18 #include <ndb_global.h>
19 #include <ndb_version.h>
21 #include <basestring_vsnprintf.h>
25 Uint32 ndbGetMajor(Uint32 version) {
26 return (version >> 16) & 0xFF;
30 Uint32 ndbGetMinor(Uint32 version) {
31 return (version >> 8) & 0xFF;
35 Uint32 ndbGetBuild(Uint32 version) {
36 return (version >> 0) & 0xFF;
40 Uint32 ndbMakeVersion(Uint32 major, Uint32 minor, Uint32 build) {
41 return NDB_MAKE_VERSION(major, minor, build);
45 const char * ndbGetOwnVersionString()
47 static char ndb_version_string_buf[NDB_VERSION_STRING_BUF_SZ];
48 return ndbGetVersionString(NDB_VERSION, NDB_MYSQL_VERSION_D, NDB_VERSION_STATUS,
49 ndb_version_string_buf,
50 sizeof(ndb_version_string_buf));
54 const char * ndbGetVersionString(Uint32 version, Uint32 mysql_version,
56 char *
buf,
unsigned sz)
58 char tmp[NDB_VERSION_STRING_BUF_SZ];
59 if (status && status[0] != 0)
60 basestring_snprintf(tmp,
sizeof(tmp),
"%s", status);
66 basestring_snprintf(buf, sz,
"mysql-%d.%d.%d ndb-%d.%d.%d%s",
67 getMajor(mysql_version),
68 getMinor(mysql_version),
69 getBuild(mysql_version),
77 basestring_snprintf(buf, sz,
"ndb-%d.%d.%d%s",
95 UG_MatchType matchType;
99 { MAKE_VERSION(7,2,NDB_VERSION_BUILD), MAKE_VERSION(7,2,0), UG_Range },
100 { MAKE_VERSION(7,2,NDB_VERSION_BUILD), MAKE_VERSION(7,1,0), UG_Range },
101 { MAKE_VERSION(7,2,NDB_VERSION_BUILD), MAKE_VERSION(7,0,0), UG_Range },
103 { MAKE_VERSION(7,1,NDB_VERSION_BUILD), MAKE_VERSION(7,1,0), UG_Range },
104 { MAKE_VERSION(7,1,NDB_VERSION_BUILD), MAKE_VERSION(7,0,0), UG_Range },
105 { MAKE_VERSION(7,1,NDB_VERSION_BUILD), MAKE_VERSION(6,4,0), UG_Range },
106 { MAKE_VERSION(7,1,NDB_VERSION_BUILD), NDBD_MAX_RECVBYTESIZE_32K, UG_Range },
107 { MAKE_VERSION(7,0,NDB_VERSION_BUILD), MAKE_VERSION(7,0,0), UG_Range },
108 { MAKE_VERSION(7,0,NDB_VERSION_BUILD), MAKE_VERSION(6,4,0), UG_Range },
112 { MAKE_VERSION(7,0,NDB_VERSION_BUILD), NDBD_MAX_RECVBYTESIZE_32K, UG_Range },
113 { MAKE_VERSION(6,3,NDB_VERSION_BUILD), MAKE_VERSION(6,2,1), UG_Range },
115 { MAKE_VERSION(6,2,NDB_VERSION_BUILD), MAKE_VERSION(6,2,1), UG_Range },
116 { MAKE_VERSION(6,2,0), MAKE_VERSION(6,2,0), UG_Range},
118 { MAKE_VERSION(6,2,NDB_VERSION_BUILD), MAKE_VERSION(6,1,19), UG_Range },
119 { MAKE_VERSION(6,1,NDB_VERSION_BUILD), MAKE_VERSION(6,1,6), UG_Range},
122 { MAKE_VERSION(6,1,4), MAKE_VERSION(6,1,2), UG_Range},
123 { MAKE_VERSION(5,1,NDB_VERSION_BUILD), MAKE_VERSION(5,1,0), UG_Range},
125 { MAKE_VERSION(5,1,NDB_VERSION_BUILD), MAKE_VERSION(5,1,18), UG_Range},
126 { MAKE_VERSION(5,1,17), MAKE_VERSION(5,1,0), UG_Range},
128 { MAKE_VERSION(5,0,NDB_VERSION_BUILD), MAKE_VERSION(5,0,12), UG_Range},
129 { MAKE_VERSION(5,0,11), MAKE_VERSION(5,0,2), UG_Range},
130 { MAKE_VERSION(4,1,NDB_VERSION_BUILD), MAKE_VERSION(4,1,15), UG_Range },
131 { MAKE_VERSION(4,1,14), MAKE_VERSION(4,1,10), UG_Range },
132 { MAKE_VERSION(4,1,10), MAKE_VERSION(4,1,9), UG_Exact },
133 { MAKE_VERSION(4,1,9), MAKE_VERSION(4,1,8), UG_Exact },
134 { MAKE_VERSION(3,5,2), MAKE_VERSION(3,5,1), UG_Exact },
139 { MAKE_VERSION(5,0,12), MAKE_VERSION(5,0,11), UG_Exact },
140 { MAKE_VERSION(5,0,2), MAKE_VERSION(4,1,8), UG_Exact },
141 { MAKE_VERSION(4,1,15), MAKE_VERSION(4,1,14), UG_Exact },
142 { MAKE_VERSION(3,5,4), MAKE_VERSION(3,5,3), UG_Exact },
147 void ndbPrintVersion()
149 printf(
"Version: %u.%u.%u\n",
150 getMajor(ndbGetOwnVersion()),
151 getMinor(ndbGetOwnVersion()),
152 getBuild(ndbGetOwnVersion()));
159 return NDB_VERSION_D;
164 ndbSearchUpgradeCompatibleTable(Uint32 ownVersion, Uint32 otherVersion,
168 for (i = 0; table[
i].ownVersion != 0 && table[
i].otherVersion != 0; i++) {
169 if (table[i].ownVersion == ownVersion ||
170 table[i].ownVersion == (Uint32) ~0) {
171 switch (table[i].matchType) {
173 if (otherVersion >= table[i].otherVersion){
178 if (otherVersion == table[i].otherVersion){
194 if (otherVersion >= ownVersion) {
197 return ndbSearchUpgradeCompatibleTable(ownVersion, otherVersion, table);
202 ndbCompatible_full(Uint32 ownVersion, Uint32 otherVersion)
204 return ndbCompatible(ownVersion, otherVersion, ndbCompatibleTable_full);
209 ndbCompatible_upgrade(Uint32 ownVersion, Uint32 otherVersion)
211 if (ndbCompatible_full(ownVersion, otherVersion))
213 return ndbCompatible(ownVersion, otherVersion, ndbCompatibleTable_upgrade);
218 ndbCompatible_mgmt_ndb(Uint32 ownVersion, Uint32 otherVersion)
220 return ndbCompatible_upgrade(ownVersion, otherVersion);
225 ndbCompatible_mgmt_api(Uint32 ownVersion, Uint32 otherVersion)
227 return ndbCompatible_upgrade(ownVersion, otherVersion);
232 ndbCompatible_ndb_mgmt(Uint32 ownVersion, Uint32 otherVersion)
234 return ndbCompatible_full(ownVersion, otherVersion);
239 ndbCompatible_api_mgmt(Uint32 ownVersion, Uint32 otherVersion)
241 return ndbCompatible_full(ownVersion, otherVersion);
246 ndbCompatible_api_ndb(Uint32 ownVersion, Uint32 otherVersion)
248 return ndbCompatible_full(ownVersion, otherVersion);
253 ndbCompatible_ndb_api(Uint32 ownVersion, Uint32 otherVersion)
255 return ndbCompatible_upgrade(ownVersion, otherVersion);
260 ndbCompatible_ndb_ndb(Uint32 ownVersion, Uint32 otherVersion)
262 return ndbCompatible_upgrade(ownVersion, otherVersion);
270 printf(
"ownVersion, matchType, otherVersion\n");
271 for (i = 0; table[
i].ownVersion != 0 && table[
i].otherVersion != 0; i++) {
274 getMajor(table[i].ownVersion),
275 getMinor(table[i].ownVersion),
276 getBuild(table[i].ownVersion));
277 switch (table[i].matchType) {
287 printf(
", %u.%u.%u\n",
288 getMajor(table[i].otherVersion),
289 getMinor(table[i].otherVersion),
290 getBuild(table[i].otherVersion));
298 ndbPrintFullyCompatibleTable(
void){
299 printf(
"ndbCompatibleTable_full\n");
300 ndbPrintCompatibleTable(ndbCompatibleTable_full);
305 ndbPrintUpgradeCompatibleTable(
void){
306 printf(
"ndbCompatibleTable_upgrade\n");
307 ndbPrintCompatibleTable(ndbCompatibleTable_upgrade);
313 #include <NdbTap.hpp>
317 printf(
"Checking NDB version defines and functions...\n\n");
319 printf(
" version string: '%s'\n", MYSQL_SERVER_VERSION);
321 printf(
" NDB_MYSQL_VERSION_MAJOR: %d\n", NDB_MYSQL_VERSION_MAJOR);
322 printf(
" NDB_MYSQL_VERSION_MINOR: %d\n", NDB_MYSQL_VERSION_MINOR);
323 printf(
" NDB_MYSQL_VERSION_BUILD: %d\n\n", NDB_MYSQL_VERSION_BUILD);
324 printf(
" NDB_VERSION_MAJOR: %d\n", NDB_VERSION_MAJOR);
325 printf(
" NDB_VERSION_MINOR: %d\n", NDB_VERSION_MINOR);
326 printf(
" NDB_VERSION_BUILD: %d\n", NDB_VERSION_BUILD);
327 printf(
" NDB_VERSION_STATUS: '%s'\n\n", NDB_VERSION_STATUS);
331 unsigned mysql_major, mysql_minor, mysql_build;
332 char mysql_status[100];
333 const int matches_version = sscanf(MYSQL_SERVER_VERSION,
"%u.%u.%u-%s",
334 &mysql_major, &mysql_minor,
335 &mysql_build, mysql_status);
336 OK(matches_version == 3 || matches_version == 4);
342 OK(NDB_MYSQL_VERSION_MAJOR == mysql_major ||
343 NDB_MYSQL_VERSION_MINOR == mysql_minor ||
344 NDB_MYSQL_VERSION_BUILD == mysql_build);
346 if (matches_version == 4 &&
347 strncmp(mysql_status,
"ndb", 3) == 0)
350 unsigned ndb_major, ndb_minor, ndb_build;
351 char ndb_status[100];
352 int matches_ndb = sscanf(mysql_status,
"ndb-%u.%u.%u%s",
353 &ndb_major, &ndb_minor,
354 &ndb_build, ndb_status);
356 printf(
"This is a MySQL Cluster build!\n");
357 printf(
" MySQL Server version(X.X.X): %u.%u.%u\n",
358 mysql_major, mysql_minor, mysql_build);
359 printf(
" NDB version(Y.Y.Y): %u.%u.%u\n",
360 ndb_major, ndb_minor, ndb_build);
362 OK(matches_ndb == 3 || matches_ndb == 4);
368 OK(NDB_VERSION_MAJOR == ndb_major ||
369 NDB_VERSION_MINOR == ndb_minor ||
370 NDB_VERSION_BUILD == ndb_build);
376 printf(
"This is a MySQL Server with NDB build!\n");
377 printf(
" MySQL Server version(X.X.X): %u.%u.%u\n",
378 mysql_major, mysql_minor, mysql_build);
379 printf(
" NDB version(Y.Y.Y): %u.%u.%u\n",
380 NDB_VERSION_MAJOR, NDB_VERSION_MINOR, NDB_VERSION_BUILD);
383 if (NDB_MYSQL_VERSION_MAJOR == NDB_VERSION_MAJOR &&
384 NDB_MYSQL_VERSION_MINOR == NDB_VERSION_MINOR &&
385 NDB_MYSQL_VERSION_BUILD == NDB_VERSION_BUILD)
392 printf(
"WARNING: The NDB version is set to same version as MySQL, "
393 "this is most likelky a configuration error!!\n\n");
398 printf(
"ndbPrintVersion() => ");
405 Uint32 version = ndbMakeVersion(major, minor, build);
406 OK(version == 0x00010203);
407 OK(ndbGetMajor(version) == major);
408 OK(ndbGetMinor(version) == minor);
409 OK(ndbGetBuild(version) == build);
413 printf(
"ndbGetVersionString(0x00010203, 0x00030201): '%s'\n",
414 ndbGetVersionString(version, 0x00030201,
"-status",
418 printf(
"ndbGetOwnVersionString: '%s'\n",
419 ndbGetOwnVersionString());
422 OK(ndbGetOwnVersion() == ndbMakeVersion(NDB_VERSION_MAJOR,
425 OK(ndbGetOwnVersion() == NDB_VERSION_D);
426 OK(ndbGetOwnVersion() == NDB_VERSION);
429 OK(NDB_MYSQL_VERSION_D == ndbMakeVersion(NDB_MYSQL_VERSION_MAJOR,
430 NDB_MYSQL_VERSION_MINOR,
431 NDB_MYSQL_VERSION_BUILD));
434 OK(ndbMakeVersion(NDB_MYSQL_VERSION_MAJOR,
435 NDB_MYSQL_VERSION_MINOR,
436 NDB_MYSQL_VERSION_BUILD) >= 0x0005012F);
437 OK(ndbMakeVersion(NDB_VERSION_MAJOR,
439 NDB_VERSION_BUILD) >= 0x00070011);
442 OK(MYSQL_VERSION_ID == (NDB_MYSQL_VERSION_MAJOR * 10000 +
443 NDB_MYSQL_VERSION_MINOR * 100 +
444 NDB_MYSQL_VERSION_BUILD));