diff options
Diffstat (limited to 'ndb/src/common/util/version.c')
-rw-r--r-- | ndb/src/common/util/version.c | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/ndb/src/common/util/version.c b/ndb/src/common/util/version.c index 7a537297861..0d254533708 100644 --- a/ndb/src/common/util/version.c +++ b/ndb/src/common/util/version.c @@ -17,6 +17,9 @@ #include <ndb_global.h> #include <ndb_version.h> #include <version.h> +#include <basestring_vsnprintf.h> +#include <NdbEnv.h> +#include <NdbOut.hpp> Uint32 getMajor(Uint32 version) { return (version >> 16) & 0xFF; @@ -38,14 +41,14 @@ Uint32 makeVersion(Uint32 major, Uint32 minor, Uint32 build) { const char * getVersionString(Uint32 version, const char * status) { char buff[100]; if (status && status[0] != 0) - snprintf(buff, sizeof(buff), + basestring_snprintf(buff, sizeof(buff), "Version %d.%d.%d (%s)", getMajor(version), getMinor(version), getBuild(version), status); else - snprintf(buff, sizeof(buff), + basestring_snprintf(buff, sizeof(buff), "Version %d.%d.%d", getMajor(version), getMinor(version), @@ -67,8 +70,27 @@ struct NdbUpGradeCompatible { /*#define TEST_VERSION*/ +#define HAVE_NDB_SETVERSION +#ifdef HAVE_NDB_SETVERSION +Uint32 ndbOwnVersionTesting = 0; +void +ndbSetOwnVersion() { + char buf[256]; + if (NdbEnv_GetEnv("NDB_SETVERSION", buf, sizeof(buf))) { + Uint32 _v1,_v2,_v3; + if (sscanf(buf, "%u.%u.%u", &_v1, &_v2, &_v3) == 3) { + ndbOwnVersionTesting = MAKE_VERSION(_v1,_v2,_v3); + ndbout_c("Testing: Version set to 0x%x", ndbOwnVersionTesting); + } + } +} +#else +void ndbSetOwnVersion() {} +#endif + #ifndef TEST_VERSION struct NdbUpGradeCompatible ndbCompatibleTable_full[] = { + { MAKE_VERSION(4,1,9), MAKE_VERSION(4,1,8), UG_Exact }, { MAKE_VERSION(3,5,2), MAKE_VERSION(3,5,1), UG_Exact }, { 0, 0, UG_Null } }; @@ -79,8 +101,6 @@ struct NdbUpGradeCompatible ndbCompatibleTable_upgrade[] = { { 0, 0, UG_Null } }; -void ndbSetOwnVersion() {} - #else /* testing purposes */ struct NdbUpGradeCompatible ndbCompatibleTable_full[] = { @@ -101,19 +121,6 @@ struct NdbUpGradeCompatible ndbCompatibleTable_upgrade[] = { }; -Uint32 ndbOwnVersionTesting = 0; -void -ndbSetOwnVersion() { - char buf[256]; - if (NdbEnv_GetEnv("NDB_SETVERSION", buf, sizeof(buf))) { - Uint32 _v1,_v2,_v3; - if (sscanf(buf, "%u.%u.%u", &_v1, &_v2, &_v3) == 3) { - ndbOwnVersionTesting = MAKE_VERSION(_v1,_v2,_v3); - ndbout_c("Testing: Version set to 0x%x", ndbOwnVersionTesting); - } - } -} - #endif void ndbPrintVersion() @@ -127,13 +134,13 @@ void ndbPrintVersion() Uint32 ndbGetOwnVersion() { -#ifndef TEST_VERSION - return NDB_VERSION_D; -#else /* testing purposes */ +#ifdef HAVE_NDB_SETVERSION if (ndbOwnVersionTesting == 0) return NDB_VERSION_D; else return ndbOwnVersionTesting; +#else + return NDB_VERSION_D; #endif } |