From e22ba29c2b6e363f9a5e102f4b2791af050b4a71 Mon Sep 17 00:00:00 2001 From: "tomas@whalegate.ndb.mysql.com" <> Date: Wed, 11 Jul 2007 14:36:44 +0200 Subject: [PATCH] fix ndb_version.h so that it is usable and make some functions public to handle ndb version --- storage/ndb/include/ndb_version.h.in | 57 ++++++++++++------- storage/ndb/include/util/version.h | 23 +++----- storage/ndb/src/common/util/version.c | 23 +++++--- .../kernel/blocks/dbdict/printSchemaFile.cpp | 2 +- storage/ndb/src/kernel/blocks/diskpage.cpp | 2 +- .../ndb/src/kernel/blocks/qmgr/QmgrMain.cpp | 2 +- storage/ndb/src/kernel/blocks/restore.cpp | 2 +- storage/ndb/src/kernel/vm/SimulatedBlock.hpp | 2 +- storage/ndb/src/mgmsrv/Services.cpp | 2 +- storage/ndb/src/ndbapi/ClusterMgr.cpp | 2 +- storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp | 2 +- storage/ndb/tools/restore/restore_main.cpp | 6 +- 12 files changed, 70 insertions(+), 55 deletions(-) diff --git a/storage/ndb/include/ndb_version.h.in b/storage/ndb/include/ndb_version.h.in index 9e1edeecd1e..5405ad4d7aa 100644 --- a/storage/ndb/include/ndb_version.h.in +++ b/storage/ndb/include/ndb_version.h.in @@ -16,8 +16,7 @@ #ifndef NDB_VERSION_H #define NDB_VERSION_H -#include -#include +#include /* NDB build version */ #define NDB_VERSION_BUILD @NDB_VERSION_BUILD@ @@ -32,19 +31,35 @@ #define NDB_VERSION_STATUS "@NDB_VERSION_STATUS@" -#define MAKE_VERSION(A,B,C) (((A) << 16) | ((B) << 8) | ((C) << 0)) +#define NDB_MAKE_VERSION(A,B,C) (((A) << 16) | ((B) << 8) | ((C) << 0)) -#define NDB_VERSION_D MAKE_VERSION(NDB_VERSION_MAJOR, NDB_VERSION_MINOR, NDB_VERSION_BUILD) +#define NDB_VERSION_D NDB_MAKE_VERSION(NDB_VERSION_MAJOR, NDB_VERSION_MINOR, NDB_VERSION_BUILD) #define NDB_VERSION_STRING_BUF_SZ 100 #ifdef __cplusplus -extern "C" -#else -extern +extern "C" { #endif -char ndb_version_string_buf[NDB_VERSION_STRING_BUF_SZ]; -#define NDB_VERSION_STRING (getVersionString(NDB_VERSION, NDB_VERSION_STATUS, \ - ndb_version_string_buf, \ - sizeof(ndb_version_string_buf))) + +void ndbPrintVersion(); + +Uint32 ndbMakeVersion(Uint32 major, Uint32 minor, Uint32 build); + +Uint32 ndbGetMajor(Uint32 version); + +Uint32 ndbGetMinor(Uint32 version); + +Uint32 ndbGetBuild(Uint32 version); + +const char* ndbGetVersionString(Uint32 version, const char * status, + char *buf, unsigned sz); +const char* ndbGetOwnVersionString(); + +Uint32 ndbGetOwnVersion(); + +#ifdef __cplusplus +} +#endif + +#define NDB_VERSION_STRING ndbGetOwnVersionString() #define NDB_VERSION ndbGetOwnVersion() @@ -59,19 +74,19 @@ char ndb_version_string_buf[NDB_VERSION_STRING_BUF_SZ]; /** * From which version do we support rowid */ -#define NDBD_ROWID_VERSION (MAKE_VERSION(5,1,6)) -#define NDBD_INCL_NODECONF_VERSION_4 MAKE_VERSION(4,1,17) -#define NDBD_INCL_NODECONF_VERSION_5 MAKE_VERSION(5,0,18) -#define NDBD_FRAGID_VERSION (MAKE_VERSION(5,1,6)) -#define NDBD_DICT_LOCK_VERSION_5 MAKE_VERSION(5,0,23) -#define NDBD_DICT_LOCK_VERSION_5_1 MAKE_VERSION(5,1,12) +#define NDBD_ROWID_VERSION (NDB_MAKE_VERSION(5,1,6)) +#define NDBD_INCL_NODECONF_VERSION_4 NDB_MAKE_VERSION(4,1,17) +#define NDBD_INCL_NODECONF_VERSION_5 NDB_MAKE_VERSION(5,0,18) +#define NDBD_FRAGID_VERSION (NDB_MAKE_VERSION(5,1,6)) +#define NDBD_DICT_LOCK_VERSION_5 NDB_MAKE_VERSION(5,0,23) +#define NDBD_DICT_LOCK_VERSION_5_1 NDB_MAKE_VERSION(5,1,12) -#define NDBD_UPDATE_FRAG_DIST_KEY_50 MAKE_VERSION(5,0,26) -#define NDBD_UPDATE_FRAG_DIST_KEY_51 MAKE_VERSION(5,1,12) +#define NDBD_UPDATE_FRAG_DIST_KEY_50 NDB_MAKE_VERSION(5,0,26) +#define NDBD_UPDATE_FRAG_DIST_KEY_51 NDB_MAKE_VERSION(5,1,12) -#define NDBD_QMGR_SINGLEUSER_VERSION_5 MAKE_VERSION(5,0,25) +#define NDBD_QMGR_SINGLEUSER_VERSION_5 NDB_MAKE_VERSION(5,0,25) -#define NDBD_NODE_VERSION_REP MAKE_VERSION(6,1,1) +#define NDBD_NODE_VERSION_REP NDB_MAKE_VERSION(6,1,1) #endif diff --git a/storage/ndb/include/util/version.h b/storage/ndb/include/util/version.h index 42513d00442..9ea18ecd9d9 100644 --- a/storage/ndb/include/util/version.h +++ b/storage/ndb/include/util/version.h @@ -16,25 +16,18 @@ #ifndef VERSION_H #define VERSION_H -#include +#include + +/* some backwards compatible macros */ +#define MAKE_VERSION(A,B,C) NDB_MAKE_VERSION(A,B,C) +#define getMajor(a) ndbGetMajor(a) +#define getMinor(a) ndbGetMinor(a) +#define getBuild(a) ndbGetBuild(a) + #ifdef __cplusplus extern "C" { #endif - Uint32 getMajor(Uint32 version); - - Uint32 getMinor(Uint32 version); - - Uint32 getBuild(Uint32 version); - - Uint32 makeVersion(Uint32 major, Uint32 minor, Uint32 build); - - const char* getVersionString(Uint32 version, const char * status, - char *buf, unsigned sz); - - void ndbPrintVersion(); - Uint32 ndbGetOwnVersion(); - int ndbCompatible_mgmt_ndb(Uint32 ownVersion, Uint32 otherVersion); int ndbCompatible_ndb_mgmt(Uint32 ownVersion, Uint32 otherVersion); int ndbCompatible_mgmt_api(Uint32 ownVersion, Uint32 otherVersion); diff --git a/storage/ndb/src/common/util/version.c b/storage/ndb/src/common/util/version.c index f309a3d4ad5..56a92489131 100644 --- a/storage/ndb/src/common/util/version.c +++ b/storage/ndb/src/common/util/version.c @@ -20,26 +20,33 @@ #include #include -Uint32 getMajor(Uint32 version) { +Uint32 ndbGetMajor(Uint32 version) { return (version >> 16) & 0xFF; } -Uint32 getMinor(Uint32 version) { +Uint32 ndbGetMinor(Uint32 version) { return (version >> 8) & 0xFF; } -Uint32 getBuild(Uint32 version) { +Uint32 ndbGetBuild(Uint32 version) { return (version >> 0) & 0xFF; } -Uint32 makeVersion(Uint32 major, Uint32 minor, Uint32 build) { - return MAKE_VERSION(major, minor, build); +Uint32 ndbMakeVersion(Uint32 major, Uint32 minor, Uint32 build) { + return NDB_MAKE_VERSION(major, minor, build); } -char ndb_version_string_buf[NDB_VERSION_STRING_BUF_SZ]; -const char * getVersionString(Uint32 version, const char * status, - char *buf, unsigned sz) +const char * ndbGetOwnVersionString() +{ + static char ndb_version_string_buf[NDB_VERSION_STRING_BUF_SZ]; + return ndbGetVersionString(NDB_VERSION, NDB_VERSION_STATUS, + ndb_version_string_buf, + sizeof(ndb_version_string_buf)); +} + +const char * ndbGetVersionString(Uint32 version, const char * status, + char *buf, unsigned sz) { if (status && status[0] != 0) basestring_snprintf(buf, sz, diff --git a/storage/ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp b/storage/ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp index 602881095c3..44326e213d0 100644 --- a/storage/ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp +++ b/storage/ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp @@ -15,7 +15,7 @@ #include -#include +#include #include #include diff --git a/storage/ndb/src/kernel/blocks/diskpage.cpp b/storage/ndb/src/kernel/blocks/diskpage.cpp index 3f98e078746..50e9b6e53cb 100644 --- a/storage/ndb/src/kernel/blocks/diskpage.cpp +++ b/storage/ndb/src/kernel/blocks/diskpage.cpp @@ -49,7 +49,7 @@ operator<<(NdbOut& out, const File_formats::Zero_page_header& obj) char buf[256]; out << "page size: " << obj.m_page_size << endl; out << "ndb version: " << obj.m_ndb_version << ", " << - getVersionString(obj.m_ndb_version, 0, buf, sizeof(buf)) << endl; + ndbGetVersionString(obj.m_ndb_version, 0, buf, sizeof(buf)) << endl; out << "ndb node id: " << obj.m_node_id << endl; out << "file type: " << obj.m_file_type << endl; out << "time: " << obj.m_time << ", " diff --git a/storage/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp b/storage/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp index 52045fd63cd..1fba4d62e17 100644 --- a/storage/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp +++ b/storage/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp @@ -2793,7 +2793,7 @@ void Qmgr::execAPI_REGREQ(Signal* signal) "incompatible with %s", type == NodeInfo::API ? "api or mysqld" : "management server", apiNodePtr.i, - getVersionString(version,"",buf,sizeof(buf)), + ndbGetVersionString(version,"",buf,sizeof(buf)), NDB_VERSION_STRING); apiNodePtr.p->phase = ZAPI_INACTIVE; sendApiRegRef(signal, ref, ApiRegRef::UnsupportedVersion); diff --git a/storage/ndb/src/kernel/blocks/restore.cpp b/storage/ndb/src/kernel/blocks/restore.cpp index 2d40cd79daa..efc4bc1948a 100644 --- a/storage/ndb/src/kernel/blocks/restore.cpp +++ b/storage/ndb/src/kernel/blocks/restore.cpp @@ -1271,7 +1271,7 @@ Restore::check_file_version(Signal* signal, Uint32 file_version) { char buf[255]; char verbuf[255]; - getVersionString(file_version, 0, verbuf, sizeof(verbuf)); + ndbGetVersionString(file_version, 0, verbuf, sizeof(verbuf)); BaseString::snprintf(buf, sizeof(buf), "Unsupported version of LCP files found on disk, " " found: %s", verbuf); diff --git a/storage/ndb/src/kernel/vm/SimulatedBlock.hpp b/storage/ndb/src/kernel/vm/SimulatedBlock.hpp index a78ee21fb8f..31f219718e5 100644 --- a/storage/ndb/src/kernel/vm/SimulatedBlock.hpp +++ b/storage/ndb/src/kernel/vm/SimulatedBlock.hpp @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include "VMSignal.hpp" diff --git a/storage/ndb/src/mgmsrv/Services.cpp b/storage/ndb/src/mgmsrv/Services.cpp index f260ff7e3ec..9272b5ab532 100644 --- a/storage/ndb/src/mgmsrv/Services.cpp +++ b/storage/ndb/src/mgmsrv/Services.cpp @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include #include diff --git a/storage/ndb/src/ndbapi/ClusterMgr.cpp b/storage/ndb/src/ndbapi/ClusterMgr.cpp index f51a5098c53..448bc1025e8 100644 --- a/storage/ndb/src/ndbapi/ClusterMgr.cpp +++ b/storage/ndb/src/ndbapi/ClusterMgr.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include "TransporterFacade.hpp" #include "ClusterMgr.hpp" diff --git a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp index 63d36bf012f..ab6d90ad59e 100644 --- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -42,7 +42,7 @@ #include #include #include -#include +#include #define DEBUG_PRINT 0 #define INCOMPATIBLE_VERSION -2 diff --git a/storage/ndb/tools/restore/restore_main.cpp b/storage/ndb/tools/restore/restore_main.cpp index 79aebbaac45..30ecc695eba 100644 --- a/storage/ndb/tools/restore/restore_main.cpp +++ b/storage/ndb/tools/restore/restore_main.cpp @@ -684,7 +684,7 @@ main(int argc, char** argv) char buf[NDB_VERSION_STRING_BUF_SZ]; info.setLevel(254); info << "Ndb version in backup files: " - << getVersionString(version, 0, buf, sizeof(buf)) << endl; + << ndbGetVersionString(version, 0, buf, sizeof(buf)) << endl; /** * check wheater we can restore the backup (right version). @@ -694,9 +694,9 @@ main(int argc, char** argv) if (version >= MAKE_VERSION(5,1,3) && version <= MAKE_VERSION(5,1,9)) { err << "Restore program incompatible with backup versions between " - << getVersionString(MAKE_VERSION(5,1,3), 0, buf, sizeof(buf)) + << ndbGetVersionString(MAKE_VERSION(5,1,3), 0, buf, sizeof(buf)) << " and " - << getVersionString(MAKE_VERSION(5,1,9), 0, buf, sizeof(buf)) + << ndbGetVersionString(MAKE_VERSION(5,1,9), 0, buf, sizeof(buf)) << endl; exitHandler(NDBT_FAILED); }