Commit 1051676c authored by unknown's avatar unknown

fix ndb_version.h so that it is usable and make some functions public to handle ndb version

parent df1bbc8f
...@@ -16,8 +16,7 @@ ...@@ -16,8 +16,7 @@
#ifndef NDB_VERSION_H #ifndef NDB_VERSION_H
#define NDB_VERSION_H #define NDB_VERSION_H
#include <ndb_global.h> #include <ndb_types.h>
#include <version.h>
/* NDB build version */ /* NDB build version */
#define NDB_VERSION_BUILD @NDB_VERSION_BUILD@ #define NDB_VERSION_BUILD @NDB_VERSION_BUILD@
...@@ -32,19 +31,35 @@ ...@@ -32,19 +31,35 @@
#define NDB_VERSION_STATUS "@NDB_VERSION_STATUS@" #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 #define NDB_VERSION_STRING_BUF_SZ 100
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C" {
#else
extern
#endif #endif
char ndb_version_string_buf[NDB_VERSION_STRING_BUF_SZ];
#define NDB_VERSION_STRING (getVersionString(NDB_VERSION, NDB_VERSION_STATUS, \ void ndbPrintVersion();
ndb_version_string_buf, \
sizeof(ndb_version_string_buf))) 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() #define NDB_VERSION ndbGetOwnVersion()
...@@ -59,19 +74,19 @@ char ndb_version_string_buf[NDB_VERSION_STRING_BUF_SZ]; ...@@ -59,19 +74,19 @@ char ndb_version_string_buf[NDB_VERSION_STRING_BUF_SZ];
/** /**
* From which version do we support rowid * From which version do we support rowid
*/ */
#define NDBD_ROWID_VERSION (MAKE_VERSION(5,1,6)) #define NDBD_ROWID_VERSION (NDB_MAKE_VERSION(5,1,6))
#define NDBD_INCL_NODECONF_VERSION_4 MAKE_VERSION(4,1,17) #define NDBD_INCL_NODECONF_VERSION_4 NDB_MAKE_VERSION(4,1,17)
#define NDBD_INCL_NODECONF_VERSION_5 MAKE_VERSION(5,0,18) #define NDBD_INCL_NODECONF_VERSION_5 NDB_MAKE_VERSION(5,0,18)
#define NDBD_FRAGID_VERSION (MAKE_VERSION(5,1,6)) #define NDBD_FRAGID_VERSION (NDB_MAKE_VERSION(5,1,6))
#define NDBD_DICT_LOCK_VERSION_5 MAKE_VERSION(5,0,23) #define NDBD_DICT_LOCK_VERSION_5 NDB_MAKE_VERSION(5,0,23)
#define NDBD_DICT_LOCK_VERSION_5_1 MAKE_VERSION(5,1,12) #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_50 NDB_MAKE_VERSION(5,0,26)
#define NDBD_UPDATE_FRAG_DIST_KEY_51 MAKE_VERSION(5,1,12) #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 #endif
...@@ -16,25 +16,18 @@ ...@@ -16,25 +16,18 @@
#ifndef VERSION_H #ifndef VERSION_H
#define VERSION_H #define VERSION_H
#include <ndb_types.h> #include <ndb_version.h>
/* 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 #ifdef __cplusplus
extern "C" { extern "C" {
#endif #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_mgmt_ndb(Uint32 ownVersion, Uint32 otherVersion);
int ndbCompatible_ndb_mgmt(Uint32 ownVersion, Uint32 otherVersion); int ndbCompatible_ndb_mgmt(Uint32 ownVersion, Uint32 otherVersion);
int ndbCompatible_mgmt_api(Uint32 ownVersion, Uint32 otherVersion); int ndbCompatible_mgmt_api(Uint32 ownVersion, Uint32 otherVersion);
......
...@@ -20,26 +20,33 @@ ...@@ -20,26 +20,33 @@
#include <NdbEnv.h> #include <NdbEnv.h>
#include <NdbOut.hpp> #include <NdbOut.hpp>
Uint32 getMajor(Uint32 version) { Uint32 ndbGetMajor(Uint32 version) {
return (version >> 16) & 0xFF; return (version >> 16) & 0xFF;
} }
Uint32 getMinor(Uint32 version) { Uint32 ndbGetMinor(Uint32 version) {
return (version >> 8) & 0xFF; return (version >> 8) & 0xFF;
} }
Uint32 getBuild(Uint32 version) { Uint32 ndbGetBuild(Uint32 version) {
return (version >> 0) & 0xFF; return (version >> 0) & 0xFF;
} }
Uint32 makeVersion(Uint32 major, Uint32 minor, Uint32 build) { Uint32 ndbMakeVersion(Uint32 major, Uint32 minor, Uint32 build) {
return MAKE_VERSION(major, minor, build); return NDB_MAKE_VERSION(major, minor, build);
} }
char ndb_version_string_buf[NDB_VERSION_STRING_BUF_SZ]; const char * ndbGetOwnVersionString()
const char * getVersionString(Uint32 version, const char * status, {
char *buf, unsigned sz) 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) if (status && status[0] != 0)
basestring_snprintf(buf, sz, basestring_snprintf(buf, sz,
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <ndb_global.h> #include <ndb_global.h>
#include <ndb_version.h> #include <util/version.h>
#include <NdbMain.h> #include <NdbMain.h>
#include <NdbOut.hpp> #include <NdbOut.hpp>
......
...@@ -49,7 +49,7 @@ operator<<(NdbOut& out, const File_formats::Zero_page_header& obj) ...@@ -49,7 +49,7 @@ operator<<(NdbOut& out, const File_formats::Zero_page_header& obj)
char buf[256]; char buf[256];
out << "page size: " << obj.m_page_size << endl; out << "page size: " << obj.m_page_size << endl;
out << "ndb version: " << obj.m_ndb_version << ", " << 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 << "ndb node id: " << obj.m_node_id << endl;
out << "file type: " << obj.m_file_type << endl; out << "file type: " << obj.m_file_type << endl;
out << "time: " << obj.m_time << ", " out << "time: " << obj.m_time << ", "
......
...@@ -2793,7 +2793,7 @@ void Qmgr::execAPI_REGREQ(Signal* signal) ...@@ -2793,7 +2793,7 @@ void Qmgr::execAPI_REGREQ(Signal* signal)
"incompatible with %s", "incompatible with %s",
type == NodeInfo::API ? "api or mysqld" : "management server", type == NodeInfo::API ? "api or mysqld" : "management server",
apiNodePtr.i, apiNodePtr.i,
getVersionString(version,"",buf,sizeof(buf)), ndbGetVersionString(version,"",buf,sizeof(buf)),
NDB_VERSION_STRING); NDB_VERSION_STRING);
apiNodePtr.p->phase = ZAPI_INACTIVE; apiNodePtr.p->phase = ZAPI_INACTIVE;
sendApiRegRef(signal, ref, ApiRegRef::UnsupportedVersion); sendApiRegRef(signal, ref, ApiRegRef::UnsupportedVersion);
......
...@@ -1271,7 +1271,7 @@ Restore::check_file_version(Signal* signal, Uint32 file_version) ...@@ -1271,7 +1271,7 @@ Restore::check_file_version(Signal* signal, Uint32 file_version)
{ {
char buf[255]; char buf[255];
char verbuf[255]; char verbuf[255];
getVersionString(file_version, 0, verbuf, sizeof(verbuf)); ndbGetVersionString(file_version, 0, verbuf, sizeof(verbuf));
BaseString::snprintf(buf, sizeof(buf), BaseString::snprintf(buf, sizeof(buf),
"Unsupported version of LCP files found on disk, " "Unsupported version of LCP files found on disk, "
" found: %s", verbuf); " found: %s", verbuf);
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include <NdbTick.h> #include <NdbTick.h>
#include <kernel_types.h> #include <kernel_types.h>
#include <ndb_version.h> #include <util/version.h>
#include <ndb_limits.h> #include <ndb_limits.h>
#include "VMSignal.hpp" #include "VMSignal.hpp"
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include <uucode.h> #include <uucode.h>
#include <socket_io.h> #include <socket_io.h>
#include <ndb_version.h> #include <util/version.h>
#include <mgmapi.h> #include <mgmapi.h>
#include <EventLogger.hpp> #include <EventLogger.hpp>
#include <signaldata/SetLogLevelOrd.hpp> #include <signaldata/SetLogLevelOrd.hpp>
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include <ndb_global.h> #include <ndb_global.h>
#include <my_pthread.h> #include <my_pthread.h>
#include <ndb_limits.h> #include <ndb_limits.h>
#include <ndb_version.h> #include <util/version.h>
#include "TransporterFacade.hpp" #include "TransporterFacade.hpp"
#include "ClusterMgr.hpp" #include "ClusterMgr.hpp"
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
#include <my_sys.h> #include <my_sys.h>
#include <NdbEnv.h> #include <NdbEnv.h>
#include <NdbMem.h> #include <NdbMem.h>
#include <ndb_version.h> #include <util/version.h>
#define DEBUG_PRINT 0 #define DEBUG_PRINT 0
#define INCOMPATIBLE_VERSION -2 #define INCOMPATIBLE_VERSION -2
......
...@@ -684,7 +684,7 @@ main(int argc, char** argv) ...@@ -684,7 +684,7 @@ main(int argc, char** argv)
char buf[NDB_VERSION_STRING_BUF_SZ]; char buf[NDB_VERSION_STRING_BUF_SZ];
info.setLevel(254); info.setLevel(254);
info << "Ndb version in backup files: " 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). * check wheater we can restore the backup (right version).
...@@ -694,9 +694,9 @@ main(int argc, char** argv) ...@@ -694,9 +694,9 @@ main(int argc, char** argv)
if (version >= MAKE_VERSION(5,1,3) && version <= MAKE_VERSION(5,1,9)) if (version >= MAKE_VERSION(5,1,3) && version <= MAKE_VERSION(5,1,9))
{ {
err << "Restore program incompatible with backup versions between " 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 " << " and "
<< getVersionString(MAKE_VERSION(5,1,9), 0, buf, sizeof(buf)) << ndbGetVersionString(MAKE_VERSION(5,1,9), 0, buf, sizeof(buf))
<< endl; << endl;
exitHandler(NDBT_FAILED); exitHandler(NDBT_FAILED);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment