summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ndb/examples/ndbapi_async_example/ndbapi_async.cpp11
-rw-r--r--ndb/examples/ndbapi_example1/ndbapi_example1.cpp5
-rw-r--r--ndb/examples/ndbapi_example2/ndbapi_example2.cpp1
-rw-r--r--ndb/examples/ndbapi_example3/ndbapi_example3.cpp1
-rw-r--r--ndb/examples/ndbapi_example4/ndbapi_example4.cpp5
-rw-r--r--ndb/examples/ndbapi_example5/ndbapi_example5.cpp1
-rw-r--r--ndb/examples/ndbapi_scan_example/ndbapi_scan.cpp10
-rw-r--r--ndb/examples/select_all/select_all.cpp1
-rw-r--r--ndb/include/debugger/EventLogger.hpp167
-rw-r--r--ndb/include/kernel/LogLevel.hpp24
-rw-r--r--ndb/include/kernel/signaldata/DictTabInfo.hpp4
-rw-r--r--ndb/include/kernel/signaldata/EventSubscribeReq.hpp14
-rw-r--r--ndb/include/kernel/signaldata/SetLogLevelOrd.hpp19
-rw-r--r--ndb/include/mgmapi/mgmapi.h18
-rw-r--r--ndb/include/mgmapi/mgmapi_config_parameters.h6
-rw-r--r--ndb/include/ndb_global.h3
-rw-r--r--ndb/include/ndbapi/NdbDictionary.hpp26
-rw-r--r--ndb/include/transporter/TransporterRegistry.hpp11
-rw-r--r--ndb/include/util/NdbSqlUtil.hpp7
-rw-r--r--ndb/src/common/debugger/EventLogger.cpp423
-rw-r--r--ndb/src/common/mgmcommon/ConfigRetriever.cpp4
-rw-r--r--ndb/src/common/mgmcommon/IPCConfig.cpp46
-rw-r--r--ndb/src/common/portlib/NdbTCP.cpp10
-rw-r--r--ndb/src/common/transporter/TransporterRegistry.cpp102
-rw-r--r--ndb/src/common/util/Makefile.am2
-rw-r--r--ndb/src/common/util/NdbSqlUtil.cpp77
-rw-r--r--ndb/src/common/util/SocketServer.cpp30
-rw-r--r--ndb/src/common/util/ndb_init.c29
-rw-r--r--ndb/src/kernel/blocks/backup/read.cpp1
-rw-r--r--ndb/src/kernel/blocks/backup/restore/main.cpp5
-rw-r--r--ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp33
-rw-r--r--ndb/src/kernel/blocks/dbdict/Dbdict.cpp2
-rw-r--r--ndb/src/kernel/main.cpp1
-rw-r--r--ndb/src/kernel/vm/Configuration.cpp2
-rw-r--r--ndb/src/mgmclient/CommandInterpreter.cpp17
-rw-r--r--ndb/src/mgmclient/main.cpp1
-rw-r--r--ndb/src/mgmsrv/CommandInterpreter.cpp22
-rw-r--r--ndb/src/mgmsrv/ConfigInfo.cpp38
-rw-r--r--ndb/src/mgmsrv/Makefile.am2
-rw-r--r--ndb/src/mgmsrv/MgmtSrvr.cpp651
-rw-r--r--ndb/src/mgmsrv/MgmtSrvr.hpp118
-rw-r--r--ndb/src/mgmsrv/NodeLogLevel.cpp70
-rw-r--r--ndb/src/mgmsrv/NodeLogLevel.hpp54
-rw-r--r--ndb/src/mgmsrv/NodeLogLevelList.cpp182
-rw-r--r--ndb/src/mgmsrv/NodeLogLevelList.hpp93
-rw-r--r--ndb/src/mgmsrv/Services.cpp202
-rw-r--r--ndb/src/mgmsrv/Services.hpp27
-rw-r--r--ndb/src/mgmsrv/main.cpp37
-rw-r--r--ndb/src/mgmsrv/mkconfig/mkconfig.cpp1
-rw-r--r--ndb/src/ndbapi/NdbDictionary.cpp58
-rw-r--r--ndb/src/ndbapi/NdbDictionaryImpl.cpp163
-rw-r--r--ndb/src/ndbapi/NdbDictionaryImpl.hpp12
-rw-r--r--ndb/src/ndbapi/Ndbinit.cpp2
-rw-r--r--ndb/src/ndbapi/ndberror.c3
-rw-r--r--ndb/test/include/NDBT_Table.hpp4
-rw-r--r--ndb/test/ndbapi/Makefile.am3
-rw-r--r--ndb/test/ndbapi/acid.cpp1
-rw-r--r--ndb/test/ndbapi/acid2.cpp1
-rw-r--r--ndb/test/ndbapi/bank/Bank.cpp156
-rw-r--r--ndb/test/ndbapi/bank/Bank.hpp5
-rw-r--r--ndb/test/ndbapi/bank/BankLoad.cpp4
-rw-r--r--ndb/test/ndbapi/bank/bankCreator.cpp1
-rw-r--r--ndb/test/ndbapi/bank/bankMakeGL.cpp1
-rw-r--r--ndb/test/ndbapi/bank/bankSumAccounts.cpp1
-rw-r--r--ndb/test/ndbapi/bank/bankTimer.cpp1
-rw-r--r--ndb/test/ndbapi/bank/bankTransactionMaker.cpp1
-rw-r--r--ndb/test/ndbapi/bank/bankValidateAllGLs.cpp1
-rw-r--r--ndb/test/ndbapi/bank/testBank.cpp1
-rw-r--r--ndb/test/ndbapi/benchronja.cpp1
-rw-r--r--ndb/test/ndbapi/bulk_copy.cpp1
-rw-r--r--ndb/test/ndbapi/cdrserver.cpp1
-rw-r--r--ndb/test/ndbapi/celloDb.cpp1
-rw-r--r--ndb/test/ndbapi/create_all_tabs.cpp1
-rw-r--r--ndb/test/ndbapi/create_tab.cpp1
-rw-r--r--ndb/test/ndbapi/drop_all_tabs.cpp1
-rw-r--r--ndb/test/ndbapi/flexAsynch.cpp1
-rw-r--r--ndb/test/ndbapi/flexBench.cpp1
-rw-r--r--ndb/test/ndbapi/flexHammer.cpp1
-rw-r--r--ndb/test/ndbapi/flexScan.cpp1
-rw-r--r--ndb/test/ndbapi/flexTT.cpp1
-rw-r--r--ndb/test/ndbapi/flexTimedAsynch.cpp1
-rw-r--r--ndb/test/ndbapi/flex_bench_mysql.cpp1
-rw-r--r--ndb/test/ndbapi/index.cpp17
-rw-r--r--ndb/test/ndbapi/index2.cpp5
-rw-r--r--ndb/test/ndbapi/initronja.cpp1
-rw-r--r--ndb/test/ndbapi/interpreterInTup.cpp1
-rw-r--r--ndb/test/ndbapi/mainAsyncGenerator.cpp1
-rw-r--r--ndb/test/ndbapi/msa.cpp1
-rw-r--r--ndb/test/ndbapi/restarter.cpp1
-rw-r--r--ndb/test/ndbapi/restarter2.cpp1
-rw-r--r--ndb/test/ndbapi/restarts.cpp1
-rw-r--r--ndb/test/ndbapi/size.cpp1
-rw-r--r--ndb/test/ndbapi/slow_select.cpp1
-rw-r--r--ndb/test/ndbapi/testBackup.cpp12
-rw-r--r--ndb/test/ndbapi/testBasic.cpp1
-rw-r--r--ndb/test/ndbapi/testBasicAsynch.cpp1
-rw-r--r--ndb/test/ndbapi/testBlobs.cpp1
-rw-r--r--ndb/test/ndbapi/testDataBuffers.cpp1
-rw-r--r--ndb/test/ndbapi/testDeadlock.cpp1
-rw-r--r--ndb/test/ndbapi/testDict.cpp3
-rw-r--r--ndb/test/ndbapi/testGrep.cpp1
-rw-r--r--ndb/test/ndbapi/testGrepVerify.cpp1
-rw-r--r--ndb/test/ndbapi/testIndex.cpp1
-rw-r--r--ndb/test/ndbapi/testInterpreter.cpp1
-rw-r--r--ndb/test/ndbapi/testLcp.cpp320
-rw-r--r--ndb/test/ndbapi/testMgm.cpp1
-rw-r--r--ndb/test/ndbapi/testNdbApi.cpp1
-rw-r--r--ndb/test/ndbapi/testNodeRestart.cpp1
-rw-r--r--ndb/test/ndbapi/testOIBasic.cpp6
-rw-r--r--ndb/test/ndbapi/testOperations.cpp1
-rw-r--r--ndb/test/ndbapi/testOrderedIndex.cpp1
-rw-r--r--ndb/test/ndbapi/testReadPerf.cpp1
-rw-r--r--ndb/test/ndbapi/testRestartGci.cpp1
-rw-r--r--ndb/test/ndbapi/testScan.cpp1
-rw-r--r--ndb/test/ndbapi/testScanInterpreter.cpp1
-rw-r--r--ndb/test/ndbapi/testScanPerf.cpp1
-rw-r--r--ndb/test/ndbapi/testSystemRestart.cpp1
-rw-r--r--ndb/test/ndbapi/testTimeout.cpp1
-rw-r--r--ndb/test/ndbapi/testTransactions.cpp1
-rw-r--r--ndb/test/ndbapi/test_event.cpp1
-rwxr-xr-xndb/test/run-test/atrt-mysql-test-run17
-rw-r--r--ndb/test/run-test/daily-basic-tests.txt15
-rw-r--r--ndb/test/run-test/daily-devel-tests.txt24
-rw-r--r--ndb/test/run-test/main.cpp1
-rw-r--r--ndb/test/src/HugoTransactions.cpp7
-rw-r--r--ndb/test/src/NDBT_Test.cpp7
-rw-r--r--ndb/test/src/NdbBackup.cpp31
-rw-r--r--ndb/test/tools/copy_tab.cpp1
-rw-r--r--ndb/test/tools/cpcc.cpp1
-rw-r--r--ndb/test/tools/create_index.cpp1
-rw-r--r--ndb/test/tools/hugoCalculator.cpp1
-rw-r--r--ndb/test/tools/hugoFill.cpp1
-rw-r--r--ndb/test/tools/hugoLoad.cpp1
-rw-r--r--ndb/test/tools/hugoLockRecords.cpp1
-rw-r--r--ndb/test/tools/hugoPkDelete.cpp1
-rw-r--r--ndb/test/tools/hugoPkRead.cpp1
-rw-r--r--ndb/test/tools/hugoPkReadRecord.cpp1
-rw-r--r--ndb/test/tools/hugoPkUpdate.cpp1
-rw-r--r--ndb/test/tools/hugoScanRead.cpp1
-rw-r--r--ndb/test/tools/hugoScanUpdate.cpp1
-rw-r--r--ndb/test/tools/restart.cpp1
-rw-r--r--ndb/test/tools/transproxy.cpp1
-rw-r--r--ndb/test/tools/verify_index.cpp1
-rw-r--r--ndb/tools/delete_all.cpp1
-rw-r--r--ndb/tools/desc.cpp1
-rw-r--r--ndb/tools/drop_index.cpp1
-rw-r--r--ndb/tools/drop_tab.cpp1
-rw-r--r--ndb/tools/listTables.cpp3
-rw-r--r--ndb/tools/ndbsql.cpp1
-rw-r--r--ndb/tools/select_all.cpp3
-rw-r--r--ndb/tools/select_count.cpp1
-rw-r--r--ndb/tools/waiter.cpp1
-rw-r--r--sql/ha_ndbcluster.cc26
153 files changed, 1904 insertions, 1697 deletions
diff --git a/ndb/examples/ndbapi_async_example/ndbapi_async.cpp b/ndb/examples/ndbapi_async_example/ndbapi_async.cpp
index 7abebcc832d..76ce1a8efe3 100644
--- a/ndb/examples/ndbapi_async_example/ndbapi_async.cpp
+++ b/ndb/examples/ndbapi_async_example/ndbapi_async.cpp
@@ -46,9 +46,9 @@
*
* NdbDictionary::Column
* setName()
- * setPrimaryKey()
* setType()
* setLength()
+ * setPrimaryKey()
* setNullable()
*
* NdbDictionary::Table
@@ -234,9 +234,9 @@ int create_table(Ndb * myNdb)
* Column REG_NO
*/
myColumn.setName("REG_NO");
- myColumn.setPrimaryKey(true);
myColumn.setType(NdbDictionary::Column::Unsigned);
myColumn.setLength(1);
+ myColumn.setPrimaryKey(true);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
@@ -244,9 +244,9 @@ int create_table(Ndb * myNdb)
* Column BRAND
*/
myColumn.setName("BRAND");
- myColumn.setPrimaryKey(false);
myColumn.setType(NdbDictionary::Column::Char);
myColumn.setLength(20);
+ myColumn.setPrimaryKey(false);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
@@ -254,9 +254,9 @@ int create_table(Ndb * myNdb)
* Column COLOR
*/
myColumn.setName("COLOR");
- myColumn.setPrimaryKey(false);
myColumn.setType(NdbDictionary::Column::Char);
myColumn.setLength(20);
+ myColumn.setPrimaryKey(false);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
@@ -454,6 +454,7 @@ int populate(Ndb * myNdb, int data, async_callback_t * cbData)
int main()
{
+ ndb_init();
Ndb* myNdb = new Ndb( "TEST_DB" ); // Object representing the database
/*******************************************
@@ -493,5 +494,3 @@ int main()
std::cout << "Number of temporary errors: " << tempErrors << std::endl;
delete myNdb;
}
-
-
diff --git a/ndb/examples/ndbapi_example1/ndbapi_example1.cpp b/ndb/examples/ndbapi_example1/ndbapi_example1.cpp
index 879d86de824..03a84aa249b 100644
--- a/ndb/examples/ndbapi_example1/ndbapi_example1.cpp
+++ b/ndb/examples/ndbapi_example1/ndbapi_example1.cpp
@@ -44,6 +44,7 @@
int main()
{
+ ndb_init();
Ndb* myNdb = new Ndb( "TEST_DB_1" ); // Object representing the database
NdbDictionary::Table myTable;
NdbDictionary::Column myColumn;
@@ -78,16 +79,16 @@ int main()
myTable.setName("MYTABLENAME");
myColumn.setName("ATTR1");
- myColumn.setPrimaryKey(true);
myColumn.setType(NdbDictionary::Column::Unsigned);
myColumn.setLength(1);
+ myColumn.setPrimaryKey(true);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
myColumn.setName("ATTR2");
- myColumn.setPrimaryKey(false);
myColumn.setType(NdbDictionary::Column::Unsigned);
myColumn.setLength(1);
+ myColumn.setPrimaryKey(false);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
diff --git a/ndb/examples/ndbapi_example2/ndbapi_example2.cpp b/ndb/examples/ndbapi_example2/ndbapi_example2.cpp
index 1c61721c037..95a7bae66b8 100644
--- a/ndb/examples/ndbapi_example2/ndbapi_example2.cpp
+++ b/ndb/examples/ndbapi_example2/ndbapi_example2.cpp
@@ -39,6 +39,7 @@ static void callback(int result, NdbConnection* NdbObject, void* aObject);
int main()
{
+ ndb_init();
Ndb* myNdb = new Ndb( "TEST_DB_2" ); // Object representing the database
NdbConnection* myNdbConnection[2]; // For transactions
diff --git a/ndb/examples/ndbapi_example3/ndbapi_example3.cpp b/ndb/examples/ndbapi_example3/ndbapi_example3.cpp
index 36d2cf1608c..91d9ff122ba 100644
--- a/ndb/examples/ndbapi_example3/ndbapi_example3.cpp
+++ b/ndb/examples/ndbapi_example3/ndbapi_example3.cpp
@@ -176,6 +176,7 @@ int executeInsertTransaction(int transactionId, Ndb* myNdb) {
int main()
{
+ ndb_init();
Ndb* myNdb = new Ndb( "TEST_DB_1" ); // Object representing the database
/*******************************************
diff --git a/ndb/examples/ndbapi_example4/ndbapi_example4.cpp b/ndb/examples/ndbapi_example4/ndbapi_example4.cpp
index 520172b9b0c..fcb770d49e9 100644
--- a/ndb/examples/ndbapi_example4/ndbapi_example4.cpp
+++ b/ndb/examples/ndbapi_example4/ndbapi_example4.cpp
@@ -44,6 +44,7 @@
int main()
{
+ ndb_init();
Ndb* myNdb = new Ndb( "TEST_DB_1" ); // Object representing the database
NdbDictionary::Table myTable;
NdbDictionary::Column myColumn;
@@ -79,16 +80,16 @@ int main()
myTable.setName("MYTABLENAME");
myColumn.setName("ATTR1");
- myColumn.setPrimaryKey(true);
myColumn.setType(NdbDictionary::Column::Unsigned);
myColumn.setLength(1);
+ myColumn.setPrimaryKey(true);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
myColumn.setName("ATTR2");
- myColumn.setPrimaryKey(false);
myColumn.setType(NdbDictionary::Column::Unsigned);
myColumn.setLength(1);
+ myColumn.setPrimaryKey(false);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
diff --git a/ndb/examples/ndbapi_example5/ndbapi_example5.cpp b/ndb/examples/ndbapi_example5/ndbapi_example5.cpp
index a9d3099883c..77f74e7bb63 100644
--- a/ndb/examples/ndbapi_example5/ndbapi_example5.cpp
+++ b/ndb/examples/ndbapi_example5/ndbapi_example5.cpp
@@ -65,6 +65,7 @@ int myCreateEvent(Ndb* myNdb,
int main()
{
+ ndb_init();
Ndb* myNdb = myCreateNdb();
NdbDictionary::Dictionary *myDict;
diff --git a/ndb/examples/ndbapi_scan_example/ndbapi_scan.cpp b/ndb/examples/ndbapi_scan_example/ndbapi_scan.cpp
index 7c3a66326c6..22641bc5b57 100644
--- a/ndb/examples/ndbapi_scan_example/ndbapi_scan.cpp
+++ b/ndb/examples/ndbapi_scan_example/ndbapi_scan.cpp
@@ -47,9 +47,9 @@
*
* NdbDictionary::Column
* setName()
- * setPrimaryKey()
* setType()
* setLength()
+ * setPrimaryKey()
* setNullable()
*
* NdbDictionary::Table
@@ -165,24 +165,24 @@ int create_table(Ndb * myNdb)
myTable.setName("GARAGE");
myColumn.setName("REG_NO");
- myColumn.setPrimaryKey(true);
myColumn.setType(NdbDictionary::Column::Unsigned);
myColumn.setLength(1);
+ myColumn.setPrimaryKey(true);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
myColumn.setName("BRAND");
- myColumn.setPrimaryKey(false);
myColumn.setType(NdbDictionary::Column::Char);
myColumn.setLength(20);
+ myColumn.setPrimaryKey(false);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
myColumn.setName("COLOR");
- myColumn.setPrimaryKey(false);
myColumn.setType(NdbDictionary::Column::Char);
myColumn.setLength(20);
+ myColumn.setPrimaryKey(false);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
@@ -761,6 +761,7 @@ int scan_print(Ndb * myNdb, int parallelism,
int main()
{
+ ndb_init();
Ndb* myNdb = new Ndb( "TEST_DB" ); // Object representing the database
@@ -813,4 +814,3 @@ int main()
delete myNdb;
}
-
diff --git a/ndb/examples/select_all/select_all.cpp b/ndb/examples/select_all/select_all.cpp
index 3cdbdc47e62..bd25fb60128 100644
--- a/ndb/examples/select_all/select_all.cpp
+++ b/ndb/examples/select_all/select_all.cpp
@@ -112,6 +112,7 @@ const char* ResultSetContainer::getAttrName(int i) const {return m_names[i];}
int main(int argc, const char** argv)
{
+ ndb_init();
Ndb* myNdb = new Ndb("ndbapi_example4"); // Object representing the database
NdbConnection* myNdbConnection; // For transactions
NdbOperation* myNdbOperation; // For operations
diff --git a/ndb/include/debugger/EventLogger.hpp b/ndb/include/debugger/EventLogger.hpp
index 6cd6a83e68d..36cece6f22a 100644
--- a/ndb/include/debugger/EventLogger.hpp
+++ b/ndb/include/debugger/EventLogger.hpp
@@ -24,6 +24,65 @@
#include <kernel/LogLevel.hpp>
#include <signaldata/EventReport.hpp>
+class EventLoggerBase {
+public:
+ virtual ~EventLoggerBase();
+
+ /**
+ * LogLevel settings
+ */
+ LogLevel m_logLevel;
+
+ /**
+ * Find a category matching the string
+ *
+ * @param str string to match.
+ * @param cat the event category.
+ * @param exactMatch only do exact matching.
+ *
+ * @return TRUE if match is found, then cat is modified
+ * FALSE if match is not found
+ */
+ static bool matchEventCategory(const char * str,
+ LogLevel::EventCategory * cat,
+ bool exactMatch = false);
+
+ /**
+ * Returns category name or NULL if not found.
+ *
+ * @param cat the event category.
+ * @return category name.
+ */
+ static const char * getEventCategoryName(LogLevel::EventCategory cat);
+
+ /**
+ * Specifies allowed event categories/log levels.
+ */
+ struct EventCategoryName {
+ LogLevel::EventCategory category;
+ const char * name;
+ };
+
+ static const EventCategoryName eventCategoryNames[];
+ static const Uint32 noOfEventCategoryNames;
+
+ /**
+ * This matrix defines which event should be printed when
+ *
+ * threshold - is in range [0-15]
+ * severity - DEBUG to ALERT (Type of log message)
+ */
+ struct EventRepLogLevelMatrix {
+ EventReport::EventType eventType;
+ LogLevel::EventCategory eventCategory;
+ Uint32 threshold;
+ Logger::LoggerLevel severity;
+ };
+
+ static const EventRepLogLevelMatrix matrix[];
+ static const Uint32 matrixSize;
+};
+
/**
* The EventLogger is primarily used for logging NDB events
* in the Management Server. It inherits all logging functionality of Logger.
@@ -58,7 +117,7 @@
* @see Logger
* @version #@ $Id: EventLogger.hpp,v 1.3 2003/09/01 10:15:52 innpeno Exp $
*/
-class EventLogger : public Logger
+class EventLogger : public EventLoggerBase, public Logger
{
public:
/**
@@ -70,7 +129,7 @@ public:
/**
* Destructor.
*/
- ~EventLogger();
+ virtual ~EventLogger();
/**
* Opens/creates the eventlog with the specified filename.
@@ -95,30 +154,23 @@ public:
/**
* Logs the NDB event.
*
- * @param nodeId the node id of event origin.
- * @param eventType the type of event.
- * @param theData the event data.
- * @deprecated use log(int eventType, const Uint32* theData, NodeId nodeId)
- */
- void log(NodeId nodeId, int eventType, const Uint32* theData);
-
- /**
- * Logs the NDB event.
- *
* @param eventType the type of event.
* @param theData the event data.
* @param nodeId the node id of event origin.
*/
- void log(int eventType, const Uint32* theData, NodeId nodeId = 0);
+ virtual void log(int eventType, const Uint32* theData, NodeId nodeId = 0);
/**
- * Returns the current log levels.
- * Enable, disable log levels to filter the events that are sent to the
- * eventlog.
+ * Returns the event text for the specified event report type.
*
- * @return the log level.
+ * @param type the event type.
+ * @param theData the event data.
+ * @param nodeId a node id.
+ * @return the event report text.
*/
- LogLevel& getLoglevel();
+ static const char* getText(char * dst, size_t dst_len,
+ int type,
+ const Uint32* theData, NodeId nodeId = 0);
/**
* Returns the log level that is used to filter an event. The event will not
@@ -127,6 +179,7 @@ public:
* @return the log level filter that is used for all event categories.
*/
int getFilterLevel() const;
+
/**
* Sets log level filter. The event will be logged if
* the event category's log level is <= 'filterLevel'.
@@ -135,92 +188,16 @@ public:
*/
void setFilterLevel(int filterLevel);
- /**
- * Returns the event text for the specified event report type.
- *
- * @param type the event type.
- * @param theData the event data.
- * @param nodeId a node id.
- * @return the event report text.
- */
- static const char* getText(int type,
- const Uint32* theData, NodeId nodeId = 0);
-
- /**
- * Find a category matching the string
- *
- * @param str string to match.
- * @param cat the event category.
- * @param exactMatch only do exact matching.
- *
- * @return TRUE if match is found, then cat is modified
- * FALSE if match is not found
- */
- static bool matchEventCategory(const char * str,
- LogLevel::EventCategory * cat,
- bool exactMatch = false);
-
- /**
- * Returns category name or NULL if not found.
- *
- * @param cat the event category.
- * @return category name.
- */
- static const char * getEventCategoryName(LogLevel::EventCategory cat);
-
- /**
- * Specifies allowed event categories/log levels.
- */
- struct EventCategoryName {
- LogLevel::EventCategory category;
- const char * name;
- };
-
- static const EventCategoryName eventCategoryNames[];
- static const Uint32 noOfEventCategoryNames;
-
- /**
- * This matrix defines which event should be printed when
- *
- * threshold - is in range [0-15]
- * severity - DEBUG to ALERT (Type of log message)
- */
- struct EventRepLogLevelMatrix {
- EventReport::EventType eventType;
- LogLevel::EventCategory eventCategory;
- Uint32 threshold;
- Logger::LoggerLevel severity;
- };
-
- static const EventRepLogLevelMatrix matrix[];
-
- /**
- * Default log levels for management nodes.
- *
- * threshold - is in range [0-15]
- */
- struct EventLogMatrix {
- LogLevel::EventCategory eventCategory;
- Uint32 threshold;
- };
-
- static const EventLogMatrix defEventLogMatrix[];
-
-
- static const Uint32 matrixSize;
- static const Uint32 defEventLogMatrixSize;
-
private:
/** Prohibit */
EventLogger(const EventLogger&);
EventLogger operator = (const EventLogger&);
bool operator == (const EventLogger&);
- LogLevel m_logLevel;
Uint32 m_filterLevel;
STATIC_CONST(MAX_TEXT_LENGTH = 256);
- static char m_text[MAX_TEXT_LENGTH];
+ char m_text[MAX_TEXT_LENGTH];
};
diff --git a/ndb/include/kernel/LogLevel.hpp b/ndb/include/kernel/LogLevel.hpp
index 10cd0d43bee..e3a81263dcb 100644
--- a/ndb/include/kernel/LogLevel.hpp
+++ b/ndb/include/kernel/LogLevel.hpp
@@ -130,18 +130,25 @@ public:
*/
Uint32 getLogLevel(EventCategory ec) const;
+ /**
+ * Set this= max(this, ll) per category
+ */
+ LogLevel& set_max(const LogLevel& ll);
+
+ bool operator==(const LogLevel& l) const {
+ return memcmp(this, &l, sizeof(* this)) == 0;
+ }
+
private:
/**
* The actual data
*/
- Uint32 logLevelData[LOGLEVEL_CATEGORIES];
-
- LogLevel(const LogLevel &);
+ Uint8 logLevelData[LOGLEVEL_CATEGORIES];
};
inline
LogLevel::LogLevel(){
- clear();
+ clear();
}
inline
@@ -176,5 +183,14 @@ LogLevel::getLogLevel(EventCategory ec) const{
return logLevelData[ec];
}
+inline
+LogLevel &
+LogLevel::set_max(const LogLevel & org){
+ for(Uint32 i = 0; i<LOGLEVEL_CATEGORIES; i++){
+ if(logLevelData[i] < org.logLevelData[i])
+ logLevelData[i] = org.logLevelData[i];
+ }
+ return * this;
+}
#endif
diff --git a/ndb/include/kernel/signaldata/DictTabInfo.hpp b/ndb/include/kernel/signaldata/DictTabInfo.hpp
index dec7145c897..a9a50f19fbc 100644
--- a/ndb/include/kernel/signaldata/DictTabInfo.hpp
+++ b/ndb/include/kernel/signaldata/DictTabInfo.hpp
@@ -438,8 +438,8 @@ public:
case DictTabInfo::ExtText:
AttributeType = DictTabInfo::StringType;
AttributeSize = DictTabInfo::an8Bit;
- // head + inline part [ attr precision ]
- AttributeArraySize = (NDB_BLOB_HEAD_SIZE << 2) + AttributeExtPrecision;
+ // head + inline part [ attr precision lower half ]
+ AttributeArraySize = (NDB_BLOB_HEAD_SIZE << 2) + (AttributeExtPrecision & 0xFFFF);
return true;
};
return false;
diff --git a/ndb/include/kernel/signaldata/EventSubscribeReq.hpp b/ndb/include/kernel/signaldata/EventSubscribeReq.hpp
index fd2821ea31d..522f8d9b8d3 100644
--- a/ndb/include/kernel/signaldata/EventSubscribeReq.hpp
+++ b/ndb/include/kernel/signaldata/EventSubscribeReq.hpp
@@ -27,7 +27,7 @@
* RECIVER: SimBlockCMCtrBlck
*/
-class EventSubscribeReq {
+struct EventSubscribeReq {
/**
* Receiver(s)
*/
@@ -38,9 +38,8 @@ class EventSubscribeReq {
*/
friend class MgmtSrvr;
-public:
STATIC_CONST( SignalLength = 22 );
-private:
+
/**
* Note: If you use the same blockRef as you have used earlier,
* you update your ongoing subscription
@@ -55,6 +54,15 @@ private:
Uint32 theCategories[10];
Uint32 theLevels[10];
+
+ EventSubscribeReq& operator= (const LogLevel& ll){
+ noOfEntries = _LOGLEVEL_CATEGORIES;
+ for(size_t i = 0; i<noOfEntries; i++){
+ theCategories[i] = i;
+ theLevels[i] = ll.getLogLevel((LogLevel::EventCategory)i);
+ }
+ return * this;
+ }
};
#endif
diff --git a/ndb/include/kernel/signaldata/SetLogLevelOrd.hpp b/ndb/include/kernel/signaldata/SetLogLevelOrd.hpp
index c3be808cc41..8e1a8add966 100644
--- a/ndb/include/kernel/signaldata/SetLogLevelOrd.hpp
+++ b/ndb/include/kernel/signaldata/SetLogLevelOrd.hpp
@@ -18,6 +18,7 @@
#define SET_LOGLEVEL_ORD_HPP
#include <LogLevel.hpp>
+#include "EventSubscribeReq.hpp"
#include "SignalData.hpp"
/**
@@ -51,6 +52,24 @@ private:
* Note level is valid as 0-15
*/
void setLogLevel(LogLevel::EventCategory ec, int level = 7);
+
+ SetLogLevelOrd& operator= (const LogLevel& ll){
+ noOfEntries = _LOGLEVEL_CATEGORIES;
+ for(size_t i = 0; i<noOfEntries; i++){
+ theCategories[i] = i;
+ theLevels[i] = ll.getLogLevel((LogLevel::EventCategory)i);
+ }
+ return * this;
+ }
+
+ SetLogLevelOrd& operator= (const EventSubscribeReq& ll){
+ noOfEntries = ll.noOfEntries;
+ for(size_t i = 0; i<noOfEntries; i++){
+ theCategories[i] = ll.theCategories[i];
+ theLevels[i] = ll.theLevels[i];
+ }
+ return * this;
+ }
};
inline
diff --git a/ndb/include/mgmapi/mgmapi.h b/ndb/include/mgmapi/mgmapi.h
index 929f4b0833b..9caf1c86c4d 100644
--- a/ndb/include/mgmapi/mgmapi.h
+++ b/ndb/include/mgmapi/mgmapi.h
@@ -56,24 +56,6 @@ extern "C" {
#endif
/**
- * Format of statistical information from the NDB Cluster.
- * STATISTIC_LINE is sent on the statistical port from the Management server,
- * each line is timestamped with STATISTIC_DATE.
- */
-#define STATISTIC_LINE "date=%s epochsecs=%d nodeid=%u trans=%u commit=%u " \
- "read=%u insert=%u attrinfo=%u cops=%u abort=%u"
- /**
- * Format of statistical information from the NDB Cluster.
- * STATISTIC_LINE is sent on the statistical port from the Management server,
- * each line is timestamped with STATISTIC_DATE.
- */
-#define STATISTIC_DATE "%d-%.2d-%.2d/%.2d:%.2d:%.2d"
- /**
- * Format of statistical information from the NDB Cluster.
- */
-#define OP_STATISTIC_LINE "date=%s epochsecs=%d nodeid=%d operations=%u"
-
- /**
* The NdbMgmHandle.
*/
typedef struct ndb_mgm_handle * NdbMgmHandle;
diff --git a/ndb/include/mgmapi/mgmapi_config_parameters.h b/ndb/include/mgmapi/mgmapi_config_parameters.h
index 4a4863298dd..6b157720f2b 100644
--- a/ndb/include/mgmapi/mgmapi_config_parameters.h
+++ b/ndb/include/mgmapi/mgmapi_config_parameters.h
@@ -104,9 +104,9 @@
#define CFG_CONNECTION_NODE_1_SYSTEM 404
#define CFG_CONNECTION_NODE_2_SYSTEM 405
#define CFG_CONNECTION_SERVER_PORT 406
+#define CFG_CONNECTION_HOSTNAME_1 407
+#define CFG_CONNECTION_HOSTNAME_2 408
-#define CFG_TCP_HOSTNAME_1 450
-#define CFG_TCP_HOSTNAME_2 451
#define CFG_TCP_SERVER 452
#define CFG_TCP_SEND_BUFFER_SIZE 454
#define CFG_TCP_RECEIVE_BUFFER_SIZE 455
@@ -128,8 +128,6 @@
#define CFG_SCI_NODE2_ADAPTER0 555
#define CFG_SCI_NODE2_ADAPTER1 556
-#define CFG_OSE_HOSTNAME_1 600
-#define CFG_OSE_HOSTNAME_2 601
#define CFG_OSE_PRIO_A_SIZE 602
#define CFG_OSE_PRIO_B_SIZE 603
#define CFG_OSE_RECEIVE_ARRAY_SIZE 604
diff --git a/ndb/include/ndb_global.h b/ndb/include/ndb_global.h
index 0ae781ba5c2..19bd387c457 100644
--- a/ndb/include/ndb_global.h
+++ b/ndb/include/ndb_global.h
@@ -76,6 +76,9 @@ extern "C" {
#include <assert.h>
+/* call in main() - does not return on error */
+extern int ndb_init(void);
+
#ifndef HAVE_STRDUP
extern char * strdup(const char *s);
#endif
diff --git a/ndb/include/ndbapi/NdbDictionary.hpp b/ndb/include/ndbapi/NdbDictionary.hpp
index 5c470c1d25f..51a6895648f 100644
--- a/ndb/include/ndbapi/NdbDictionary.hpp
+++ b/ndb/include/ndbapi/NdbDictionary.hpp
@@ -32,6 +32,8 @@
#include <ndb_types.h>
class Ndb;
+struct charset_info_st;
+typedef struct charset_info_st CHARSET_INFO;
/**
* @class NdbDictionary
@@ -257,6 +259,10 @@ public:
/**
* Set type of column
* @param type Type of column
+ *
+ * @note setType resets <em>all</em> column attributes
+ * to (type dependent) defaults and should be the first
+ * method to call. Default type is Unsigned.
*/
void setType(Type type);
@@ -302,27 +308,35 @@ public:
int getLength() const;
/**
+ * For Char or Varchar or Text, set or get MySQL CHARSET_INFO. This
+ * specifies both character set and collation. See get_charset()
+ * etc in MySQL. (The cs is not "const" in MySQL).
+ */
+ void setCharset(CHARSET_INFO* cs);
+ CHARSET_INFO* getCharset() const;
+
+ /**
* For blob, set or get "inline size" i.e. number of initial bytes
* to store in table's blob attribute. This part is normally in
* main memory and can be indexed and interpreted.
*/
- void setInlineSize(int size) { setPrecision(size); }
- int getInlineSize() const { return getPrecision(); }
+ void setInlineSize(int size);
+ int getInlineSize() const;
/**
* For blob, set or get "part size" i.e. number of bytes to store in
* each tuple of the "blob table". Can be set to zero to omit parts
* and to allow only inline bytes ("tinyblob").
*/
- void setPartSize(int size) { setScale(size); }
- int getPartSize() const { return getScale(); }
+ void setPartSize(int size);
+ int getPartSize() const;
/**
* For blob, set or get "stripe size" i.e. number of consecutive
* <em>parts</em> to store in each node group.
*/
- void setStripeSize(int size) { setLength(size); }
- int getStripeSize() const { return getLength(); }
+ void setStripeSize(int size);
+ int getStripeSize() const;
/**
* Get size of element
diff --git a/ndb/include/transporter/TransporterRegistry.hpp b/ndb/include/transporter/TransporterRegistry.hpp
index 3c6c307406c..ac6291f9e57 100644
--- a/ndb/include/transporter/TransporterRegistry.hpp
+++ b/ndb/include/transporter/TransporterRegistry.hpp
@@ -218,15 +218,18 @@ public:
void printState();
#endif
- unsigned short m_service_port;
-
+ class Transporter_interface {
+ public:
+ unsigned short m_service_port;
+ const char *m_interface;
+ };
+ Vector<Transporter_interface> m_transporter_interface;
+ void add_transporter_interface(const char *interface, unsigned short port);
protected:
private:
void * callbackObj;
- TransporterService *m_transporter_service;
- char *m_interface_name;
struct NdbThread *m_start_clients_thread;
bool m_run_start_clients_thread;
diff --git a/ndb/include/util/NdbSqlUtil.hpp b/ndb/include/util/NdbSqlUtil.hpp
index 1d3e96d5c7e..df1cb716f93 100644
--- a/ndb/include/util/NdbSqlUtil.hpp
+++ b/ndb/include/util/NdbSqlUtil.hpp
@@ -90,6 +90,13 @@ public:
*/
static const Type& getType(Uint32 typeId);
+ /**
+ * Check character set.
+ */
+ static bool usable_in_pk(Uint32 typeId, const void* cs);
+ static bool usable_in_hash_index(Uint32 typeId, const void* cs);
+ static bool usable_in_ordered_index(Uint32 typeId, const void* cs);
+
private:
/**
* List of all types. Must match Type::Enum.
diff --git a/ndb/src/common/debugger/EventLogger.cpp b/ndb/src/common/debugger/EventLogger.cpp
index 69874ab7ecc..2e818c04e02 100644
--- a/ndb/src/common/debugger/EventLogger.cpp
+++ b/ndb/src/common/debugger/EventLogger.cpp
@@ -28,6 +28,10 @@
//
// PUBLIC
//
+EventLoggerBase::~EventLoggerBase()
+{
+
+}
/**
* This matrix defines which event should be printed when
@@ -35,105 +39,86 @@
* threshold - is in range [0-15]
* severity - DEBUG to ALERT (Type of log message)
*/
-const EventLogger::EventRepLogLevelMatrix EventLogger::matrix[] = {
+const EventLoggerBase::EventRepLogLevelMatrix EventLoggerBase::matrix[] = {
// CONNECTION
- { EventReport::Connected, LogLevel::llConnection, 8, LL_INFO },
- { EventReport::Disconnected, LogLevel::llConnection, 8, LL_ALERT },
- { EventReport::CommunicationClosed, LogLevel::llConnection, 8, LL_INFO },
- { EventReport::CommunicationOpened, LogLevel::llConnection, 8, LL_INFO },
- { EventReport::ConnectedApiVersion, LogLevel::llConnection, 8, LL_INFO },
+ { EventReport::Connected, LogLevel::llConnection, 8, Logger::LL_INFO },
+ { EventReport::Disconnected, LogLevel::llConnection, 8, Logger::LL_ALERT },
+ { EventReport::CommunicationClosed, LogLevel::llConnection, 8, Logger::LL_INFO },
+ { EventReport::CommunicationOpened, LogLevel::llConnection, 8, Logger::LL_INFO },
+ { EventReport::ConnectedApiVersion, LogLevel::llConnection, 8, Logger::LL_INFO },
// CHECKPOINT
- { EventReport::GlobalCheckpointStarted, LogLevel::llCheckpoint, 9, LL_INFO },
- { EventReport::GlobalCheckpointCompleted,LogLevel::llCheckpoint,10, LL_INFO },
- { EventReport::LocalCheckpointStarted, LogLevel::llCheckpoint, 7, LL_INFO },
- { EventReport::LocalCheckpointCompleted,LogLevel::llCheckpoint, 8, LL_INFO },
- { EventReport::LCPStoppedInCalcKeepGci, LogLevel::llCheckpoint, 0, LL_ALERT },
- { EventReport::LCPFragmentCompleted, LogLevel::llCheckpoint, 11, LL_INFO },
- { EventReport::UndoLogBlocked, LogLevel::llCheckpoint, 7, LL_INFO },
+ { EventReport::GlobalCheckpointStarted, LogLevel::llCheckpoint, 9, Logger::LL_INFO },
+ { EventReport::GlobalCheckpointCompleted,LogLevel::llCheckpoint,10, Logger::LL_INFO },
+ { EventReport::LocalCheckpointStarted, LogLevel::llCheckpoint, 7, Logger::LL_INFO },
+ { EventReport::LocalCheckpointCompleted,LogLevel::llCheckpoint, 8, Logger::LL_INFO },
+ { EventReport::LCPStoppedInCalcKeepGci, LogLevel::llCheckpoint, 0, Logger::LL_ALERT },
+ { EventReport::LCPFragmentCompleted, LogLevel::llCheckpoint, 11, Logger::LL_INFO },
+ { EventReport::UndoLogBlocked, LogLevel::llCheckpoint, 7, Logger::LL_INFO },
// STARTUP
- { EventReport::NDBStartStarted, LogLevel::llStartUp, 1, LL_INFO },
- { EventReport::NDBStartCompleted, LogLevel::llStartUp, 1, LL_INFO },
- { EventReport::STTORRYRecieved, LogLevel::llStartUp,15, LL_INFO },
- { EventReport::StartPhaseCompleted, LogLevel::llStartUp, 4, LL_INFO },
- { EventReport::CM_REGCONF, LogLevel::llStartUp, 3, LL_INFO },
- { EventReport::CM_REGREF, LogLevel::llStartUp, 8, LL_INFO },
- { EventReport::FIND_NEIGHBOURS, LogLevel::llStartUp, 8, LL_INFO },
- { EventReport::NDBStopStarted, LogLevel::llStartUp, 1, LL_INFO },
- { EventReport::NDBStopAborted, LogLevel::llStartUp, 1, LL_INFO },
- { EventReport::StartREDOLog, LogLevel::llStartUp, 10, LL_INFO },
- { EventReport::StartLog, LogLevel::llStartUp, 10, LL_INFO },
- { EventReport::UNDORecordsExecuted, LogLevel::llStartUp, 15, LL_INFO },
+ { EventReport::NDBStartStarted, LogLevel::llStartUp, 1, Logger::LL_INFO },
+ { EventReport::NDBStartCompleted, LogLevel::llStartUp, 1, Logger::LL_INFO },
+ { EventReport::STTORRYRecieved, LogLevel::llStartUp,15, Logger::LL_INFO },
+ { EventReport::StartPhaseCompleted, LogLevel::llStartUp, 4, Logger::LL_INFO },
+ { EventReport::CM_REGCONF, LogLevel::llStartUp, 3, Logger::LL_INFO },
+ { EventReport::CM_REGREF, LogLevel::llStartUp, 8, Logger::LL_INFO },
+ { EventReport::FIND_NEIGHBOURS, LogLevel::llStartUp, 8, Logger::LL_INFO },
+ { EventReport::NDBStopStarted, LogLevel::llStartUp, 1, Logger::LL_INFO },
+ { EventReport::NDBStopAborted, LogLevel::llStartUp, 1, Logger::LL_INFO },
+ { EventReport::StartREDOLog, LogLevel::llStartUp, 10, Logger::LL_INFO },
+ { EventReport::StartLog, LogLevel::llStartUp, 10, Logger::LL_INFO },
+ { EventReport::UNDORecordsExecuted, LogLevel::llStartUp, 15, Logger::LL_INFO },
// NODERESTART
- { EventReport::NR_CopyDict, LogLevel::llNodeRestart, 8, LL_INFO },
- { EventReport::NR_CopyDistr, LogLevel::llNodeRestart, 8, LL_INFO },
- { EventReport::NR_CopyFragsStarted, LogLevel::llNodeRestart, 8, LL_INFO },
- { EventReport::NR_CopyFragDone, LogLevel::llNodeRestart, 10, LL_INFO },
- { EventReport::NR_CopyFragsCompleted, LogLevel::llNodeRestart, 8, LL_INFO },
+ { EventReport::NR_CopyDict, LogLevel::llNodeRestart, 8, Logger::LL_INFO },
+ { EventReport::NR_CopyDistr, LogLevel::llNodeRestart, 8, Logger::LL_INFO },
+ { EventReport::NR_CopyFragsStarted, LogLevel::llNodeRestart, 8, Logger::LL_INFO },
+ { EventReport::NR_CopyFragDone, LogLevel::llNodeRestart, 10, Logger::LL_INFO },
+ { EventReport::NR_CopyFragsCompleted, LogLevel::llNodeRestart, 8, Logger::LL_INFO },
- { EventReport::NodeFailCompleted, LogLevel::llNodeRestart, 8, LL_ALERT},
- { EventReport::NODE_FAILREP, LogLevel::llNodeRestart, 8, LL_ALERT},
- { EventReport::ArbitState, LogLevel::llNodeRestart, 6, LL_INFO },
- { EventReport::ArbitResult, LogLevel::llNodeRestart, 2, LL_ALERT},
- { EventReport::GCP_TakeoverStarted, LogLevel::llNodeRestart, 7, LL_INFO },
- { EventReport::GCP_TakeoverCompleted, LogLevel::llNodeRestart, 7, LL_INFO },
- { EventReport::LCP_TakeoverStarted, LogLevel::llNodeRestart, 7, LL_INFO },
- { EventReport::LCP_TakeoverCompleted, LogLevel::llNodeRestart, 7, LL_INFO },
+ { EventReport::NodeFailCompleted, LogLevel::llNodeRestart, 8, Logger::LL_ALERT},
+ { EventReport::NODE_FAILREP, LogLevel::llNodeRestart, 8, Logger::LL_ALERT},
+ { EventReport::ArbitState, LogLevel::llNodeRestart, 6, Logger::LL_INFO },
+ { EventReport::ArbitResult, LogLevel::llNodeRestart, 2, Logger::LL_ALERT},
+ { EventReport::GCP_TakeoverStarted, LogLevel::llNodeRestart, 7, Logger::LL_INFO },
+ { EventReport::GCP_TakeoverCompleted, LogLevel::llNodeRestart, 7, Logger::LL_INFO },
+ { EventReport::LCP_TakeoverStarted, LogLevel::llNodeRestart, 7, Logger::LL_INFO },
+ { EventReport::LCP_TakeoverCompleted, LogLevel::llNodeRestart, 7, Logger::LL_INFO },
// STATISTIC
- { EventReport::TransReportCounters, LogLevel::llStatistic, 8, LL_INFO },
- { EventReport::OperationReportCounters, LogLevel::llStatistic, 8, LL_INFO },
- { EventReport::TableCreated, LogLevel::llStatistic, 7, LL_INFO },
- { EventReport::JobStatistic, LogLevel::llStatistic, 9, LL_INFO },
- { EventReport::SendBytesStatistic, LogLevel::llStatistic, 9, LL_INFO },
- { EventReport::ReceiveBytesStatistic, LogLevel::llStatistic, 9, LL_INFO },
- { EventReport::MemoryUsage, LogLevel::llStatistic, 5, LL_INFO },
+ { EventReport::TransReportCounters, LogLevel::llStatistic, 8, Logger::LL_INFO },
+ { EventReport::OperationReportCounters, LogLevel::llStatistic, 8, Logger::LL_INFO },
+ { EventReport::TableCreated, LogLevel::llStatistic, 7, Logger::LL_INFO },
+ { EventReport::JobStatistic, LogLevel::llStatistic, 9, Logger::LL_INFO },
+ { EventReport::SendBytesStatistic, LogLevel::llStatistic, 9, Logger::LL_INFO },
+ { EventReport::ReceiveBytesStatistic, LogLevel::llStatistic, 9, Logger::LL_INFO },
+ { EventReport::MemoryUsage, LogLevel::llStatistic, 5, Logger::LL_INFO },
// ERROR
- { EventReport::TransporterError, LogLevel::llError, 2, LL_ERROR },
- { EventReport::TransporterWarning, LogLevel::llError, 8, LL_WARNING },
- { EventReport::MissedHeartbeat, LogLevel::llError, 8, LL_WARNING },
- { EventReport::DeadDueToHeartbeat, LogLevel::llError, 8, LL_ALERT },
- { EventReport::WarningEvent, LogLevel::llError, 2, LL_WARNING },
+ { EventReport::TransporterError, LogLevel::llError, 2, Logger::LL_ERROR },
+ { EventReport::TransporterWarning, LogLevel::llError, 8, Logger::LL_WARNING },
+ { EventReport::MissedHeartbeat, LogLevel::llError, 8, Logger::LL_WARNING },
+ { EventReport::DeadDueToHeartbeat, LogLevel::llError, 8, Logger::LL_ALERT },
+ { EventReport::WarningEvent, LogLevel::llError, 2, Logger::LL_WARNING },
// INFO
- { EventReport::SentHeartbeat, LogLevel::llInfo, 12, LL_INFO },
- { EventReport::CreateLogBytes, LogLevel::llInfo, 11, LL_INFO },
- { EventReport::InfoEvent, LogLevel::llInfo, 2, LL_INFO },
+ { EventReport::SentHeartbeat, LogLevel::llInfo, 12, Logger::LL_INFO },
+ { EventReport::CreateLogBytes, LogLevel::llInfo, 11, Logger::LL_INFO },
+ { EventReport::InfoEvent, LogLevel::llInfo, 2, Logger::LL_INFO },
//Global replication
- { EventReport::GrepSubscriptionInfo, LogLevel::llGrep, 7, LL_INFO},
- { EventReport::GrepSubscriptionAlert, LogLevel::llGrep, 7, LL_ALERT}
+ { EventReport::GrepSubscriptionInfo, LogLevel::llGrep, 7, Logger::LL_INFO},
+ { EventReport::GrepSubscriptionAlert, LogLevel::llGrep, 7, Logger::LL_ALERT}
};
-const Uint32 EventLogger::matrixSize = sizeof(EventLogger::matrix)/
+const Uint32 EventLoggerBase::matrixSize = sizeof(EventLoggerBase::matrix)/
sizeof(EventRepLogLevelMatrix);
/**
- * Default log levels for management nodes.
- *
- * threshold - is in range [0-15]
- */
-const EventLogger::EventLogMatrix EventLogger::defEventLogMatrix[] = {
- { LogLevel::llStartUp, 7 },
- { LogLevel::llShutdown, 7 },
- { LogLevel::llStatistic, 7 },
- { LogLevel::llCheckpoint, 7 },
- { LogLevel::llNodeRestart, 7 },
- { LogLevel::llConnection, 7 },
- { LogLevel::llError, 15 },
- { LogLevel::llInfo, 7 },
- { LogLevel::llGrep, 7 }
-};
-
-const Uint32
-EventLogger::defEventLogMatrixSize = sizeof(EventLogger::defEventLogMatrix)/
- sizeof(EventLogMatrix);
-/**
* Specifies allowed event categories/log levels that can be set from
* the Management API/interactive shell.
*/
-const EventLogger::EventCategoryName EventLogger::eventCategoryNames[] = {
+const EventLoggerBase::EventCategoryName
+EventLoggerBase::eventCategoryNames[] = {
{ LogLevel::llStartUp, "STARTUP" },
{ LogLevel::llStatistic, "STATISTICS" },
{ LogLevel::llCheckpoint, "CHECKPOINT" },
@@ -144,13 +129,13 @@ const EventLogger::EventCategoryName EventLogger::eventCategoryNames[] = {
};
const Uint32
-EventLogger::noOfEventCategoryNames = sizeof(EventLogger::eventCategoryNames)/
- sizeof(EventLogger::EventCategoryName);
-
-char EventLogger::m_text[MAX_TEXT_LENGTH];
+EventLoggerBase::noOfEventCategoryNames =
+ sizeof(EventLoggerBase::eventCategoryNames)/
+ sizeof(EventLoggerBase::EventCategoryName);
const char*
-EventLogger::getText(int type,
+EventLogger::getText(char * m_text, size_t m_text_len,
+ int type,
const Uint32* theData, NodeId nodeId)
{
// TODO: Change the switch implementation...
@@ -164,13 +149,13 @@ EventLogger::getText(int type,
EventReport::EventType eventType = (EventReport::EventType)type;
switch (eventType){
case EventReport::Connected:
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sNode %u Connected",
theNodeId,
theData[1]);
break;
case EventReport::ConnectedApiVersion:
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sNode %u: API version %d.%d.%d",
theNodeId,
theData[1],
@@ -179,7 +164,7 @@ EventLogger::getText(int type,
getBuild(theData[2]));
break;
case EventReport::Disconnected:
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sNode %u Disconnected",
theNodeId,
theData[1]);
@@ -188,7 +173,7 @@ EventLogger::getText(int type,
//-----------------------------------------------------------------------
// REPORT communication to node closed.
//-----------------------------------------------------------------------
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sCommunication to Node %u closed",
theNodeId,
theData[1]);
@@ -197,7 +182,7 @@ EventLogger::getText(int type,
//-----------------------------------------------------------------------
// REPORT communication to node opened.
//-----------------------------------------------------------------------
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sCommunication to Node %u opened",
theNodeId,
theData[1]);
@@ -206,7 +191,7 @@ EventLogger::getText(int type,
//-----------------------------------------------------------------------
// Start of NDB has been initiated.
//-----------------------------------------------------------------------
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sStart initiated (version %d.%d.%d)",
theNodeId ,
getMajor(theData[1]),
@@ -214,13 +199,13 @@ EventLogger::getText(int type,
getBuild(theData[1]));
break;
case EventReport::NDBStopStarted:
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%s%s shutdown initiated",
theNodeId,
(theData[1] == 1 ? "Cluster" : "Node"));
break;
case EventReport::NDBStopAborted:
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sNode shutdown aborted",
theNodeId);
break;
@@ -228,7 +213,7 @@ EventLogger::getText(int type,
//-----------------------------------------------------------------------
// Start of NDB has been completed.
//-----------------------------------------------------------------------
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sStarted (version %d.%d.%d)",
theNodeId ,
getMajor(theData[1]),
@@ -240,7 +225,7 @@ EventLogger::getText(int type,
//-----------------------------------------------------------------------
// STTORRY recevied after restart finished.
//-----------------------------------------------------------------------
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sSTTORRY received after restart finished",
theNodeId);
break;
@@ -266,7 +251,7 @@ EventLogger::getText(int type,
type = "";
break;
default:{
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sStart phase %u completed (unknown = %d)",
theNodeId,
theData[1],
@@ -274,7 +259,7 @@ EventLogger::getText(int type,
return m_text;
}
}
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sStart phase %u completed %s",
theNodeId,
theData[1],
@@ -283,7 +268,7 @@ EventLogger::getText(int type,
break;
}
case EventReport::CM_REGCONF:
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sCM_REGCONF president = %u, own Node = %u, our dynamic id = %u"
,
theNodeId,
@@ -315,7 +300,7 @@ EventLogger::getText(int type,
break;
}//switch
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sCM_REGREF from Node %u to our Node %u. Cause = %s",
theNodeId,
theData[2],
@@ -328,7 +313,7 @@ EventLogger::getText(int type,
// REPORT Node Restart copied a fragment.
//-----------------------------------------------------------------------
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sWe are Node %u with dynamic ID %u, our left neighbour "
"is Node %u, our right is Node %u",
theNodeId,
@@ -344,13 +329,13 @@ EventLogger::getText(int type,
if (theData[1] == 0)
{
if (theData[3] != 0) {
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sNode %u completed failure of Node %u",
theNodeId,
theData[3],
theData[2]);
} else {
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sAll nodes completed failure of Node %u",
theNodeId,
theData[2]);
@@ -367,7 +352,7 @@ EventLogger::getText(int type,
line = "DBLQH";
}
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sNode failure of %u %s completed",
theNodeId,
theData[2],
@@ -376,7 +361,7 @@ EventLogger::getText(int type,
break;
case EventReport::NODE_FAILREP:
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sNode %u has failed. The Node state at failure "
"was %u",
theNodeId,
@@ -395,41 +380,41 @@ EventLogger::getText(int type,
const unsigned state = sd->code >> 16;
switch (code) {
case ArbitCode::ThreadStart:
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sPresident restarts arbitration thread [state=%u]",
theNodeId, state);
break;
case ArbitCode::PrepPart2:
sd->ticket.getText(ticketText, sizeof(ticketText));
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sPrepare arbitrator node %u [ticket=%s]",
theNodeId, sd->node, ticketText);
break;
case ArbitCode::PrepAtrun:
sd->ticket.getText(ticketText, sizeof(ticketText));
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sReceive arbitrator node %u [ticket=%s]",
theNodeId, sd->node, ticketText);
break;
case ArbitCode::ApiStart:
sd->ticket.getText(ticketText, sizeof(ticketText));
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sStarted arbitrator node %u [ticket=%s]",
theNodeId, sd->node, ticketText);
break;
case ArbitCode::ApiFail:
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sLost arbitrator node %u - process failure [state=%u]",
theNodeId, sd->node, state);
break;
case ArbitCode::ApiExit:
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sLost arbitrator node %u - process exit [state=%u]",
theNodeId, sd->node, state);
break;
default:
ArbitCode::getErrText(code, errText, sizeof(errText));
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sLost arbitrator node %u - %s [state=%u]",
theNodeId, sd->node, errText, state);
break;
@@ -446,48 +431,48 @@ EventLogger::getText(int type,
const unsigned state = sd->code >> 16;
switch (code) {
case ArbitCode::LoseNodes:
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sArbitration check lost - less than 1/2 nodes left",
theNodeId);
break;
case ArbitCode::WinGroups:
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sArbitration check won - node group majority",
theNodeId);
break;
case ArbitCode::LoseGroups:
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sArbitration check lost - missing node group",
theNodeId);
break;
case ArbitCode::Partitioning:
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sNetwork partitioning - arbitration required",
theNodeId);
break;
case ArbitCode::WinChoose:
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sArbitration won - positive reply from node %u",
theNodeId, sd->node);
break;
case ArbitCode::LoseChoose:
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sArbitration lost - negative reply from node %u",
theNodeId, sd->node);
break;
case ArbitCode::LoseNorun:
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sNetwork partitioning - no arbitrator available",
theNodeId);
break;
case ArbitCode::LoseNocfg:
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sNetwork partitioning - no arbitrator configured",
theNodeId);
break;
default:
ArbitCode::getErrText(code, errText, sizeof(errText));
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sArbitration failure - %s [state=%u]",
theNodeId, errText, state);
break;
@@ -500,7 +485,7 @@ EventLogger::getText(int type,
// node is the master of this global checkpoint.
//-----------------------------------------------------------------------
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sGlobal checkpoint %u started",
theNodeId,
theData[1]);
@@ -510,7 +495,7 @@ EventLogger::getText(int type,
// This event reports that a global checkpoint has been completed on this
// node and the node is the master of this global checkpoint.
//-----------------------------------------------------------------------
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sGlobal checkpoint %u completed",
theNodeId,
theData[1]);
@@ -521,7 +506,7 @@ EventLogger::getText(int type,
// node is the master of this local checkpoint.
//-----------------------------------------------------------------------
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sLocal checkpoint %u started. "
"Keep GCI = %u oldest restorable GCI = %u",
theNodeId,
@@ -535,7 +520,7 @@ EventLogger::getText(int type,
// node and the node is the master of this local checkpoint.
//-----------------------------------------------------------------------
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sLocal checkpoint %u completed",
theNodeId,
theData[1]);
@@ -544,14 +529,14 @@ EventLogger::getText(int type,
//-----------------------------------------------------------------------
// This event reports that a table has been created.
//-----------------------------------------------------------------------
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sTable with ID = %u created",
theNodeId,
theData[1]);
break;
case EventReport::LCPStoppedInCalcKeepGci:
if (theData[1] == 0)
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sLocal Checkpoint stopped in CALCULATED_KEEP_GCI",
theNodeId);
break;
@@ -560,7 +545,7 @@ EventLogger::getText(int type,
// REPORT Node Restart completed copy of dictionary information.
//-----------------------------------------------------------------------
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sNode restart completed copy of dictionary information",
theNodeId);
break;
@@ -569,7 +554,7 @@ EventLogger::getText(int type,
// REPORT Node Restart completed copy of distribution information.
//-----------------------------------------------------------------------
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sNode restart completed copy of distribution information",
theNodeId);
break;
@@ -578,7 +563,7 @@ EventLogger::getText(int type,
// REPORT Node Restart is starting to copy the fragments.
//-----------------------------------------------------------------------
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sNode restart starting to copy the fragments "
"to Node %u",
theNodeId,
@@ -589,7 +574,7 @@ EventLogger::getText(int type,
// REPORT Node Restart copied a fragment.
//-----------------------------------------------------------------------
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sTable ID = %u, fragment ID = %u have been copied "
"to Node %u",
theNodeId,
@@ -599,7 +584,7 @@ EventLogger::getText(int type,
break;
case EventReport::NR_CopyFragsCompleted:
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sNode restart completed copying the fragments "
"to Node %u",
theNodeId,
@@ -607,7 +592,7 @@ EventLogger::getText(int type,
break;
case EventReport::LCPFragmentCompleted:
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sTable ID = %u, fragment ID = %u has completed LCP "
"on Node %u",
theNodeId,
@@ -620,7 +605,7 @@ EventLogger::getText(int type,
// Report information about transaction activity once per 10 seconds.
// -------------------------------------------------------------------
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sTrans. Count = %u, Commit Count = %u, "
"Read Count = %u, Simple Read Count = %u,\n"
"Write Count = %u, AttrInfo Count = %u, "
@@ -639,7 +624,7 @@ EventLogger::getText(int type,
theData[10]);
break;
case EventReport::OperationReportCounters:
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%sOperations=%u",
theNodeId,
theData[1]);
@@ -649,7 +634,7 @@ EventLogger::getText(int type,
// REPORT Undo Logging blocked due to buffer near to overflow.
//-----------------------------------------------------------------------
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sACC Blocked %u and TUP Blocked %u times last second",
theNodeId,
theData[1],
@@ -658,7 +643,7 @@ EventLogger::getText(int type,
case EventReport::TransporterError:
case EventReport::TransporterWarning:
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sTransporter to node %d reported error 0x%x",
theNodeId,
theData[1],
@@ -669,7 +654,7 @@ EventLogger::getText(int type,
// REPORT Undo Logging blocked due to buffer near to overflow.
//-----------------------------------------------------------------------
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sNode %d missed heartbeat %d",
theNodeId,
theData[1],
@@ -680,21 +665,21 @@ EventLogger::getText(int type,
// REPORT Undo Logging blocked due to buffer near to overflow.
//-----------------------------------------------------------------------
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sNode %d declared dead due to missed heartbeat",
theNodeId,
theData[1]);
break;
case EventReport::JobStatistic:
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sMean loop Counter in doJob last 8192 times = %u",
theNodeId,
theData[1]);
break;
case EventReport::SendBytesStatistic:
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sMean send size to Node = %d last 4096 sends = %u bytes",
theNodeId,
theData[1],
@@ -702,7 +687,7 @@ EventLogger::getText(int type,
break;
case EventReport::ReceiveBytesStatistic:
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sMean receive size to Node = %d last 4096 sends = %u bytes",
theNodeId,
theData[1],
@@ -710,14 +695,14 @@ EventLogger::getText(int type,
break;
case EventReport::SentHeartbeat:
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sNode Sent Heartbeat to node = %d",
theNodeId,
theData[1]);
break;
case EventReport::CreateLogBytes:
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sLog part %u, log file %u, MB %u",
theNodeId,
theData[1],
@@ -726,7 +711,7 @@ EventLogger::getText(int type,
break;
case EventReport::StartLog:
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sLog part %u, start MB %u, stop MB %u, last GCI, log exec %u",
theNodeId,
theData[1],
@@ -736,7 +721,7 @@ EventLogger::getText(int type,
break;
case EventReport::StartREDOLog:
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sNode: %d StartLog: [GCI Keep: %d LastCompleted: %d NewestRestorable: %d]",
theNodeId,
theData[1],
@@ -753,7 +738,7 @@ EventLogger::getText(int type,
}
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%s UNDO %s %d [%d %d %d %d %d %d %d %d %d]",
theNodeId,
line,
@@ -771,36 +756,36 @@ EventLogger::getText(int type,
break;
case EventReport::InfoEvent:
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%s%s",
theNodeId,
(char *)&theData[1]);
break;
case EventReport::WarningEvent:
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%s%s",
theNodeId,
(char *)&theData[1]);
break;
case EventReport::GCP_TakeoverStarted:
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sGCP Take over started", theNodeId);
break;
case EventReport::GCP_TakeoverCompleted:
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sGCP Take over completed", theNodeId);
break;
case EventReport::LCP_TakeoverStarted:
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sLCP Take over started", theNodeId);
break;
case EventReport::LCP_TakeoverCompleted:
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sLCP Take over completed (state = %d)",
theNodeId, theData[1]);
break;
@@ -812,7 +797,7 @@ EventLogger::getText(int type,
const int block = theData[5];
const int percent = (used*100)/total;
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"%s%s usage %s %d%s(%d %dK pages of total %d)",
theNodeId,
(block==DBACC ? "Index" : (block == DBTUP ?"Data":"<unknown>")),
@@ -833,7 +818,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::SSCoord: Created subscription id"
" (subId=%d,SubKey=%d)"
" Return code: %d.",
@@ -847,7 +832,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::PSCoord: Created subscription id"
" (subId=%d,SubKey=%d)"
" Return code: %d.",
@@ -862,7 +847,7 @@ EventLogger::getText(int type,
const int subKey = theData[3];
const int err = theData[4];
const int nodegrp = theData[5];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::SSCoord: Created subscription using"
" (subId=%d,SubKey=%d)"
" in primary system. Primary system has %d nodegroup(s)."
@@ -878,7 +863,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::PSCoord: All participants have created "
"subscriptions"
" using (subId=%d,SubKey=%d)."
@@ -893,7 +878,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::SSCoord: Logging started on meta data changes."
" using (subId=%d,SubKey=%d)"
" Return code: %d",
@@ -907,7 +892,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::PSCoord: All participants have started "
"logging meta data"
" changes on the subscription subId=%d,SubKey=%d) "
@@ -922,7 +907,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::SSCoord: Logging started on table data changes "
" using (subId=%d,SubKey=%d)"
" Return code: %d",
@@ -936,7 +921,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::PSCoord: All participants have started logging "
"table data changes on the subscription "
"subId=%d,SubKey=%d)."
@@ -951,7 +936,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::PSCoord: All participants have started "
" synchronization on meta data (META SCAN) using "
"(subId=%d,SubKey=%d)."
@@ -966,7 +951,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::SSCoord: Synchronization started (META SCAN) on "
" meta data using (subId=%d,SubKey=%d)"
" Return code: %d",
@@ -980,7 +965,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::PSCoord: All participants have started "
"synchronization "
" on table data (DATA SCAN) using (subId=%d,SubKey=%d)."
@@ -996,7 +981,7 @@ EventLogger::getText(int type,
const int subKey = theData[3];
const int err = theData[4];
const int gci = theData[5];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::SSCoord: Synchronization started (DATA SCAN) on "
"table data using (subId=%d,SubKey=%d). GCI = %d"
" Return code: %d",
@@ -1011,7 +996,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::PSCoord: All participants have removed "
"subscription (subId=%d,SubKey=%d). I have cleaned "
"up resources I've used."
@@ -1026,7 +1011,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::SSCoord: Removed subscription "
"(subId=%d,SubKey=%d)"
" Return code: %d",
@@ -1037,7 +1022,7 @@ EventLogger::getText(int type,
}
default:
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sUnknown GrepSubscriptonInfo event: %d",
theNodeId,
theData[1]);
@@ -1055,7 +1040,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::SSCoord:Error code: %d Error message: %s"
" (subId=%d,SubKey=%d)",
err,
@@ -1069,7 +1054,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::SSCoord: FAILED to Created subscription using"
" (subId=%d,SubKey=%d)in primary system."
" Error code: %d Error Message: %s",
@@ -1084,7 +1069,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::SSCoord: Logging failed to start on meta "
"data changes."
" using (subId=%d,SubKey=%d)"
@@ -1100,7 +1085,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::SSCoord: Logging FAILED to start on table data "
" changes using (subId=%d,SubKey=%d)"
" Error code: %d Error Message: %s",
@@ -1115,7 +1100,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::SSCoord: Synchronization FAILED (META SCAN) on "
" meta data using (subId=%d,SubKey=%d)"
" Error code: %d Error Message: %s",
@@ -1131,7 +1116,7 @@ EventLogger::getText(int type,
const int subKey = theData[3];
const int err = theData[4];
const int gci = theData[5];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::SSCoord: Synchronization FAILED (DATA SCAN) on "
"table data using (subId=%d,SubKey=%d). GCI = %d"
" Error code: %d Error Message: %s",
@@ -1147,7 +1132,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::SSCoord: Failed to remove subscription "
"(subId=%d,SubKey=%d). "
" Error code: %d Error Message: %s",
@@ -1164,7 +1149,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::PSCoord: Error code: %d Error Message: %s"
" (subId=%d,SubKey=%d)",
err,
@@ -1178,7 +1163,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::PSCoord: FAILED to Created subscription using"
" (subId=%d,SubKey=%d)in primary system."
" Error code: %d Error Message: %s",
@@ -1193,7 +1178,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::PSCoord: Logging failed to start on meta "
"data changes."
" using (subId=%d,SubKey=%d)"
@@ -1209,7 +1194,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::PSCoord: Logging FAILED to start on table data "
" changes using (subId=%d,SubKey=%d)"
" Error code: %d Error Message: %s",
@@ -1224,7 +1209,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::PSCoord: Synchronization FAILED (META SCAN) on "
" meta data using (subId=%d,SubKey=%d)"
" Error code: %d Error Message: %s",
@@ -1240,7 +1225,7 @@ EventLogger::getText(int type,
const int subKey = theData[3];
const int err = theData[4];
const int gci = theData[5];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::PSCoord: Synchronization FAILED (DATA SCAN) on "
"table data using (subId=%d,SubKey=%d). GCI = %d. "
" Error code: %d Error Message: %s",
@@ -1256,7 +1241,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Grep::PSCoord: Failed to remove subscription "
"(subId=%d,SubKey=%d)."
" Error code: %d Error Message: %s",
@@ -1270,7 +1255,7 @@ EventLogger::getText(int type,
{
const int err = theData[4];
const int nodeId = theData[5];
- ::snprintf(m_text, sizeof(m_text),
+ ::snprintf(m_text, m_text_len,
"Rep: Node %d."
" Error code: %d Error Message: %s",
nodeId,
@@ -1282,7 +1267,7 @@ EventLogger::getText(int type,
default:
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sUnknown GrepSubscriptionAlert event: %d",
theNodeId,
theData[1]);
@@ -1293,7 +1278,7 @@ EventLogger::getText(int type,
default:
::snprintf(m_text,
- sizeof(m_text),
+ m_text_len,
"%sUnknown event: %d",
theNodeId,
theData[0]);
@@ -1303,9 +1288,9 @@ EventLogger::getText(int type,
}
bool
-EventLogger::matchEventCategory(const char * str,
- LogLevel::EventCategory * cat,
- bool exactMatch){
+EventLoggerBase::matchEventCategory(const char * str,
+ LogLevel::EventCategory * cat,
+ bool exactMatch){
unsigned i;
if(cat == 0 || str == 0)
return false;
@@ -1326,7 +1311,7 @@ EventLogger::matchEventCategory(const char * str,
}
const char *
-EventLogger::getEventCategoryName(LogLevel::EventCategory cat){
+EventLoggerBase::getEventCategoryName(LogLevel::EventCategory cat){
for(unsigned i = 0; i<noOfEventCategoryNames; i++){
if(cat == eventCategoryNames[i].category){
@@ -1337,19 +1322,19 @@ EventLogger::getEventCategoryName(LogLevel::EventCategory cat){
}
-EventLogger::EventLogger() : Logger(), m_logLevel(), m_filterLevel(15)
+EventLogger::EventLogger() : m_filterLevel(15)
{
setCategory("EventLogger");
m_logLevel.setLogLevel(LogLevel::llStartUp, m_filterLevel);
m_logLevel.setLogLevel(LogLevel::llShutdown, m_filterLevel);
- // m_logLevel.setLogLevel(LogLevel::llStatistic, m_filterLevel);
- // m_logLevel.setLogLevel(LogLevel::llCheckpoint, m_filterLevel);
+ m_logLevel.setLogLevel(LogLevel::llStatistic, m_filterLevel);
+ m_logLevel.setLogLevel(LogLevel::llCheckpoint, m_filterLevel);
m_logLevel.setLogLevel(LogLevel::llNodeRestart, m_filterLevel);
m_logLevel.setLogLevel(LogLevel::llConnection, m_filterLevel);
m_logLevel.setLogLevel(LogLevel::llError, m_filterLevel);
m_logLevel.setLogLevel(LogLevel::llInfo, m_filterLevel);
- enable(Logger::LL_INFO, Logger::LL_ALERT); // Log INFO to ALERT
-
+ enable(Logger::Logger::LL_INFO, Logger::Logger::LL_ALERT); // Log INFO to ALERT
+
}
EventLogger::~EventLogger()
@@ -1371,65 +1356,61 @@ EventLogger::close()
}
void
-EventLogger::log(NodeId nodeId, int eventType, const Uint32* theData)
-{
- log(eventType, theData, nodeId);
-}
-
-void
EventLogger::log(int eventType, const Uint32* theData, NodeId nodeId)
{
Uint32 threshold = 0;
- Logger::LoggerLevel severity = LL_WARNING;
+ Logger::LoggerLevel severity = Logger::LL_WARNING;
+ LogLevel::EventCategory cat;
for(unsigned i = 0; i<EventLogger::matrixSize; i++){
if(EventLogger::matrix[i].eventType == eventType){
- const LogLevel::EventCategory cat = EventLogger::matrix[i].eventCategory;
- threshold = m_logLevel.getLogLevel(cat);
+ cat = EventLogger::matrix[i].eventCategory;
+ threshold = EventLogger::matrix[i].threshold;
severity = EventLogger::matrix[i].severity;
break;
}
}
-
- if (threshold <= m_filterLevel){
+
+ if (threshold <= m_logLevel.getLogLevel(cat)){
switch (severity){
- case LL_ALERT:
- alert(EventLogger::getText(eventType, theData, nodeId));
+ case Logger::LL_ALERT:
+ alert(EventLogger::getText(m_text, sizeof(m_text),
+ eventType, theData, nodeId));
break;
- case LL_CRITICAL:
- critical(EventLogger::getText(eventType, theData, nodeId));
+ case Logger::LL_CRITICAL:
+ critical(EventLogger::getText(m_text, sizeof(m_text),
+ eventType, theData, nodeId));
break;
- case LL_WARNING:
- warning(EventLogger::getText(eventType, theData, nodeId));
+ case Logger::LL_WARNING:
+ warning(EventLogger::getText(m_text, sizeof(m_text),
+ eventType, theData, nodeId));
break;
- case LL_ERROR:
- error(EventLogger::getText(eventType, theData, nodeId));
+ case Logger::LL_ERROR:
+ error(EventLogger::getText(m_text, sizeof(m_text),
+ eventType, theData, nodeId));
break;
- case LL_INFO:
- info(EventLogger::getText(eventType, theData, nodeId));
+ case Logger::LL_INFO:
+ info(EventLogger::getText(m_text, sizeof(m_text),
+ eventType, theData, nodeId));
break;
- case LL_DEBUG:
- debug(EventLogger::getText(eventType, theData, nodeId));
+ case Logger::LL_DEBUG:
+ debug(EventLogger::getText(m_text, sizeof(m_text),
+ eventType, theData, nodeId));
break;
default:
- info(EventLogger::getText(eventType, theData, nodeId));
+ info(EventLogger::getText(m_text, sizeof(m_text),
+ eventType, theData, nodeId));
break;
}
} // if (..
}
-LogLevel&
-EventLogger::getLoglevel()
-{
- return m_logLevel;
-}
-
int
EventLogger::getFilterLevel() const
{
diff --git a/ndb/src/common/mgmcommon/ConfigRetriever.cpp b/ndb/src/common/mgmcommon/ConfigRetriever.cpp
index 109c999852b..a2d6f6a3cea 100644
--- a/ndb/src/common/mgmcommon/ConfigRetriever.cpp
+++ b/ndb/src/common/mgmcommon/ConfigRetriever.cpp
@@ -344,7 +344,7 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf, Uint32
const char * name;
struct in_addr addr;
BaseString tmp;
- if(!iter.get(CFG_TCP_HOSTNAME_1, &name) && strlen(name)){
+ if(!iter.get(CFG_CONNECTION_HOSTNAME_1, &name) && strlen(name)){
if(Ndb_getInAddr(&addr, name) != 0){
tmp.assfmt("Unable to lookup/illegal hostname %s, "
"connection from node %d to node %d",
@@ -354,7 +354,7 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf, Uint32
}
}
- if(!iter.get(CFG_TCP_HOSTNAME_2, &name) && strlen(name)){
+ if(!iter.get(CFG_CONNECTION_HOSTNAME_2, &name) && strlen(name)){
if(Ndb_getInAddr(&addr, name) != 0){
tmp.assfmt("Unable to lookup/illegal hostname %s, "
"connection from node %d to node %d",
diff --git a/ndb/src/common/mgmcommon/IPCConfig.cpp b/ndb/src/common/mgmcommon/IPCConfig.cpp
index a76c541f3f6..d7ad993c2af 100644
--- a/ndb/src/common/mgmcommon/IPCConfig.cpp
+++ b/ndb/src/common/mgmcommon/IPCConfig.cpp
@@ -345,18 +345,27 @@ IPCConfig::configureTransporters(Uint32 nodeId,
const class ndb_mgm_configuration & config,
class TransporterRegistry & tr){
- Uint32 noOfTransportersCreated= 0, server_port= 0;
+ Uint32 noOfTransportersCreated= 0;
ndb_mgm_configuration_iterator iter(config, CFG_SECTION_CONNECTION);
for(iter.first(); iter.valid(); iter.next()){
Uint32 nodeId1, nodeId2, remoteNodeId;
+ const char * remoteHostName= 0, * localHostName= 0;
if(iter.get(CFG_CONNECTION_NODE_1, &nodeId1)) continue;
if(iter.get(CFG_CONNECTION_NODE_2, &nodeId2)) continue;
if(nodeId1 != nodeId && nodeId2 != nodeId) continue;
remoteNodeId = (nodeId == nodeId1 ? nodeId2 : nodeId1);
+ {
+ const char * host1= 0, * host2= 0;
+ iter.get(CFG_CONNECTION_HOSTNAME_1, &host1);
+ iter.get(CFG_CONNECTION_HOSTNAME_2, &host2);
+ localHostName = (nodeId == nodeId1 ? host1 : host2);
+ remoteHostName = (nodeId == nodeId1 ? host2 : host1);
+ }
+
Uint32 sendSignalId = 1;
Uint32 checksum = 1;
if(iter.get(CFG_CONNECTION_SEND_SIGNAL_ID, &sendSignalId)) continue;
@@ -365,14 +374,10 @@ IPCConfig::configureTransporters(Uint32 nodeId,
Uint32 type = ~0;
if(iter.get(CFG_TYPE_OF_SECTION, &type)) continue;
- Uint32 tmp_server_port= 0;
- if(iter.get(CFG_CONNECTION_SERVER_PORT, &tmp_server_port)) break;
+ Uint32 server_port= 0;
+ if(iter.get(CFG_CONNECTION_SERVER_PORT, &server_port)) break;
if (nodeId <= nodeId1 && nodeId <= nodeId2) {
- if (server_port && server_port != tmp_server_port) {
- ndbout << "internal error in config setup of server ports line= " << __LINE__ << endl;
- exit(-1);
- }
- server_port= tmp_server_port;
+ tr.add_transporter_interface(localHostName, server_port);
}
switch(type){
@@ -388,7 +393,7 @@ IPCConfig::configureTransporters(Uint32 nodeId,
if(iter.get(CFG_SHM_KEY, &conf.shmKey)) break;
if(iter.get(CFG_SHM_BUFFER_MEM, &conf.shmSize)) break;
- conf.port= tmp_server_port;
+ conf.port= server_port;
if(!tr.createTransporter(&conf)){
ndbout << "Failed to create SHM Transporter from: "
@@ -437,14 +442,10 @@ IPCConfig::configureTransporters(Uint32 nodeId,
case CONNECTION_TYPE_TCP:{
TCP_TransporterConfiguration conf;
- const char * host1, * host2;
- if(iter.get(CFG_TCP_HOSTNAME_1, &host1)) break;
- if(iter.get(CFG_TCP_HOSTNAME_2, &host2)) break;
-
if(iter.get(CFG_TCP_SEND_BUFFER_SIZE, &conf.sendBufferSize)) break;
if(iter.get(CFG_TCP_RECEIVE_BUFFER_SIZE, &conf.maxReceiveSize)) break;
- conf.port= tmp_server_port;
+ conf.port= server_port;
const char * proxy;
if (!iter.get(CFG_TCP_PROXY, &proxy)) {
if (strlen(proxy) > 0 && nodeId2 == nodeId) {
@@ -455,8 +456,8 @@ IPCConfig::configureTransporters(Uint32 nodeId,
conf.localNodeId = nodeId;
conf.remoteNodeId = remoteNodeId;
- conf.localHostName = (nodeId == nodeId1 ? host1 : host2);
- conf.remoteHostName = (nodeId == nodeId1 ? host2 : host1);
+ conf.localHostName = localHostName;
+ conf.remoteHostName = remoteHostName;
conf.byteOrder = 0;
conf.compression = 0;
conf.checksum = checksum;
@@ -470,19 +471,15 @@ IPCConfig::configureTransporters(Uint32 nodeId,
}
case CONNECTION_TYPE_OSE:{
OSE_TransporterConfiguration conf;
-
- const char * host1, * host2;
- if(iter.get(CFG_OSE_HOSTNAME_1, &host1)) break;
- if(iter.get(CFG_OSE_HOSTNAME_2, &host2)) break;
-
+
if(iter.get(CFG_OSE_PRIO_A_SIZE, &conf.prioASignalSize)) break;
if(iter.get(CFG_OSE_PRIO_B_SIZE, &conf.prioBSignalSize)) break;
if(iter.get(CFG_OSE_RECEIVE_ARRAY_SIZE, &conf.receiveBufferSize)) break;
conf.localNodeId = nodeId;
conf.remoteNodeId = remoteNodeId;
- conf.localHostName = (nodeId == nodeId1 ? host1 : host2);
- conf.remoteHostName = (nodeId == nodeId1 ? host2 : host1);
+ conf.localHostName = localHostName;
+ conf.remoteHostName = remoteHostName;
conf.byteOrder = 0;
conf.compression = 0;
conf.checksum = checksum;
@@ -502,9 +499,6 @@ IPCConfig::configureTransporters(Uint32 nodeId,
}
}
}
-
- tr.m_service_port= server_port;
-
return noOfTransportersCreated;
}
diff --git a/ndb/src/common/portlib/NdbTCP.cpp b/ndb/src/common/portlib/NdbTCP.cpp
index 8448d64222f..a711a586203 100644
--- a/ndb/src/common/portlib/NdbTCP.cpp
+++ b/ndb/src/common/portlib/NdbTCP.cpp
@@ -15,6 +15,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+#include <ndb_global.h>
#include <NdbMutex.h>
#include <NdbTCP.h>
@@ -27,13 +28,14 @@ static NdbMutex LOCK_gethostbyname = NDB_MUTEX_INITIALIZER;
extern "C"
int
Ndb_getInAddr(struct in_addr * dst, const char *address) {
+ DBUG_ENTER("Ndb_getInAddr");
struct hostent * hostPtr;
NdbMutex_Lock(&LOCK_gethostbyname);
hostPtr = gethostbyname(address);
if (hostPtr != NULL) {
dst->s_addr = ((struct in_addr *) *hostPtr->h_addr_list)->s_addr;
NdbMutex_Unlock(&LOCK_gethostbyname);
- return 0;
+ DBUG_RETURN(0);
}
NdbMutex_Unlock(&LOCK_gethostbyname);
@@ -47,9 +49,11 @@ Ndb_getInAddr(struct in_addr * dst, const char *address) {
#endif
)
{
- return 0;
+ DBUG_RETURN(0);
}
- return -1;
+ DBUG_PRINT("error",("inet_addr(%s) - %d - %s",
+ address, errno, strerror(errno)));
+ DBUG_RETURN(-1);
}
#if 0
diff --git a/ndb/src/common/transporter/TransporterRegistry.cpp b/ndb/src/common/transporter/TransporterRegistry.cpp
index fe1d4b04786..5679c3c5834 100644
--- a/ndb/src/common/transporter/TransporterRegistry.cpp
+++ b/ndb/src/common/transporter/TransporterRegistry.cpp
@@ -98,9 +98,8 @@ SocketServer::Session * TransporterService::newSession(NDB_SOCKET_TYPE sockfd)
TransporterRegistry::TransporterRegistry(void * callback,
unsigned _maxTransporters,
- unsigned sizeOfLongSignalMemory) {
-
- m_transporter_service= 0;
+ unsigned sizeOfLongSignalMemory)
+{
nodeIdSpecified = false;
maxTransporters = _maxTransporters;
sendCounter = 1;
@@ -150,7 +149,6 @@ TransporterRegistry::~TransporterRegistry() {
delete[] theTransporters;
delete[] performStates;
delete[] ioStates;
-
#ifdef NDB_OSE_TRANSPORTER
if(theOSEReceiver != NULL){
theOSEReceiver->destroyPhantom();
@@ -1159,55 +1157,67 @@ TransporterRegistry::stop_clients()
return true;
}
-bool
-TransporterRegistry::start_service(SocketServer& socket_server)
+void
+TransporterRegistry::add_transporter_interface(const char *interface, unsigned short port)
{
-#if 0
- for (int i= 0, n= 0; n < nTransporters; i++){
- Transporter * t = theTransporters[i];
- if (!t)
+ DBUG_ENTER("TransporterRegistry::add_transporter_interface");
+ DBUG_PRINT("enter",("interface=%s, port= %d", interface, port));
+ if (interface && strlen(interface) == 0)
+ interface= 0;
+
+ for (unsigned i= 0; i < m_transporter_interface.size(); i++)
+ {
+ Transporter_interface &tmp= m_transporter_interface[i];
+ if (port != tmp.m_service_port)
continue;
- n++;
- if (t->isServer) {
- t->m_service = new TransporterService(new SocketAuthSimple("ndbd passwd"));
- if(!socket_server.setup(t->m_service, t->m_r_port, 0))
- {
- ndbout_c("Unable to setup transporter service port: %d!\n"
- "Please check if the port is already used,\n"
- "(perhaps a mgmt server is already running)",
- m_service_port);
- delete t->m_service;
- return false;
- }
+ if (interface != 0 && tmp.m_interface != 0 &&
+ strcmp(interface, tmp.m_interface) == 0)
+ {
+ DBUG_VOID_RETURN; // found match, no need to insert
+ }
+ if (interface == 0 && tmp.m_interface == 0)
+ {
+ DBUG_VOID_RETURN; // found match, no need to insert
}
}
-#endif
-
- if (m_service_port != 0) {
+ Transporter_interface t;
+ t.m_service_port= port;
+ t.m_interface= interface;
+ m_transporter_interface.push_back(t);
+ DBUG_PRINT("exit",("interface and port added"));
+ DBUG_VOID_RETURN;
+}
- m_transporter_service = new TransporterService(new SocketAuthSimple("ndbd", "ndbd passwd"));
+bool
+TransporterRegistry::start_service(SocketServer& socket_server)
+{
+ if (m_transporter_interface.size() > 0 && nodeIdSpecified != true)
+ {
+ ndbout_c("TransporterRegistry::startReceiving: localNodeId not specified");
+ return false;
+ }
- if (nodeIdSpecified != true) {
- ndbout_c("TransporterRegistry::startReceiving: localNodeId not specified");
+ for (unsigned i= 0; i < m_transporter_interface.size(); i++)
+ {
+ Transporter_interface &t= m_transporter_interface[i];
+ if (t.m_service_port == 0)
+ {
+ continue;
+ }
+ TransporterService *transporter_service =
+ new TransporterService(new SocketAuthSimple("ndbd", "ndbd passwd"));
+ if(!socket_server.setup(transporter_service,
+ t.m_service_port, t.m_interface))
+ {
+ ndbout_c("Unable to setup transporter service port: %s:%d!\n"
+ "Please check if the port is already used,\n"
+ "(perhaps the node is already running)",
+ t.m_interface ? t.m_interface : "*", t.m_service_port);
+ delete transporter_service;
return false;
}
-
- //m_interface_name = "ndbd";
- m_interface_name = 0;
-
- if(!socket_server.setup(m_transporter_service, m_service_port, m_interface_name))
- {
- ndbout_c("Unable to setup transporter service port: %d!\n"
- "Please check if the port is already used,\n"
- "(perhaps a mgmt server is already running)",
- m_service_port);
- delete m_transporter_service;
- return false;
- }
- m_transporter_service->setTransporterRegistry(this);
- } else
- m_transporter_service= 0;
-
+ transporter_service->setTransporterRegistry(this);
+ }
return true;
}
@@ -1281,3 +1291,5 @@ NdbOut & operator <<(NdbOut & out, SignalHeader & sh){
out << "trace: " << (int)sh.theTrace << endl;
return out;
}
+
+template class Vector<TransporterRegistry::Transporter_interface>;
diff --git a/ndb/src/common/util/Makefile.am b/ndb/src/common/util/Makefile.am
index 678added01e..efb249dd330 100644
--- a/ndb/src/common/util/Makefile.am
+++ b/ndb/src/common/util/Makefile.am
@@ -9,7 +9,7 @@ libgeneral_la_SOURCES = \
NdbSqlUtil.cpp new.cpp \
uucode.c random.c getarg.c version.c \
strdup.c strlcat.c strlcpy.c \
- ConfigValues.cpp
+ ConfigValues.cpp ndb_init.c
include $(top_srcdir)/ndb/config/common.mk.am
include $(top_srcdir)/ndb/config/type_util.mk.am
diff --git a/ndb/src/common/util/NdbSqlUtil.cpp b/ndb/src/common/util/NdbSqlUtil.cpp
index 84a6f6e6c21..afb9bcfff62 100644
--- a/ndb/src/common/util/NdbSqlUtil.cpp
+++ b/ndb/src/common/util/NdbSqlUtil.cpp
@@ -529,6 +529,83 @@ NdbSqlUtil::cmpText(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size
return CmpUnknown;
}
+// check charset
+
+bool
+NdbSqlUtil::usable_in_pk(Uint32 typeId, const void* info)
+{
+ const Type& type = getType(typeId);
+ switch (type.m_typeId) {
+ case Type::Undefined:
+ break;
+ case Type::Char:
+ {
+ const CHARSET_INFO *cs = (const CHARSET_INFO*)info;
+ return
+ cs != 0 &&
+ cs->cset != 0 &&
+ cs->coll != 0 &&
+ cs->coll->strnxfrm != 0 &&
+ cs->strxfrm_multiply == 1; // current limitation
+ }
+ break;
+ case Type::Varchar:
+ return true; // Varchar not used via MySQL
+ case Type::Blob:
+ case Type::Text:
+ break;
+ default:
+ return true;
+ }
+ return false;
+}
+
+bool
+NdbSqlUtil::usable_in_hash_index(Uint32 typeId, const void* info)
+{
+ return usable_in_pk(typeId, info);
+}
+
+bool
+NdbSqlUtil::usable_in_ordered_index(Uint32 typeId, const void* info)
+{
+ const Type& type = getType(typeId);
+ switch (type.m_typeId) {
+ case Type::Undefined:
+ break;
+ case Type::Char:
+ {
+ const CHARSET_INFO *cs = (const CHARSET_INFO*)info;
+ return
+ cs != 0 &&
+ cs->cset != 0 &&
+ cs->coll != 0 &&
+ cs->coll->strnxfrm != 0 &&
+ cs->coll->strnncollsp != 0 &&
+ cs->strxfrm_multiply == 1; // current limitation
+ }
+ break;
+ case Type::Varchar:
+ return true; // Varchar not used via MySQL
+ case Type::Text:
+ {
+ const CHARSET_INFO *cs = (const CHARSET_INFO*)info;
+ return
+ cs != 0 &&
+ cs->mbmaxlen == 1 && // extra limitation
+ cs->cset != 0 &&
+ cs->coll != 0 &&
+ cs->coll->strnxfrm != 0 &&
+ cs->coll->strnncollsp != 0 &&
+ cs->strxfrm_multiply == 1; // current limitation
+ }
+ break;
+ default:
+ return true;
+ }
+ return false;
+}
+
#ifdef NDB_SQL_UTIL_TEST
#include <NdbTick.h>
diff --git a/ndb/src/common/util/SocketServer.cpp b/ndb/src/common/util/SocketServer.cpp
index 0cc06a54496..380a8073a2c 100644
--- a/ndb/src/common/util/SocketServer.cpp
+++ b/ndb/src/common/util/SocketServer.cpp
@@ -16,6 +16,7 @@
#include <ndb_global.h>
+#include <my_pthread.h>
#include <SocketServer.hpp>
@@ -83,7 +84,8 @@ bool
SocketServer::setup(SocketServer::Service * service,
unsigned short port,
const char * intface){
-
+ DBUG_ENTER("SocketServer::setup");
+ DBUG_PRINT("enter",("interface=%s, port=%d", intface, port));
struct sockaddr_in servaddr;
memset(&servaddr, 0, sizeof(servaddr));
servaddr.sin_family = AF_INET;
@@ -92,36 +94,44 @@ SocketServer::setup(SocketServer::Service * service,
if(intface != 0){
if(Ndb_getInAddr(&servaddr.sin_addr, intface))
- return false;
+ DBUG_RETURN(false);
}
const NDB_SOCKET_TYPE sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock == NDB_INVALID_SOCKET) {
- return false;
+ DBUG_PRINT("error",("socket() - %d - %s",
+ errno, strerror(errno)));
+ DBUG_RETURN(false);
}
const int on = 1;
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
(const char*)&on, sizeof(on)) == -1) {
+ DBUG_PRINT("error",("getsockopt() - %d - %s",
+ errno, strerror(errno)));
NDB_CLOSE_SOCKET(sock);
- return false;
+ DBUG_RETURN(false);
}
if (bind(sock, (struct sockaddr*) &servaddr, sizeof(servaddr)) == -1) {
+ DBUG_PRINT("error",("bind() - %d - %s",
+ errno, strerror(errno)));
NDB_CLOSE_SOCKET(sock);
- return false;
+ DBUG_RETURN(false);
}
if (listen(sock, m_maxSessions) == -1){
+ DBUG_PRINT("error",("listen() - %d - %s",
+ errno, strerror(errno)));
NDB_CLOSE_SOCKET(sock);
- return false;
+ DBUG_RETURN(false);
}
ServiceInstance i;
i.m_socket = sock;
i.m_service = service;
m_services.push_back(i);
- return true;
+ DBUG_RETURN(true);
}
void
@@ -177,8 +187,9 @@ void*
socketServerThread_C(void* _ss){
SocketServer * ss = (SocketServer *)_ss;
+ my_thread_init();
ss->doRun();
-
+ my_thread_end();
NdbThread_Exit(0);
return 0;
}
@@ -287,8 +298,10 @@ void*
sessionThread_C(void* _sc){
SocketServer::Session * si = (SocketServer::Session *)_sc;
+ my_thread_init();
if(!transfer(si->m_socket)){
si->m_stopped = true;
+ my_thread_end();
NdbThread_Exit(0);
return 0;
}
@@ -301,6 +314,7 @@ sessionThread_C(void* _sc){
}
si->m_stopped = true;
+ my_thread_end();
NdbThread_Exit(0);
return 0;
}
diff --git a/ndb/src/common/util/ndb_init.c b/ndb/src/common/util/ndb_init.c
new file mode 100644
index 00000000000..b160ed3636b
--- /dev/null
+++ b/ndb/src/common/util/ndb_init.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 2003 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#include <ndb_global.h>
+#include <my_sys.h>
+
+int
+ndb_init()
+{
+ if (my_init()) {
+ const char* err = "my_init() failed - exit\n";
+ write(2, err, strlen(err));
+ exit(1);
+ }
+ return 0;
+}
diff --git a/ndb/src/kernel/blocks/backup/read.cpp b/ndb/src/kernel/blocks/backup/read.cpp
index 921c352ea13..89cc08ee9de 100644
--- a/ndb/src/kernel/blocks/backup/read.cpp
+++ b/ndb/src/kernel/blocks/backup/read.cpp
@@ -48,6 +48,7 @@ static Uint32 logEntryNo;
int
main(int argc, const char * argv[]){
+ ndb_init();
if(argc <= 1){
printf("Usage: %s <filename>", argv[0]);
exit(1);
diff --git a/ndb/src/kernel/blocks/backup/restore/main.cpp b/ndb/src/kernel/blocks/backup/restore/main.cpp
index a330aa51373..5708415c61e 100644
--- a/ndb/src/kernel/blocks/backup/restore/main.cpp
+++ b/ndb/src/kernel/blocks/backup/restore/main.cpp
@@ -206,6 +206,7 @@ free_data_callback()
int
main(int argc, const char** argv)
{
+ ndb_init();
if (!readArguments(argc, argv))
{
return -1;
@@ -331,7 +332,7 @@ main(int argc, const char** argv)
for (i= 0; i < g_consumers.size(); i++)
g_consumers[i]->endOfTuples();
-
+
RestoreLogIterator logIter(metaData);
if (!logIter.readHeader())
{
@@ -357,7 +358,7 @@ main(int argc, const char** argv)
}
}
clearConsumers();
- return 1;
+ return 0;
} // main
template class Vector<BackupConsumer*>;
diff --git a/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp b/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp
index e2085eb612c..fff6c734bd3 100644
--- a/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp
+++ b/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp
@@ -250,17 +250,7 @@ Cmvmi::execEVENT_SUBSCRIBE_REQ(Signal * signal){
sendSignal(subReq->blockRef, GSN_EVENT_SUBSCRIBE_REF, signal, 1, JBB);
return;
}
- /**
- * If it's a new subscription, clear the loglevel
- *
- * Clear only if noOfEntries is 0, this is needed beacuse we set
- * the default loglevels for the MGMT nodes during the inital connect phase.
- * See reportConnected().
- */
- if (subReq->noOfEntries == 0){
- ptr.p->logLevel.clear();
- }
-
+ ptr.p->logLevel.clear();
ptr.p->blockRef = subReq->blockRef;
}
@@ -384,11 +374,6 @@ void Cmvmi::execCLOSE_COMREQ(Signal* signal)
globalTransporterRegistry.setIOState(i, HaltIO);
globalTransporterRegistry.do_disconnect(i);
-
- /**
- * Cancel possible event subscription
- */
- cancelSubscription(i);
}
}
if (failNo != 0) {
@@ -494,6 +479,8 @@ void Cmvmi::execDISCONNECT_REP(Signal *signal)
globalTransporterRegistry.do_connect(hostId);
}
+ cancelSubscription(hostId);
+
signal->theData[0] = EventReport::Disconnected;
signal->theData[1] = hostId;
sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB);
@@ -539,20 +526,6 @@ void Cmvmi::execCONNECT_REP(Signal *signal){
if(type == NodeInfo::MGM){
jam();
globalTransporterRegistry.setIOState(hostId, NoHalt);
-
- EventSubscribeReq* dst = (EventSubscribeReq *)&signal->theData[0];
-
- for (Uint32 i = 0; i < EventLogger::defEventLogMatrixSize; i++) {
- dst->theCategories[i] = EventLogger::defEventLogMatrix[i].eventCategory;
- dst->theLevels[i] = EventLogger::defEventLogMatrix[i].threshold;
- }
-
- dst->noOfEntries = EventLogger::defEventLogMatrixSize;
- /* The BlockNumber is hardcoded as 1 in MgmtSrvr */
- dst->blockRef = numberToRef(MIN_API_BLOCK_NO, hostId);
-
- execEVENT_SUBSCRIBE_REQ(signal);
-
}
//------------------------------------------
diff --git a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
index 7126842459e..d82083684b7 100644
--- a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
+++ b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
@@ -6317,6 +6317,8 @@ Dbdict::createIndex_toCreateTable(Signal* signal, OpCreateIndexPtr opPtr)
w.add(DictTabInfo::AttributeStoredInd, (Uint32)DictTabInfo::Stored);
// ext type overrides
w.add(DictTabInfo::AttributeExtType, aRec->extType);
+ w.add(DictTabInfo::AttributeExtPrecision, aRec->extPrecision);
+ w.add(DictTabInfo::AttributeExtScale, aRec->extScale);
w.add(DictTabInfo::AttributeExtLength, aRec->extLength);
w.add(DictTabInfo::AttributeEnd, (Uint32)true);
}
diff --git a/ndb/src/kernel/main.cpp b/ndb/src/kernel/main.cpp
index 491733975a8..20844db75b6 100644
--- a/ndb/src/kernel/main.cpp
+++ b/ndb/src/kernel/main.cpp
@@ -56,6 +56,7 @@ const char programName[] = "NDB Kernel";
NDB_MAIN(ndb_kernel){
+ ndb_init();
// Print to stdout/console
g_eventLogger.createConsoleHandler();
g_eventLogger.setCategory("NDB");
diff --git a/ndb/src/kernel/vm/Configuration.cpp b/ndb/src/kernel/vm/Configuration.cpp
index 8907cb9f640..c0015172512 100644
--- a/ndb/src/kernel/vm/Configuration.cpp
+++ b/ndb/src/kernel/vm/Configuration.cpp
@@ -15,7 +15,6 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <ndb_global.h>
-#include <my_sys.h>
#include "Configuration.hpp"
#include <ErrorHandlingMacros.hpp>
@@ -105,7 +104,6 @@ Configuration::init(int argc, const char** argv){
}
// check for depricated flag '-i'
- my_init();
#ifndef DBUG_OFF
if (debug_option)
DBUG_PUSH(debug_option);
diff --git a/ndb/src/mgmclient/CommandInterpreter.cpp b/ndb/src/mgmclient/CommandInterpreter.cpp
index 91d057f8c30..ba8e93edde9 100644
--- a/ndb/src/mgmclient/CommandInterpreter.cpp
+++ b/ndb/src/mgmclient/CommandInterpreter.cpp
@@ -673,8 +673,10 @@ CommandInterpreter::executeShutdown(char* parameters)
if (mgm_id == 0)
mgm_id= state->node_states[i].node_id;
else {
- ndbout << "Unable to locate management server, shutdown manually with #STOP"
+ ndbout << "Unable to locate management server, "
+ << "shutdown manually with <id> STOP"
<< endl;
+ return;
}
}
}
@@ -721,11 +723,13 @@ const char *status_string(ndb_mgm_node_status status)
static void
print_nodes(ndb_mgm_cluster_state *state, ndb_mgm_configuration_iterator *it,
- const char *proc_name, int no_proc, ndb_mgm_node_type type, int master_id)
+ const char *proc_name, int no_proc, ndb_mgm_node_type type,
+ int master_id)
{
int i;
ndbout << "[" << proc_name
- << "(" << ndb_mgm_get_node_type_string(type) << ")]\t" << no_proc << " node(s)" << endl;
+ << "(" << ndb_mgm_get_node_type_string(type) << ")]\t"
+ << no_proc << " node(s)" << endl;
for(i=0; i < state->no_of_nodes; i++) {
struct ndb_mgm_node_state *node_state= &(state->node_states[i]);
if(node_state->node_type == type) {
@@ -733,7 +737,9 @@ print_nodes(ndb_mgm_cluster_state *state, ndb_mgm_configuration_iterator *it,
ndbout << "id=" << node_id;
if(node_state->version != 0) {
const char *hostname= node_state->connect_address;
- if (hostname == 0 || strlen(hostname) == 0 || strcmp(hostname,"0.0.0.0") == 0)
+ if (hostname == 0
+ || strlen(hostname) == 0
+ || strcmp(hostname,"0.0.0.0") == 0)
ndbout << " ";
else
ndbout << "\t@" << hostname;
@@ -761,7 +767,8 @@ print_nodes(ndb_mgm_cluster_state *state, ndb_mgm_configuration_iterator *it,
ndb_mgm_get_string_parameter(it, CFG_NODE_HOST, &config_hostname);
if (config_hostname == 0 || config_hostname[0] == 0)
config_hostname= "any host";
- ndbout << " (not connected, accepting connect from " << config_hostname << ")" << endl;
+ ndbout << " (not connected, accepting connect from "
+ << config_hostname << ")" << endl;
}
}
}
diff --git a/ndb/src/mgmclient/main.cpp b/ndb/src/mgmclient/main.cpp
index df6659df0b1..69f968677cd 100644
--- a/ndb/src/mgmclient/main.cpp
+++ b/ndb/src/mgmclient/main.cpp
@@ -44,6 +44,7 @@ handler(int sig){
}
int main(int argc, const char** argv){
+ ndb_init();
int optind = 0;
const char *_host = 0;
int _port = 0;
diff --git a/ndb/src/mgmsrv/CommandInterpreter.cpp b/ndb/src/mgmsrv/CommandInterpreter.cpp
index 316b6d5795e..8388c012e55 100644
--- a/ndb/src/mgmsrv/CommandInterpreter.cpp
+++ b/ndb/src/mgmsrv/CommandInterpreter.cpp
@@ -389,9 +389,9 @@ void CommandInterpreter::executeHelp(char* parameters) {
<< endl;
ndbout << "<category> = ";
- for(i = 0; i<EventLogger::noOfEventCategoryNames; i++){
- ndbout << EventLogger::eventCategoryNames[i].name;
- if (i < EventLogger::noOfEventCategoryNames - 1) {
+ for(i = 0; i<EventLoggerBase::noOfEventCategoryNames; i++){
+ ndbout << EventLoggerBase::eventCategoryNames[i].name;
+ if (i < EventLoggerBase::noOfEventCategoryNames - 1) {
ndbout << " | ";
}
}
@@ -831,12 +831,13 @@ void CommandInterpreter::executeStatus(int processId,
//*****************************************************************************
void CommandInterpreter::executeLogLevel(int processId,
const char* parameters, bool all) {
+#if 0
(void)all; // Don't want compiler warning
SetLogLevelOrd logLevel; logLevel.clear();
if (emptyString(parameters) || (strcmp(parameters, "ALL") == 0)) {
- for(Uint32 i = 0; i<EventLogger::noOfEventCategoryNames; i++)
- logLevel.setLogLevel(EventLogger::eventCategoryNames[i].category, 7);
+ for(Uint32 i = 0; i<EventLoggerBase::noOfEventCategoryNames; i++)
+ logLevel.setLogLevel(EventLoggerBase::eventCategoryNames[i].category, 7);
} else {
char * tmpString = strdup(parameters);
@@ -852,7 +853,7 @@ void CommandInterpreter::executeLogLevel(int processId,
return;
}
LogLevel::EventCategory cat;
- if(!EventLogger::matchEventCategory(categoryTxt,
+ if(!EventLoggerBase::matchEventCategory(categoryTxt,
&cat)){
ndbout << "Invalid loglevel specification, unknown category: "
<< categoryTxt << endl;
@@ -875,6 +876,7 @@ void CommandInterpreter::executeLogLevel(int processId,
if (result != 0) {
ndbout << _mgmtSrvr.getErrorText(result) << endl;
}
+#endif
}
@@ -1080,12 +1082,13 @@ void CommandInterpreter::executeTestOff(int processId,
void CommandInterpreter::executeEventReporting(int processId,
const char* parameters,
bool all) {
+#if 0
(void)all; // Don't want compiler warning
SetLogLevelOrd logLevel; logLevel.clear();
if (emptyString(parameters) || (strcmp(parameters, "ALL") == 0)) {
- for(Uint32 i = 0; i<EventLogger::noOfEventCategoryNames; i++)
- logLevel.setLogLevel(EventLogger::eventCategoryNames[i].category, 7);
+ for(Uint32 i = 0; i<EventLoggerBase::noOfEventCategoryNames; i++)
+ logLevel.setLogLevel(EventLoggerBase::eventCategoryNames[i].category, 7);
} else {
char * tmpString = strdup(parameters);
@@ -1101,7 +1104,7 @@ void CommandInterpreter::executeEventReporting(int processId,
return;
}
LogLevel::EventCategory cat;
- if(!EventLogger::matchEventCategory(categoryTxt,
+ if(!EventLoggerBase::matchEventCategory(categoryTxt,
&cat)){
ndbout << "Invalid loglevel specification, unknown category: "
<< categoryTxt << endl;
@@ -1124,6 +1127,7 @@ void CommandInterpreter::executeEventReporting(int processId,
if (result != 0) {
ndbout << _mgmtSrvr.getErrorText(result) << endl;
}
+#endif
}
void
diff --git a/ndb/src/mgmsrv/ConfigInfo.cpp b/ndb/src/mgmsrv/ConfigInfo.cpp
index ea19bc76d0e..1de9e0aa165 100644
--- a/ndb/src/mgmsrv/ConfigInfo.cpp
+++ b/ndb/src/mgmsrv/ConfigInfo.cpp
@@ -1529,7 +1529,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
},
{
- CFG_TCP_HOSTNAME_1,
+ CFG_CONNECTION_HOSTNAME_1,
"HostName1",
"TCP",
"Name/IP of computer on one side of the connection",
@@ -1540,7 +1540,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
0, 0 },
{
- CFG_TCP_HOSTNAME_2,
+ CFG_CONNECTION_HOSTNAME_2,
"HostName2",
"TCP",
"Name/IP of computer on one side of the connection",
@@ -1935,7 +1935,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
},
{
- CFG_OSE_HOSTNAME_1,
+ CFG_CONNECTION_HOSTNAME_1,
"HostName1",
"OSE",
"Name of computer on one side of the connection",
@@ -1946,7 +1946,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
0, 0 },
{
- CFG_OSE_HOSTNAME_2,
+ CFG_CONNECTION_HOSTNAME_2,
"HostName2",
"OSE",
"Name of computer on one side of the connection",
@@ -2902,26 +2902,38 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){
DBUG_ENTER("fixPortNumber");
Uint32 id1= 0, id2= 0;
+ const char *hostName1;
+ const char *hostName2;
require(ctx.m_currentSection->get("NodeId1", &id1));
require(ctx.m_currentSection->get("NodeId2", &id2));
+ require(ctx.m_currentSection->get("HostName1", &hostName1));
+ require(ctx.m_currentSection->get("HostName2", &hostName2));
+ DBUG_PRINT("info",("NodeId1=%d HostName1=\"%s\"",id1,hostName1));
+ DBUG_PRINT("info",("NodeId2=%d HostName2=\"%s\"",id2,hostName2));
+
if (id1 > id2) {
Uint32 tmp= id1;
+ const char *tmp_name= hostName1;
+ hostName1= hostName2;
id1= id2;
+ hostName2= tmp_name;
id2= tmp;
}
const Properties * node;
require(ctx.m_config->get("Node", id1, &node));
- BaseString hostname;
- require(node->get("HostName", hostname));
+ BaseString hostname(hostName1);
+ // require(node->get("HostName", hostname));
if (hostname.c_str()[0] == 0) {
- ctx.reportError("Hostname required on nodeid %d since it will act as server.", id1);
+ ctx.reportError("Hostname required on nodeid %d since it will "
+ "act as server.", id1);
DBUG_RETURN(false);
}
Uint32 port= 0;
- if (!node->get("ServerPort", &port) && !ctx.m_userProperties.get("ServerPort_", id1, &port)) {
+ if (!node->get("ServerPort", &port) &&
+ !ctx.m_userProperties.get("ServerPort_", id1, &port)) {
Uint32 adder= 0;
{
BaseString server_port_adder(hostname);
@@ -2932,7 +2944,8 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){
Uint32 base= 0;
if (!ctx.m_userProperties.get("ServerPortBase", &base)){
- if(!(ctx.m_userDefaults && ctx.m_userDefaults->get("PortNumber", &base)) &&
+ if(!(ctx.m_userDefaults &&
+ ctx.m_userDefaults->get("PortNumber", &base)) &&
!ctx.m_systemDefaults->get("PortNumber", &base)) {
base= strtoll(NDB_BASE_PORT,0,0)+2;
// ctx.reportError("Cannot retrieve base port number");
@@ -2945,12 +2958,15 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){
}
if(ctx.m_currentSection->contains("PortNumber")) {
- ndbout << "PortNumber should no longer be specificied per connection, please remove from config. Will be changed to " << port << endl;
+ ndbout << "PortNumber should no longer be specificied "
+ << "per connection, please remove from config. "
+ << "Will be changed to " << port << endl;
ctx.m_currentSection->put("PortNumber", port, true);
} else
ctx.m_currentSection->put("PortNumber", port);
- DBUG_PRINT("info", ("connection %d-%d port %d host %s", id1, id2, port, hostname.c_str()));
+ DBUG_PRINT("info", ("connection %d-%d port %d host %s",
+ id1, id2, port, hostname.c_str()));
DBUG_RETURN(true);
}
diff --git a/ndb/src/mgmsrv/Makefile.am b/ndb/src/mgmsrv/Makefile.am
index 8fa9ec5f63e..36cb7f87d3d 100644
--- a/ndb/src/mgmsrv/Makefile.am
+++ b/ndb/src/mgmsrv/Makefile.am
@@ -12,8 +12,6 @@ ndb_mgmd_SOURCES = \
main.cpp \
Services.cpp \
convertStrToInt.cpp \
- NodeLogLevel.cpp \
- NodeLogLevelList.cpp \
SignalQueue.cpp \
MgmtSrvrConfig.cpp \
ConfigInfo.cpp \
diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp
index 8380f3fd86a..7c2298d4773 100644
--- a/ndb/src/mgmsrv/MgmtSrvr.cpp
+++ b/ndb/src/mgmsrv/MgmtSrvr.cpp
@@ -45,7 +45,6 @@
#include <ndb_version.h>
#include <SocketServer.hpp>
-#include "NodeLogLevel.hpp"
#include <NdbConfig.h>
#include <NdbAutoPtr.hpp>
@@ -62,6 +61,7 @@
#endif
extern int global_flag_send_heartbeat_now;
+extern int g_no_nodeid_checks;
static
void
@@ -191,41 +191,49 @@ EventLogger g_EventLogger;
void
MgmtSrvr::logLevelThreadRun()
{
- NdbMutex* threadMutex = NdbMutex_Create();
-
while (!_isStopThread) {
- if (_startedNodeId != 0) {
- NdbMutex_Lock(threadMutex);
-
- // Local node
- NodeLogLevel* n = NULL;
- while ((n = _nodeLogLevelList->next()) != NULL) {
- if (n->getNodeId() == _startedNodeId) {
- setNodeLogLevel(_startedNodeId, n->getLogLevelOrd(), true);
- }
- }
- // Cluster log
- while ((n = _clusterLogLevelList->next()) != NULL) {
- if (n->getNodeId() == _startedNodeId) {
- setEventReportingLevel(_startedNodeId, n->getLogLevelOrd(), true);
- }
- }
- _startedNodeId = 0;
-
- NdbMutex_Unlock(threadMutex);
+ /**
+ * Handle started nodes
+ */
+ EventSubscribeReq req;
+ req = m_statisticsListner.m_clients[0].m_logLevel;
+ req.blockRef = _ownReference;
- } // if (_startedNodeId != 0) {
+ SetLogLevelOrd ord;
+
+ m_started_nodes.lock();
+ while(m_started_nodes.size() > 0){
+ Uint32 node = m_started_nodes[0];
+ m_started_nodes.erase(0, false);
+ m_started_nodes.unlock();
+ setEventReportingLevelImpl(node, req);
+
+ ord = m_nodeLogLevel[node];
+ setNodeLogLevelImpl(node, ord);
+
+ m_started_nodes.lock();
+ }
+ m_started_nodes.unlock();
+
+ m_log_level_requests.lock();
+ while(m_log_level_requests.size() > 0){
+ req = m_log_level_requests[0];
+ m_log_level_requests.erase(0, false);
+ m_log_level_requests.unlock();
+
+ if(req.blockRef == 0){
+ req.blockRef = _ownReference;
+ setEventReportingLevelImpl(0, req);
+ } else {
+ ord = req;
+ setNodeLogLevelImpl(req.blockRef, ord);
+ }
+ m_log_level_requests.lock();
+ }
+ m_log_level_requests.unlock();
NdbSleep_MilliSleep(_logLevelThreadSleep);
- } // while (!_isStopThread)
-
- NdbMutex_Destroy(threadMutex);
-}
-
-void
-MgmtSrvr::setStatisticsListner(StatisticsListner* listner)
-{
- m_statisticsListner = listner;
+ }
}
void
@@ -272,7 +280,7 @@ class ErrorItem
{
public:
int _errorCode;
- const BaseString _errorText;
+ const char * _errorText;
};
bool
@@ -485,23 +493,6 @@ MgmtSrvr::getPort() const {
return port;
}
-int
-MgmtSrvr::getStatPort() const {
-#if 0
- const Properties *mgmProps;
- if(!getConfig()->get("Node", _ownNodeId, &mgmProps))
- return -1;
-
- int tmp = -1;
- if(!mgmProps->get("PortNumberStats", (Uint32 *)&tmp))
- return -1;
-
- return tmp;
-#else
- return -1;
-#endif
-}
-
/* Constructor */
MgmtSrvr::MgmtSrvr(NodeId nodeId,
const BaseString &configFilename,
@@ -510,22 +501,19 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId,
_blockNumber(1), // Hard coded block number since it makes it easy to send
// signals to other management servers.
_ownReference(0),
+ m_allocated_resources(*this),
theSignalIdleList(NULL),
theWaitState(WAIT_SUBSCRIBE_CONF),
- theConfCount(0),
- m_allocated_resources(*this) {
-
+ m_statisticsListner(this){
+
DBUG_ENTER("MgmtSrvr::MgmtSrvr");
_config = NULL;
- _isStatPortActive = false;
- _isClusterLogStatActive = false;
_isStopThread = false;
_logLevelThread = NULL;
_logLevelThreadSleep = 500;
m_signalRecvThread = NULL;
- _startedNodeId = 0;
theFacade = 0;
@@ -583,17 +571,27 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId,
ndb_mgm_destroy_iterator(iter);
}
- m_statisticsListner = NULL;
-
- _nodeLogLevelList = new NodeLogLevelList();
- _clusterLogLevelList = new NodeLogLevelList();
-
_props = NULL;
-
_ownNodeId= 0;
+ char my_hostname[256];
+ struct sockaddr_in tmp_addr;
+ SOCKET_SIZE_TYPE addrlen= sizeof(tmp_addr);
+ if (!g_no_nodeid_checks) {
+ if (gethostname(my_hostname, sizeof(my_hostname))) {
+ ndbout << "error: gethostname() - " << strerror(errno) << endl;
+ exit(-1);
+ }
+ if (Ndb_getInAddr(&(((sockaddr_in*)&tmp_addr)->sin_addr),my_hostname)) {
+ ndbout << "error: Ndb_getInAddr(" << my_hostname << ") - "
+ << strerror(errno) << endl;
+ exit(-1);
+ }
+ }
NodeId tmp= nodeId;
BaseString error_string;
- if (!alloc_node_id(&tmp, NDB_MGM_NODE_TYPE_MGM, 0, 0, error_string)){
+ if (!alloc_node_id(&tmp, NDB_MGM_NODE_TYPE_MGM,
+ (struct sockaddr *)&tmp_addr,
+ &addrlen, error_string)){
ndbout << "Unable to obtain requested nodeid: "
<< error_string.c_str() << endl;
exit(-1);
@@ -610,6 +608,16 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId,
}
}
+ {
+ MgmStatService::StatListener se;
+ se.m_socket = -1;
+ for(size_t t = 0; t<_LOGLEVEL_CATEGORIES; t++)
+ se.m_logLevel.setLogLevel((LogLevel::EventCategory)t, 7);
+ se.m_logLevel.setLogLevel(LogLevel::llError, 15);
+ m_statisticsListner.m_clients.push_back(se);
+ m_statisticsListner.m_logLevel = se.m_logLevel;
+ }
+
DBUG_VOID_RETURN;
}
@@ -671,8 +679,6 @@ MgmtSrvr::start(BaseString &error_string)
// Set the initial confirmation count for subscribe requests confirm
// from NDB nodes in the cluster.
//
- theConfCount = getNodeCount(NDB_MGM_NODE_TYPE_NDB);
-
// Loglevel thread
_logLevelThread = NdbThread_Create(logLevelThread_C,
(void**)this,
@@ -713,9 +719,6 @@ MgmtSrvr::~MgmtSrvr()
if(_config != NULL)
delete _config;
- delete _nodeLogLevelList;
- delete _clusterLogLevelList;
-
// End set log level thread
void* res = 0;
_isStopThread = true;
@@ -736,6 +739,9 @@ MgmtSrvr::~MgmtSrvr()
int MgmtSrvr::okToSendTo(NodeId processId, bool unCond)
{
+ if(processId == 0)
+ return 0;
+
if (getNodeType(processId) != NDB_MGM_NODE_TYPE_NDB)
return WRONG_PROCESS_TYPE;
@@ -1020,36 +1026,38 @@ int
MgmtSrvr::versionNode(int processId, bool abort,
VersionCallback callback, void * anyData)
{
+ int version;
+
if(m_versionRec.inUse)
return OPERATION_IN_PROGRESS;
m_versionRec.callback = callback;
m_versionRec.inUse = true ;
- ClusterMgr::Node node;
- int version;
- if (getNodeType(processId) == NDB_MGM_NODE_TYPE_MGM) {
- if(m_versionRec.callback != 0)
- m_versionRec.callback(processId, NDB_VERSION, this,0);
- }
- if (getNodeType(processId) == NDB_MGM_NODE_TYPE_NDB) {
- node = theFacade->theClusterMgr->getNodeInfo(processId);
- version = node.m_info.m_version;
- if(theFacade->theClusterMgr->getNodeInfo(processId).connected)
- if(m_versionRec.callback != 0)
- m_versionRec.callback(processId, version, this,0);
- else
- if(m_versionRec.callback != 0)
- m_versionRec.callback(processId, 0, this,0);
-
+ if (getOwnNodeId() == processId)
+ {
+ version= NDB_VERSION;
}
-
- if (getNodeType(processId) == NDB_MGM_NODE_TYPE_API) {
+ else if (getNodeType(processId) == NDB_MGM_NODE_TYPE_NDB)
+ {
+ ClusterMgr::Node node= theFacade->theClusterMgr->getNodeInfo(processId);
+ if(node.connected)
+ version= node.m_info.m_version;
+ else
+ version= 0;
+ }
+ else if (getNodeType(processId) == NDB_MGM_NODE_TYPE_API ||
+ getNodeType(processId) == NDB_MGM_NODE_TYPE_MGM)
+ {
return sendVersionReq(processId);
}
+ if(m_versionRec.callback != 0)
+ m_versionRec.callback(processId, version, this,0);
m_versionRec.inUse = false ;
- return 0;
+ m_versionRec.version[processId]= version;
+
+ return 0;
}
int
@@ -1460,17 +1468,14 @@ MgmtSrvr::status(int processId,
Uint32 * nodegroup,
Uint32 * connectCount)
{
- if (getNodeType(processId) == NDB_MGM_NODE_TYPE_API) {
+ if (getNodeType(processId) == NDB_MGM_NODE_TYPE_API ||
+ getNodeType(processId) == NDB_MGM_NODE_TYPE_MGM) {
if(versionNode(processId, false,0,0) ==0)
* version = m_versionRec.version[processId];
else
* version = 0;
}
- if (getNodeType(processId) == NDB_MGM_NODE_TYPE_MGM) {
- * version = NDB_VERSION;
- }
-
const ClusterMgr::Node node =
theFacade->theClusterMgr->getNodeInfo(processId);
@@ -1540,175 +1545,72 @@ MgmtSrvr::status(int processId,
return -1;
}
-
-
-//****************************************************************************
-//****************************************************************************
-int
-MgmtSrvr::startStatisticEventReporting(int level)
-{
- SetLogLevelOrd ll;
- NodeId nodeId = 0;
-
- ll.clear();
- ll.setLogLevel(LogLevel::llStatistic, level);
-
- if (level > 0) {
- _isStatPortActive = true;
- } else {
- _isStatPortActive = false;
-
- if (_isClusterLogStatActive) {
- return 0;
- }
- }
-
- while (getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_NDB)) {
- setEventReportingLevelImpl(nodeId, ll);
- }
-
- return 0;
-}
-
-int
-MgmtSrvr::setEventReportingLevel(int processId, const SetLogLevelOrd & ll,
- bool isResend)
-{
- for (Uint32 i = 0; i < ll.noOfEntries; i++) {
- if (ll.theCategories[i] == LogLevel::llStatistic) {
- if (ll.theLevels[i] > 0) {
- _isClusterLogStatActive = true;
- break;
- } else {
- _isClusterLogStatActive = false;
-
- if (_isStatPortActive) {
- return 0;
- }
- break;
- }
- } // if (ll.theCategories
- } // for (int i = 0
-
- return setEventReportingLevelImpl(processId, ll, isResend);
-}
int
MgmtSrvr::setEventReportingLevelImpl(int processId,
- const SetLogLevelOrd & ll,
- bool isResend)
+ const EventSubscribeReq& ll)
{
- Uint32 i;
- for(i = 0; i<ll.noOfEntries; i++){
- // Save log level for the cluster log
- if (!isResend) {
- NodeLogLevel* n = NULL;
- bool found = false;
- while ((n = _clusterLogLevelList->next()) != NULL) {
- if (n->getNodeId() == processId &&
- n->getCategory() == ll.theCategories[i]) {
-
- n->setLevel(ll.theLevels[i]);
- found = true;
- }
- }
- if (!found) {
- _clusterLogLevelList->add(new NodeLogLevel(processId, ll));
- }
- }
- }
-
+
int result = okToSendTo(processId, true);
if (result != 0) {
return result;
}
- NdbApiSignal* signal = getSignal();
- if (signal == NULL) {
- return COULD_NOT_ALLOCATE_MEMORY;
- }
+ NdbApiSignal signal(_ownReference);
EventSubscribeReq * dst =
- CAST_PTR(EventSubscribeReq, signal->getDataPtrSend());
- for(i = 0; i<ll.noOfEntries; i++){
- dst->theCategories[i] = ll.theCategories[i];
- dst->theLevels[i] = ll.theLevels[i];
- }
-
- dst->noOfEntries = ll.noOfEntries;
- dst->blockRef = _ownReference;
+ CAST_PTR(EventSubscribeReq, signal.getDataPtrSend());
- signal->set(TestOrd::TraceAPI, CMVMI, GSN_EVENT_SUBSCRIBE_REQ,
- EventSubscribeReq::SignalLength);
+ * dst = ll;
+
+ signal.set(TestOrd::TraceAPI, CMVMI, GSN_EVENT_SUBSCRIBE_REQ,
+ EventSubscribeReq::SignalLength);
+
+ theFacade->lock_mutex();
+ send(&signal, processId, NODE_TYPE_DB);
+ theFacade->unlock_mutex();
- result = sendSignal(processId, WAIT_SUBSCRIBE_CONF, signal, true);
- if (result == -1) {
- return SEND_OR_RECEIVE_FAILED;
- }
- else {
- // Increment the conf counter
- theConfCount++;
- }
-
return 0;
}
//****************************************************************************
//****************************************************************************
int
-MgmtSrvr::setNodeLogLevel(int processId, const SetLogLevelOrd & ll,
- bool isResend)
+MgmtSrvr::setNodeLogLevelImpl(int processId, const SetLogLevelOrd & ll)
{
- Uint32 i;
- for(i = 0; i<ll.noOfEntries; i++){
- // Save log level for the cluster log
- if (!isResend) {
- NodeLogLevel* n = NULL;
- bool found = false;
- while ((n = _clusterLogLevelList->next()) != NULL) {
- if (n->getNodeId() == processId &&
- n->getCategory() == ll.theCategories[i]) {
-
- n->setLevel(ll.theLevels[i]);
- found = true;
- }
- }
- if (!found) {
- _clusterLogLevelList->add(new NodeLogLevel(processId, ll));
- }
- }
- }
-
int result = okToSendTo(processId, true);
if (result != 0) {
return result;
}
- NdbApiSignal* signal = getSignal();
- if (signal == NULL) {
- return COULD_NOT_ALLOCATE_MEMORY;
- }
-
- SetLogLevelOrd * dst = CAST_PTR(SetLogLevelOrd, signal->getDataPtrSend());
-
- for(i = 0; i<ll.noOfEntries; i++){
- dst->theCategories[i] = ll.theCategories[i];
- dst->theLevels[i] = ll.theLevels[i];
- }
+ NdbApiSignal signal(_ownReference);
- dst->noOfEntries = ll.noOfEntries;
+ SetLogLevelOrd * dst = CAST_PTR(SetLogLevelOrd, signal.getDataPtrSend());
- signal->set(TestOrd::TraceAPI, CMVMI, GSN_SET_LOGLEVELORD,
- SetLogLevelOrd::SignalLength);
-
- result = sendSignal(processId, NO_WAIT, signal, true);
- if (result == -1) {
- return SEND_OR_RECEIVE_FAILED;
- }
+ * dst = ll;
+
+ signal.set(TestOrd::TraceAPI, CMVMI, GSN_SET_LOGLEVELORD,
+ SetLogLevelOrd::SignalLength);
+
+ theFacade->lock_mutex();
+ theFacade->sendSignalUnCond(&signal, processId);
+ theFacade->unlock_mutex();
return 0;
}
+int
+MgmtSrvr::send(NdbApiSignal* signal, Uint32 node, Uint32 node_type){
+ Uint32 max = (node == 0) ? MAX_NODES : node + 1;
+
+ for(; node < max; node++){
+ while(nodeTypes[node] != node_type && node < max) node++;
+ if(nodeTypes[node] != node_type)
+ break;
+ theFacade->sendSignalUnCond(signal, node);
+ }
+ return 0;
+}
//****************************************************************************
//****************************************************************************
@@ -2003,7 +1905,7 @@ const char* MgmtSrvr::getErrorText(int errorCode)
for (int i = 0; i < noOfErrorCodes; ++i) {
if (errorCode == errorTable[i]._errorCode) {
- return errorTable[i]._errorText.c_str();
+ return errorTable[i]._errorText;
}
}
@@ -2011,21 +1913,6 @@ const char* MgmtSrvr::getErrorText(int errorCode)
return text;
}
-/*****************************************************************************
- * Handle reception of various signals
- *****************************************************************************/
-
-int
-MgmtSrvr::handleSTATISTICS_CONF(NdbApiSignal* signal)
-{
- //ndbout << "MgmtSrvr::handleSTATISTICS_CONF" << endl;
-
- int x = signal->readData(1);
- //ndbout << "MgmtSrvr::handleSTATISTICS_CONF, x: " << x << endl;
- _statistics._test1 = x;
- return 0;
-}
-
void
MgmtSrvr::handleReceivedSignal(NdbApiSignal* signal)
{
@@ -2049,51 +1936,7 @@ MgmtSrvr::handleReceivedSignal(NdbApiSignal* signal)
}
break;
- case GSN_STATISTICS_CONF:
- if (theWaitState != WAIT_STATISTICS) {
- g_EventLogger.warning("MgmtSrvr::handleReceivedSignal, unexpected "
- "signal received, gsn %d, theWaitState = %d",
- gsn, theWaitState);
-
- return;
- }
- returnCode = handleSTATISTICS_CONF(signal);
- if (returnCode != -1) {
- theWaitState = NO_WAIT;
- }
- break;
-
-
- case GSN_SET_VAR_CONF:
- if (theWaitState != WAIT_SET_VAR) {
- g_EventLogger.warning("MgmtSrvr::handleReceivedSignal, unexpected "
- "signal received, gsn %d, theWaitState = %d",
- gsn, theWaitState);
- return;
- }
- theWaitState = NO_WAIT;
- _setVarReqResult = 0;
- break;
-
- case GSN_SET_VAR_REF:
- if (theWaitState != WAIT_SET_VAR) {
- g_EventLogger.warning("MgmtSrvr::handleReceivedSignal, unexpected "
- "signal received, gsn %d, theWaitState = %d",
- gsn, theWaitState);
- return;
- }
- theWaitState = NO_WAIT;
- _setVarReqResult = -1;
- break;
-
case GSN_EVENT_SUBSCRIBE_CONF:
- theConfCount--; // OK, we've received a conf message
- if (theConfCount < 0) {
- g_EventLogger.warning("MgmtSrvr::handleReceivedSignal, unexpected "
- "signal received, gsn %d, theWaitState = %d",
- gsn, theWaitState);
- theConfCount = 0;
- }
break;
case GSN_EVENT_REP:
@@ -2276,20 +2119,19 @@ void
MgmtSrvr::handleStatus(NodeId nodeId, bool alive)
{
if (alive) {
- _startedNodeId = nodeId; // Used by logLevelThreadRun()
+ m_started_nodes.push_back(nodeId);
Uint32 theData[25];
theData[0] = EventReport::Connected;
theData[1] = nodeId;
+ eventReport(_ownNodeId, theData);
} else {
handleStopReply(nodeId, 0);
- theConfCount++; // Increment the event subscr conf count because
-
+
Uint32 theData[25];
theData[0] = EventReport::Disconnected;
theData[1] = nodeId;
-
+
eventReport(_ownNodeId, theData);
- g_EventLogger.info("Lost connection to node %d", nodeId);
}
}
@@ -2337,32 +2179,42 @@ MgmtSrvr::alloc_node_id(NodeId * nodeId,
SOCKET_SIZE_TYPE *client_addr_len,
BaseString &error_string)
{
+ DBUG_ENTER("MgmtSrvr::alloc_node_id");
+ DBUG_PRINT("enter", ("nodeid=%d, type=%d, client_addr=%d",
+ *nodeId, type, client_addr));
+ if (g_no_nodeid_checks) {
+ if (*nodeId == 0) {
+ error_string.appfmt("no-nodeid-ckecks set in manegment server.\n"
+ "node id must be set explicitly in connectstring");
+ DBUG_RETURN(false);
+ }
+ DBUG_RETURN(true);
+ }
Guard g(&f_node_id_mutex);
-#if 0
- ndbout << "MgmtSrvr::getFreeNodeId type=" << type
- << " *nodeid=" << *nodeId << endl;
-#endif
-
+ int no_mgm= 0;
NodeBitmask connected_nodes(m_reserved_nodes);
- if (theFacade && theFacade->theClusterMgr) {
- for(Uint32 i = 0; i < MAX_NODES; i++)
- if (getNodeType(i) == NDB_MGM_NODE_TYPE_NDB) {
- const ClusterMgr::Node &node= theFacade->theClusterMgr->getNodeInfo(i);
- if (node.connected)
- connected_nodes.bitOR(node.m_state.m_connected_nodes);
+ for(Uint32 i = 0; i < MAX_NODES; i++)
+ {
+ if (getNodeType(i) == NDB_MGM_NODE_TYPE_NDB &&
+ theFacade && theFacade->theClusterMgr) {
+ const ClusterMgr::Node &node= theFacade->theClusterMgr->getNodeInfo(i);
+ if (node.connected) {
+ connected_nodes.bitOR(node.m_state.m_connected_nodes);
}
+ } else if (getNodeType(i) == NDB_MGM_NODE_TYPE_MGM)
+ no_mgm++;
}
-
bool found_matching_id= false;
bool found_matching_type= false;
bool found_free_node= false;
- const char *config_hostname = 0;
+ unsigned id_found= 0;
+ const char *config_hostname= 0;
struct in_addr config_addr= {0};
int r_config_addr= -1;
unsigned type_c= 0;
- ndb_mgm_configuration_iterator iter(*(ndb_mgm_configuration *)_config->m_configValues,
- CFG_SECTION_NODE);
+ ndb_mgm_configuration_iterator
+ iter(*(ndb_mgm_configuration *)_config->m_configValues, CFG_SECTION_NODE);
for(iter.first(); iter.valid(); iter.next()) {
unsigned tmp= 0;
if(iter.get(CFG_NODE_ID, &tmp)) abort();
@@ -2370,15 +2222,16 @@ MgmtSrvr::alloc_node_id(NodeId * nodeId,
continue;
found_matching_id= true;
if(iter.get(CFG_TYPE_OF_SECTION, &type_c)) abort();
- if(type_c != type)
+ if(type_c != (unsigned)type)
continue;
found_matching_type= true;
if (connected_nodes.get(tmp))
continue;
found_free_node= true;
if(iter.get(CFG_NODE_HOST, &config_hostname)) abort();
-
- if (config_hostname && config_hostname[0] != 0 && client_addr) {
+ if (config_hostname && config_hostname[0] == 0)
+ config_hostname= 0;
+ else if (client_addr) {
// check hostname compatability
const void *tmp_in= &(((sockaddr_in*)client_addr)->sin_addr);
if((r_config_addr= Ndb_getInAddr(&config_addr, config_hostname)) != 0
@@ -2388,8 +2241,9 @@ MgmtSrvr::alloc_node_id(NodeId * nodeId,
|| memcmp(&tmp_addr, tmp_in, sizeof(config_addr)) != 0) {
// not localhost
#if 0
- ndbout << "MgmtSrvr::getFreeNodeId compare failed for \"" << config_hostname
- << "\" id=" << tmp << endl;
+ ndbout << "MgmtSrvr::getFreeNodeId compare failed for \""
+ << config_hostname
+ << "\" id=" << tmp << endl;
#endif
continue;
}
@@ -2405,22 +2259,59 @@ MgmtSrvr::alloc_node_id(NodeId * nodeId,
}
}
}
- *nodeId= tmp;
- if (client_addr)
- m_connect_address[tmp]= ((struct sockaddr_in *)client_addr)->sin_addr;
- else
- Ndb_getInAddr(&(m_connect_address[tmp]), "localhost");
- m_reserved_nodes.set(tmp);
-#if 0
- ndbout << "MgmtSrvr::getFreeNodeId found type=" << type
- << " *nodeid=" << *nodeId << endl;
-#endif
- return true;
+ if (*nodeId != 0 ||
+ type != NDB_MGM_NODE_TYPE_MGM ||
+ no_mgm == 1) { // any match is ok
+ id_found= tmp;
+ break;
+ }
+ if (id_found) { // mgmt server may only have one match
+ error_string.appfmt("Ambiguous node id's %d and %d.\n"
+ "Suggest specifying node id in connectstring,\n"
+ "or specifying unique host names in config file.",
+ id_found, tmp);
+ DBUG_RETURN(false);
+ }
+ if (config_hostname == 0) {
+ error_string.appfmt("Ambiguity for node id %d.\n"
+ "Suggest specifying node id in connectstring,\n"
+ "or specifying unique host names in config file,\n"
+ "or specifying just one mgmt server in config file.",
+ tmp);
+ DBUG_RETURN(false);
+ }
+ id_found= tmp; // mgmt server matched, check for more matches
+ }
+
+ if (id_found)
+ {
+ *nodeId= id_found;
+ DBUG_PRINT("info", ("allocating node id %d",*nodeId));
+ {
+ int r= 0;
+ if (client_addr)
+ m_connect_address[id_found]=
+ ((struct sockaddr_in *)client_addr)->sin_addr;
+ else if (config_hostname)
+ r= Ndb_getInAddr(&(m_connect_address[id_found]), config_hostname);
+ else {
+ char name[256];
+ r= gethostname(name, sizeof(name));
+ if (r == 0) {
+ name[sizeof(name)-1]= 0;
+ r= Ndb_getInAddr(&(m_connect_address[id_found]), name);
+ }
+ }
+ if (r)
+ m_connect_address[id_found].s_addr= 0;
+ }
+ m_reserved_nodes.set(id_found);
+ DBUG_RETURN(true);
}
if (found_matching_type && !found_free_node) {
- // we have a temporary error which might be due to that we have got the latest
- // connect status from db-nodes. Force update.
+ // we have a temporary error which might be due to that
+ // we have got the latest connect status from db-nodes. Force update.
global_flag_send_heartbeat_now= 1;
}
@@ -2429,7 +2320,8 @@ MgmtSrvr::alloc_node_id(NodeId * nodeId,
const char *alias, *str;
alias= ndb_mgm_get_node_type_alias_string(type, &str);
type_string.assfmt("%s(%s)", alias, str);
- alias= ndb_mgm_get_node_type_alias_string((enum ndb_mgm_node_type)type_c, &str);
+ alias= ndb_mgm_get_node_type_alias_string((enum ndb_mgm_node_type)type_c,
+ &str);
type_c_string.assfmt("%s(%s)", alias, str);
}
@@ -2440,9 +2332,11 @@ MgmtSrvr::alloc_node_id(NodeId * nodeId,
error_string.appfmt("Connection done from wrong host ip %s.",
inet_ntoa(((struct sockaddr_in *)(client_addr))->sin_addr));
else
- error_string.appfmt("No free node id found for %s.", type_string.c_str());
+ error_string.appfmt("No free node id found for %s.",
+ type_string.c_str());
else
- error_string.appfmt("No %s node defined in config file.", type_string.c_str());
+ error_string.appfmt("No %s node defined in config file.",
+ type_string.c_str());
else
error_string.append("No nodes defined in config file.");
} else {
@@ -2451,19 +2345,23 @@ MgmtSrvr::alloc_node_id(NodeId * nodeId,
if (found_free_node) {
// have to split these into two since inet_ntoa overwrites itself
error_string.appfmt("Connection with id %d done from wrong host ip %s,",
- *nodeId, inet_ntoa(((struct sockaddr_in *)(client_addr))->sin_addr));
+ *nodeId, inet_ntoa(((struct sockaddr_in *)
+ (client_addr))->sin_addr));
error_string.appfmt(" expected %s(%s).", config_hostname,
- r_config_addr ? "lookup failed" : inet_ntoa(config_addr));
+ r_config_addr ?
+ "lookup failed" : inet_ntoa(config_addr));
} else
- error_string.appfmt("Id %d already allocated by another node.", *nodeId);
+ error_string.appfmt("Id %d already allocated by another node.",
+ *nodeId);
else
error_string.appfmt("Id %d configured as %s, connect attempted as %s.",
- *nodeId, type_c_string.c_str(), type_string.c_str());
+ *nodeId, type_c_string.c_str(),
+ type_string.c_str());
else
- error_string.appfmt("No node defined with id=%d in config file.", *nodeId);
+ error_string.appfmt("No node defined with id=%d in config file.",
+ *nodeId);
}
-
- return false;
+ DBUG_RETURN(false);
}
bool
@@ -2483,77 +2381,18 @@ MgmtSrvr::getNextNodeId(NodeId * nodeId, enum ndb_mgm_node_type type) const
return true;
}
+#include "Services.hpp"
+
void
MgmtSrvr::eventReport(NodeId nodeId, const Uint32 * theData)
{
const EventReport * const eventReport = (EventReport *)&theData[0];
-
+
EventReport::EventType type = eventReport->getEventType();
- if (type == EventReport::TransReportCounters ||
- type == EventReport::OperationReportCounters) {
-
- if (_isClusterLogStatActive) {
- g_EventLogger.log(type, theData, nodeId);
- }
-
- if (_isStatPortActive) {
- char theTime[128];
- struct tm* tm_now;
- time_t now;
- now = time((time_t*)NULL);
-#ifdef NDB_WIN32
- tm_now = localtime(&now);
-#else
- tm_now = gmtime(&now);
-#endif
-
- snprintf(theTime, sizeof(theTime),
- STATISTIC_DATE,
- tm_now->tm_year + 1900,
- tm_now->tm_mon,
- tm_now->tm_mday,
- tm_now->tm_hour,
- tm_now->tm_min,
- tm_now->tm_sec);
-
- char str[255];
-
- if (type == EventReport::TransReportCounters) {
- snprintf(str, sizeof(str),
- STATISTIC_LINE,
- theTime,
- (int)now,
- nodeId,
- theData[1],
- theData[2],
- theData[3],
- // theData[4], simple reads
- theData[5],
- theData[6],
- theData[7],
- theData[8]);
- } else if (type == EventReport::OperationReportCounters) {
- snprintf(str, sizeof(str),
- OP_STATISTIC_LINE,
- theTime,
- (int)now,
- nodeId,
- theData[1]);
- }
-
- if(m_statisticsListner != 0){
- m_statisticsListner->println_statistics(str);
- }
- }
-
- return;
-
- } // if (type ==
-
// Log event
g_EventLogger.log(type, theData, nodeId);
-
+ m_statisticsListner.log(type, theData, nodeId);
}
/***************************************************************************
@@ -2957,15 +2796,15 @@ MgmtSrvr::setDbParameter(int node, int param, const char * value,
switch(p_type){
case 0:
res = i2.set(param, val_32);
- ndbout_c("Updateing node %d param: %d to %d", node, param, val_32);
+ ndbout_c("Updating node %d param: %d to %d", node, param, val_32);
break;
case 1:
res = i2.set(param, val_64);
- ndbout_c("Updateing node %d param: %d to %Ld", node, param, val_32);
+ ndbout_c("Updating node %d param: %d to %Ld", node, param, val_32);
break;
case 2:
res = i2.set(param, val_char);
- ndbout_c("Updateing node %d param: %d to %s", node, param, val_char);
+ ndbout_c("Updating node %d param: %d to %s", node, param, val_char);
break;
default:
abort();
@@ -2981,3 +2820,7 @@ template class Vector<SigMatch>;
#if __SUNPRO_CC != 0x560
template bool SignalQueue::waitFor<SigMatch>(Vector<SigMatch>&, SigMatch*&, NdbApiSignal*&, unsigned);
#endif
+
+template class MutexVector<unsigned short>;
+template class MutexVector<MgmStatService::StatListener>;
+template class MutexVector<EventSubscribeReq>;
diff --git a/ndb/src/mgmsrv/MgmtSrvr.hpp b/ndb/src/mgmsrv/MgmtSrvr.hpp
index d7f9f7a1af3..5de39932bf4 100644
--- a/ndb/src/mgmsrv/MgmtSrvr.hpp
+++ b/ndb/src/mgmsrv/MgmtSrvr.hpp
@@ -28,8 +28,8 @@
#include <signaldata/ManagementServer.hpp>
#include "SignalQueue.hpp"
#include <ndb_version.h>
-
-#include "NodeLogLevelList.hpp"
+#include <EventLogger.hpp>
+#include <signaldata/EventSubscribeReq.hpp>
/**
* @desc Block number for Management server.
@@ -43,6 +43,29 @@ class Config;
class SetLogLevelOrd;
class SocketServer;
+class MgmStatService : public EventLoggerBase
+{
+ friend class MgmtSrvr;
+public:
+ struct StatListener : public EventLoggerBase {
+ NDB_SOCKET_TYPE m_socket;
+ };
+
+private:
+ class MgmtSrvr * m_mgmsrv;
+ MutexVector<StatListener> m_clients;
+public:
+ MgmStatService(class MgmtSrvr * m) : m_clients(5) {
+ m_mgmsrv = m;
+ }
+
+ void add_listener(const StatListener&);
+
+ void log(int eventType, const Uint32* theData, NodeId nodeId);
+
+ void stopSessions();
+};
+
/**
* @class MgmtSrvr
* @brief Main class for the management server.
@@ -63,11 +86,6 @@ class SocketServer;
class MgmtSrvr {
public:
- class StatisticsListner {
- public:
- virtual void println_statistics(const BaseString &s) = 0;
- };
-
// some compilers need all of this
class Allocated_resources;
friend class Allocated_resources;
@@ -85,11 +103,6 @@ public:
};
/**
- * Set a reference to the socket server.
- */
- void setStatisticsListner(StatisticsListner* listner);
-
- /**
* Start/initate the event log.
*/
void startEventLog();
@@ -151,15 +164,6 @@ public:
STATIC_CONST( NO_CONTACT_WITH_DB_NODES = 5030 );
/**
- * This class holds all statistical variables fetched with
- * the getStatistics methods.
- */
- class Statistics { // TODO, Real statistic data to be added
- public:
- int _test1;
- };
-
- /**
* This enum specifies the different signal loggig modes possible to set
* with the setSignalLoggingMode method.
*/
@@ -206,7 +210,7 @@ public:
typedef void (* EnterSingleCallback)(int nodeId, void * anyData,
int errorCode);
typedef void (* ExitSingleCallback)(int nodeId, void * anyData,
- int errorCode);
+ int errorCode);
/**
* Lock configuration
@@ -313,13 +317,6 @@ public:
bool abort = false,
int * stopCount = 0, StopCallback = 0, void * anyData = 0);
- int setEventReportingLevel(int processId,
- const class SetLogLevelOrd & logLevel,
- bool isResend = false);
-
- int startStatisticEventReporting(int level = 5);
-
-
struct BackupEvent {
enum Event {
BackupStarted = 1,
@@ -377,22 +374,8 @@ public:
// INVALID_LEVEL
//**************************************************************************
- /**
- * Sets the Node's log level, i.e., its local event reporting.
- *
- * @param processId the DB node id.
- * @param logLevel the log level.
- * @param isResend Flag to indicate for resending log levels
- * during node restart
-
- * @return 0 if successful or NO_CONTACT_WITH_PROCESS,
- * SEND_OR_RECEIVE_FAILED,
- * COULD_NOT_ALLOCATE_MEMORY
- */
- int setNodeLogLevel(int processId,
- const class SetLogLevelOrd & logLevel,
- bool isResend = false);
-
+ int setEventReportingLevelImpl(int processId, const EventSubscribeReq& ll);
+ int setNodeLogLevelImpl(int processId, const SetLogLevelOrd & ll);
/**
* Insert an error in a DB process.
@@ -509,11 +492,6 @@ public:
NodeId getPrimaryNode() const;
/**
- * Returns the statistics port number.
- * @return statistic port number.
- */
- int getStatPort() const;
- /**
* Returns the port number.
* @return port number.
*/
@@ -526,10 +504,7 @@ public:
private:
//**************************************************************************
- int setEventReportingLevelImpl(int processId,
- const class SetLogLevelOrd & logLevel,
- bool isResend = false);
-
+ int setEventReportingLevel(int processId, LogLevel::EventCategory, Uint32);
/**
* Check if it is possible to send a signal to a (DB) process
@@ -563,10 +538,6 @@ private:
Allocated_resources m_allocated_resources;
struct in_addr m_connect_address[MAX_NODES];
- int _setVarReqResult; // The result of the SET_VAR_REQ response
- Statistics _statistics; // handleSTATISTICS_CONF store the result here,
- // and getStatistics reads it.
-
//**************************************************************************
// Specific signal handling methods
//**************************************************************************
@@ -598,14 +569,6 @@ private:
// Returns: -
//**************************************************************************
- int handleSTATISTICS_CONF(NdbApiSignal* signal);
- //**************************************************************************
- // Description: Handle reception of signal STATISTICS_CONF
- // Parameters:
- // signal: The recieved signal
- // Returns: TODO, to be defined
- //**************************************************************************
-
void handle_MGM_LOCK_CONFIG_REQ(NdbApiSignal *signal);
void handle_MGM_UNLOCK_CONFIG_REQ(NdbApiSignal *signal);
@@ -631,7 +594,6 @@ private:
*/
enum WaitSignalType {
NO_WAIT, // We don't expect to receive any signal
- WAIT_STATISTICS, // Accept STATISTICS_CONF
WAIT_SET_VAR, // Accept SET_VAR_CONF and SET_VAR_REF
WAIT_SUBSCRIBE_CONF, // Accept event subscription confirmation
WAIT_STOP,
@@ -733,14 +695,6 @@ private:
class SignalQueue m_signalRecvQueue;
- enum ndb_mgm_node_type nodeTypes[MAX_NODES];
-
- int theConfCount; // The number of expected conf signals
-
- StatisticsListner * m_statisticsListner; // Used for sending statistics info
- bool _isStatPortActive;
- bool _isClusterLogStatActive;
-
struct StopRecord {
StopRecord(){ inUse = false; callback = 0; singleUserMode = false;}
bool inUse;
@@ -765,10 +719,16 @@ private:
void handleStopReply(NodeId nodeId, Uint32 errCode);
int translateStopRef(Uint32 errCode);
-
+
bool _isStopThread;
int _logLevelThreadSleep;
- int _startedNodeId;
+ MutexVector<NodeId> m_started_nodes;
+ MutexVector<EventSubscribeReq> m_log_level_requests;
+ LogLevel m_nodeLogLevel[MAX_NODES];
+ enum ndb_mgm_node_type nodeTypes[MAX_NODES];
+ friend class MgmApiSession;
+ friend class MgmStatService;
+ MgmStatService m_statisticsListner;
/**
* Handles the thread wich upon a 'Node is started' event will
@@ -782,15 +742,13 @@ private:
static void *signalRecvThread_C(void *);
void signalRecvThreadRun();
- NodeLogLevelList* _nodeLogLevelList;
- NodeLogLevelList* _clusterLogLevelList;
-
void backupCallback(BackupEvent &);
BackupCallback m_backupCallback;
BackupEvent m_lastBackupEvent;
Config *_props;
+ int send(class NdbApiSignal* signal, Uint32 node, Uint32 node_type);
public:
/**
* This method does not exist
diff --git a/ndb/src/mgmsrv/NodeLogLevel.cpp b/ndb/src/mgmsrv/NodeLogLevel.cpp
deleted file mode 100644
index 5271cdb0f2b..00000000000
--- a/ndb/src/mgmsrv/NodeLogLevel.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/* Copyright (C) 2003 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#include "NodeLogLevel.hpp"
-// TODO_RONM: Clearly getCategory and getLevel is not correctly coded. Must be taken care of.
-
-NodeLogLevel::NodeLogLevel(int nodeId, const SetLogLevelOrd& ll)
-{
- m_nodeId = nodeId;
- m_logLevel = ll;
-}
-
-NodeLogLevel::~NodeLogLevel()
-{
-}
-
-int
-NodeLogLevel::getNodeId() const
-{
- return m_nodeId;
-}
-
-Uint32
-NodeLogLevel::getCategory() const
-{
- for (Uint32 i = 0; i < m_logLevel.noOfEntries; i++)
- {
- return m_logLevel.theCategories[i];
- }
- return 0;
-}
-
-int
-NodeLogLevel::getLevel() const
-{
- for (Uint32 i = 0; i < m_logLevel.noOfEntries; i++)
- {
- return m_logLevel.theLevels[i];
- }
- return 0;
-}
-
-void
-NodeLogLevel::setLevel(int level)
-{
- for (Uint32 i = 0; i < m_logLevel.noOfEntries; i++)
- {
- m_logLevel.theLevels[i] = level;
- }
-
-}
-
-SetLogLevelOrd
-NodeLogLevel::getLogLevelOrd() const
-{
- return m_logLevel;
-}
diff --git a/ndb/src/mgmsrv/NodeLogLevel.hpp b/ndb/src/mgmsrv/NodeLogLevel.hpp
deleted file mode 100644
index 3ad758cde99..00000000000
--- a/ndb/src/mgmsrv/NodeLogLevel.hpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (C) 2003 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#ifndef NODELOGLEVEL_H
-#define NODELOGLEVEL_H
-
-#include <ndb_global.h>
-
-#include <signaldata/SetLogLevelOrd.hpp>
-
-/**
- * Holds a DB node's log level settings for both local and event log levels.
- * It only holds one log level setting even though SetLogLevelOrd can handle
- * multiple log levels at once, it is not used in that way in the managment
- * server.
- *
- * @version #@ $Id: NodeLogLevel.hpp,v 1.2 2003/07/05 17:40:22 elathal Exp $
- */
-class NodeLogLevel
-{
-public:
- NodeLogLevel(int nodeId, const SetLogLevelOrd& ll);
- ~NodeLogLevel();
-
- int getNodeId() const;
- Uint32 getCategory() const;
- int getLevel() const;
- void setLevel(int level);
- SetLogLevelOrd getLogLevelOrd() const;
-
-private:
- NodeLogLevel();
- NodeLogLevel(const NodeLogLevel&);
- bool operator == (const NodeLogLevel&);
- NodeLogLevel operator = (const NodeLogLevel&);
-
- int m_nodeId;
- SetLogLevelOrd m_logLevel;
-};
-
-#endif
diff --git a/ndb/src/mgmsrv/NodeLogLevelList.cpp b/ndb/src/mgmsrv/NodeLogLevelList.cpp
deleted file mode 100644
index 6c7c091c1a8..00000000000
--- a/ndb/src/mgmsrv/NodeLogLevelList.cpp
+++ /dev/null
@@ -1,182 +0,0 @@
-/* Copyright (C) 2003 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#include <ndb_global.h>
-
-#include "NodeLogLevelList.hpp"
-#include "NodeLogLevel.hpp"
-
-//
-// PUBLIC
-//
-
-NodeLogLevelList::NodeLogLevelList() :
- m_size(0),
- m_pHeadNode(NULL),
- m_pTailNode(NULL),
- m_pCurrNode(NULL)
-{
-}
-
-NodeLogLevelList::~NodeLogLevelList()
-{
- removeAll();
-}
-
-void
-NodeLogLevelList::add(NodeLogLevel* pNewNode)
-{
- NodeLogLevelNode* pNode = new NodeLogLevelNode();
-
- if (m_pHeadNode == NULL)
- {
- m_pHeadNode = pNode;
- pNode->pPrev = NULL;
- }
- else
- {
- m_pTailNode->pNext = pNode;
- pNode->pPrev = m_pTailNode;
- }
- m_pTailNode = pNode;
- pNode->pNext = NULL;
- pNode->pHandler = pNewNode;
-
- m_size++;
-}
-
-bool
-NodeLogLevelList::remove(NodeLogLevel* pRemoveNode)
-{
- NodeLogLevelNode* pNode = m_pHeadNode;
- bool removed = false;
- do
- {
- if (pNode->pHandler == pRemoveNode)
- {
- removeNode(pNode);
- removed = true;
- break;
- }
- } while ( (pNode = next(pNode)) != NULL);
-
- return removed;
-}
-
-void
-NodeLogLevelList::removeAll()
-{
- while (m_pHeadNode != NULL)
- {
- removeNode(m_pHeadNode);
- }
-}
-
-NodeLogLevel*
-NodeLogLevelList::next()
-{
- NodeLogLevel* pHandler = NULL;
- if (m_pCurrNode == NULL)
- {
- m_pCurrNode = m_pHeadNode;
- if (m_pCurrNode != NULL)
- {
- pHandler = m_pCurrNode->pHandler;
- }
- }
- else
- {
- m_pCurrNode = next(m_pCurrNode); // Next node
- if (m_pCurrNode != NULL)
- {
- pHandler = m_pCurrNode->pHandler;
- }
- }
-
- return pHandler;
-}
-
-int
-NodeLogLevelList::size() const
-{
- return m_size;
-}
-
-//
-// PRIVATE
-//
-
-NodeLogLevelList::NodeLogLevelNode*
-NodeLogLevelList::next(NodeLogLevelNode* pNode)
-{
- NodeLogLevelNode* pCurr = pNode;
- if (pNode->pNext != NULL)
- {
- pCurr = pNode->pNext;
- }
- else
- {
- // Tail
- pCurr = NULL;
- }
- return pCurr;
-}
-
-NodeLogLevelList::NodeLogLevelNode*
-NodeLogLevelList::prev(NodeLogLevelNode* pNode)
-{
- NodeLogLevelNode* pCurr = pNode;
- if (pNode->pPrev != NULL) // head
- {
- pCurr = pNode->pPrev;
- }
- else
- {
- // Head
- pCurr = NULL;
- }
-
- return pCurr;
-}
-
-void
-NodeLogLevelList::removeNode(NodeLogLevelNode* pNode)
-{
- if (pNode->pPrev == NULL) // If head
- {
- m_pHeadNode = pNode->pNext;
- }
- else
- {
- pNode->pPrev->pNext = pNode->pNext;
- }
-
- if (pNode->pNext == NULL) // if tail
- {
- m_pTailNode = pNode->pPrev;
- }
- else
- {
- pNode->pNext->pPrev = pNode->pPrev;
- }
-
- pNode->pNext = NULL;
- pNode->pPrev = NULL;
- delete pNode->pHandler; // Delete log handler
- delete pNode;
-
- m_size--;
-}
diff --git a/ndb/src/mgmsrv/NodeLogLevelList.hpp b/ndb/src/mgmsrv/NodeLogLevelList.hpp
deleted file mode 100644
index 4a55ee211e2..00000000000
--- a/ndb/src/mgmsrv/NodeLogLevelList.hpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/* Copyright (C) 2003 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#ifndef NODELOGLEVELLIST_H
-#define NODELOGLEVELLIST_H
-
-class NodeLogLevel;
-
-/**
- * Provides a simple linked list of NodeLogLevel.
- *
- * @see NodeLogLevel
- * @version #@ $Id: NodeLogLevelList.hpp,v 1.1 2002/08/09 12:53:50 eyualex Exp $
- */
-class NodeLogLevelList
-{
-public:
- /**
- * Default Constructor.
- */
- NodeLogLevelList();
-
- /**
- * Destructor.
- */
- ~NodeLogLevelList();
-
- /**
- * Adds a new node.
- *
- * @param pNewHandler a new NodeLogLevel.
- */
- void add(NodeLogLevel* pNewNode);
-
- /**
- * Removes a NodeLogLevel from the list and call its destructor.
- *
- * @param pRemoveHandler the NodeLogLevel to remove
- */
- bool remove(NodeLogLevel* pRemoveNode);
-
- /**
- * Removes all items.
- */
- void removeAll();
-
- /**
- * Returns the next node in the list.
- * returns a node or NULL.
- */
- NodeLogLevel* next();
-
- /**
- * Returns the size of the list.
- */
- int size() const;
-private:
- /** List node */
- struct NodeLogLevelNode
- {
- NodeLogLevelNode* pPrev;
- NodeLogLevelNode* pNext;
- NodeLogLevel* pHandler;
- };
-
- NodeLogLevelNode* next(NodeLogLevelNode* pNode);
- NodeLogLevelNode* prev(NodeLogLevelNode* pNode);
-
- void removeNode(NodeLogLevelNode* pNode);
-
- int m_size;
-
- NodeLogLevelNode* m_pHeadNode;
- NodeLogLevelNode* m_pTailNode;
- NodeLogLevelNode* m_pCurrNode;
-};
-
-#endif
-
-
diff --git a/ndb/src/mgmsrv/Services.cpp b/ndb/src/mgmsrv/Services.cpp
index c529e277e0e..942e72f3d68 100644
--- a/ndb/src/mgmsrv/Services.cpp
+++ b/ndb/src/mgmsrv/Services.cpp
@@ -23,6 +23,7 @@
#include <mgmapi.h>
#include <EventLogger.hpp>
#include <signaldata/SetLogLevelOrd.hpp>
+#include <LogLevel.hpp>
#include <BaseString.hpp>
#include <Base64.hpp>
@@ -133,7 +134,7 @@ ParserRow<MgmApiSession> commands[] = {
MGM_ARG("public key", String, Mandatory, "Public key"),
MGM_CMD("get version", &MgmApiSession::getVersion, ""),
-
+
MGM_CMD("get status", &MgmApiSession::getStatus, ""),
MGM_CMD("get info clusterlog", &MgmApiSession::getInfoClusterLog, ""),
@@ -236,7 +237,11 @@ ParserRow<MgmApiSession> commands[] = {
MGM_ARG("node", String, Mandatory, "Node"),
MGM_ARG("parameter", String, Mandatory, "Parameter"),
MGM_ARG("value", String, Mandatory, "Value"),
-
+
+ MGM_CMD("listen event", &MgmApiSession::listen_event, ""),
+ MGM_ARG("node", Int, Optional, "Node"),
+ MGM_ARG("filter", String, Mandatory, "Event category"),
+
MGM_END()
};
@@ -289,7 +294,8 @@ MgmApiSession::runSession() {
break;
}
}
- NDB_CLOSE_SOCKET(m_socket);
+ if(m_socket >= 0)
+ NDB_CLOSE_SOCKET(m_socket);
}
#ifdef MGM_GET_CONFIG_BACKWARDS_COMPAT
@@ -418,7 +424,8 @@ MgmApiSession::get_nodeid(Parser_t::Context &,
&addr, &addrlen, error_string)){
const char *alias;
const char *str;
- alias= ndb_mgm_get_node_type_alias_string((enum ndb_mgm_node_type)nodetype, &str);
+ alias= ndb_mgm_get_node_type_alias_string((enum ndb_mgm_node_type)
+ nodetype, &str);
m_output->println(cmd);
m_output->println("result: %s", error_string.c_str());
m_output->println("");
@@ -554,7 +561,7 @@ MgmApiSession::getStatPort(Parser_t::Context &,
const class Properties &) {
m_output->println("get statport reply");
- m_output->println("tcpport: %d", m_mgmsrv.getStatPort());
+ m_output->println("tcpport: %d", 0);
m_output->println("");
}
@@ -760,7 +767,6 @@ MgmApiSession::setClusterLogLevel(Parser<MgmApiSession>::Context &,
BaseString categoryName, errorString;
SetLogLevelOrd logLevel;
int result;
- logLevel.clear();
args.get("node", &node);
args.get("category", categoryName);
args.get("level", &level);
@@ -779,14 +785,15 @@ MgmApiSession::setClusterLogLevel(Parser<MgmApiSession>::Context &,
goto error;
}
- logLevel.setLogLevel(category, level);
- result = m_mgmsrv.setEventReportingLevel(node, logLevel);
+ EventSubscribeReq req;
+ req.blockRef = 0;
+ req.noOfEntries = 1;
+ req.theCategories[0] = category;
+ req.theLevels[0] = level;
+ m_mgmsrv.m_log_level_requests.push_back(req);
m_output->println("set cluster loglevel reply");
- if(result != 0)
- m_output->println("result: %s", m_mgmsrv.getErrorText(result));
- else
- m_output->println("result: Ok");
+ m_output->println("result: Ok");
m_output->println("");
return;
error:
@@ -821,15 +828,15 @@ MgmApiSession::setLogLevel(Parser<MgmApiSession>::Context &,
goto error;
}
- logLevel.setLogLevel(category, level);
-
- result = m_mgmsrv.setNodeLogLevel(node, logLevel);
-
+ EventSubscribeReq req;
+ req.blockRef = node;
+ req.noOfEntries = 1;
+ req.theCategories[0] = category;
+ req.theLevels[0] = level;
+ m_mgmsrv.m_log_level_requests.push_back(req);
+
m_output->println("set loglevel reply");
- if(result != 0)
- m_output->println("result: %s", m_mgmsrv.getErrorText(result));
- else
- m_output->println("result: Ok");
+ m_output->println("result: Ok");
m_output->println("");
return;
error:
@@ -1248,33 +1255,91 @@ MgmApiSession::configChange(Parser_t::Context &,
m_output->println("");
}
-void
-MgmStatService::println_statistics(const BaseString &line){
- MutexVector<NDB_SOCKET_TYPE> copy(m_sockets.size());
- m_sockets.lock();
+NdbOut&
+operator<<(NdbOut& out, const LogLevel & ll)
+{
+ out << "[LogLevel: ";
+ for(size_t i = 0; i<_LOGLEVEL_CATEGORIES; i++)
+ out << ll.getLogLevel((LogLevel::EventCategory)i) << " ";
+ out << "]";
+}
+
+void
+MgmStatService::log(int eventType, const Uint32* theData, NodeId nodeId){
+
+ Uint32 threshold = 0;
+ LogLevel::EventCategory cat;
+
+ for(unsigned i = 0; i<EventLogger::matrixSize; i++){
+ if(EventLogger::matrix[i].eventType == eventType){
+ cat = EventLogger::matrix[i].eventCategory;
+ threshold = EventLogger::matrix[i].threshold;
+ break;
+ }
+ }
+
+ char m_text[256];
+ EventLogger::getText(m_text, sizeof(m_text), eventType, theData, nodeId);
+
+ Vector<NDB_SOCKET_TYPE> copy;
+ m_clients.lock();
int i;
- for(i = m_sockets.size() - 1; i >= 0; i--){
- if(println_socket(m_sockets[i], MAX_WRITE_TIMEOUT, line.c_str()) == -1){
- copy.push_back(m_sockets[i]);
- m_sockets.erase(i, false);
+ for(i = m_clients.size() - 1; i >= 0; i--){
+ if(threshold <= m_clients[i].m_logLevel.getLogLevel(cat)){
+ if(m_clients[i].m_socket >= 0 &&
+ println_socket(m_clients[i].m_socket,
+ MAX_WRITE_TIMEOUT, m_text) == -1){
+ copy.push_back(m_clients[i].m_socket);
+ m_clients.erase(i, false);
+ }
}
}
- m_sockets.unlock();
+ m_clients.unlock();
- for(i = copy.size() - 1; i >= 0; i--){
+ for(i = 0; (unsigned)i<copy.size(); i++){
NDB_CLOSE_SOCKET(copy[i]);
- copy.erase(i);
}
- if(m_sockets.size() == 0 || false){
- m_mgmsrv->startStatisticEventReporting(0);
+
+ if(copy.size()){
+ LogLevel tmp; tmp.clear();
+ m_clients.lock();
+ for(i = 0; i < m_clients.size(); i++){
+ tmp.set_max(m_clients[i].m_logLevel);
+ }
+ m_clients.unlock();
+
+ if(!(tmp == m_logLevel)){
+ m_logLevel = tmp;
+ EventSubscribeReq req;
+ req = tmp;
+ req.blockRef = 0;
+ m_mgmsrv->m_log_level_requests.push_back(req);
+ }
+ }
+}
+
+void
+MgmStatService::add_listener(const StatListener& client){
+ m_clients.push_back(client);
+ LogLevel tmp = m_logLevel;
+ tmp.set_max(client.m_logLevel);
+
+ if(!(tmp == m_logLevel)){
+ m_logLevel = tmp;
+ EventSubscribeReq req;
+ req = tmp;
+ req.blockRef = 0;
+ m_mgmsrv->m_log_level_requests.push_back(req);
}
}
void
MgmStatService::stopSessions(){
- for(int i = m_sockets.size() - 1; i >= 0; i--){
- NDB_CLOSE_SOCKET(m_sockets[i]);
- m_sockets.erase(i);
+ for(int i = m_clients.size() - 1; i >= 0; i--){
+ if(m_clients[i].m_socket >= 0){
+ NDB_CLOSE_SOCKET(m_clients[i].m_socket);
+ m_clients.erase(i);
+ }
}
}
@@ -1298,6 +1363,71 @@ MgmApiSession::setParameter(Parser_t::Context &,
m_output->println("");
}
+void
+MgmApiSession::listen_event(Parser<MgmApiSession>::Context & ctx,
+ Properties const & args) {
+
+ BaseString node, param, value;
+ args.get("node", node);
+ args.get("filter", param);
+
+ int result = 0;
+ BaseString msg;
+
+ MgmStatService::StatListener le;
+ le.m_socket = m_socket;
+
+ Vector<BaseString> list;
+ param.trim();
+ param.split(list, " ,");
+ for(size_t i = 0; i<list.size(); i++){
+ Vector<BaseString> spec;
+ list[i].trim();
+ list[i].split(spec, "=:");
+ if(spec.size() != 2){
+ msg.appfmt("Invalid filter specification: >%s< >%s< %d",
+ param.c_str(), list[i].c_str(), spec.size());
+ result = -1;
+ goto done;
+ }
+
+ spec[0].trim();
+ spec[0].ndb_toupper();
+
+ LogLevel::EventCategory category;
+ if(!EventLogger::matchEventCategory(spec[0].c_str(), &category)) {
+ msg.appfmt("Unknown category: >%s<", spec[0].c_str());
+ result = -1;
+ goto done;
+ }
+
+ int level = atoi(spec[1].c_str());
+ if(level < 0 || level > 15){
+ msg.appfmt("Invalid level: >%s<", spec[1].c_str());
+ result = -1;
+ goto done;
+ }
+ le.m_logLevel.setLogLevel(category, level);
+ }
+
+ if(list.size() == 0){
+ msg.appfmt("Empty filter specification");
+ result = -1;
+ goto done;
+ }
+
+ m_mgmsrv.m_statisticsListner.add_listener(le);
+
+ m_stop = true;
+ m_socket = -1;
+
+done:
+ m_output->println("listen event");
+ m_output->println("result: %d", result);
+ if(result != 0)
+ m_output->println("msg: %s", msg.c_str());
+}
+
template class MutexVector<int>;
template class Vector<ParserRow<MgmApiSession> const*>;
template class Vector<unsigned short>;
diff --git a/ndb/src/mgmsrv/Services.hpp b/ndb/src/mgmsrv/Services.hpp
index 9cf8b59be8f..e47820826b6 100644
--- a/ndb/src/mgmsrv/Services.hpp
+++ b/ndb/src/mgmsrv/Services.hpp
@@ -83,7 +83,8 @@ public:
void configChange(Parser_t::Context &ctx, const class Properties &args);
void setParameter(Parser_t::Context &ctx, const class Properties &args);
-
+ void listen_event(Parser_t::Context &ctx, const class Properties &args);
+
void repCommand(Parser_t::Context &ctx, const class Properties &args);
};
@@ -103,28 +104,4 @@ public:
}
};
-class MgmStatService : public SocketServer::Service,
- public MgmtSrvr::StatisticsListner
-{
- class MgmtSrvr * m_mgmsrv;
- MutexVector<NDB_SOCKET_TYPE> m_sockets;
-public:
- MgmStatService() : m_sockets(5) {
- m_mgmsrv = 0;
- }
-
- void setMgm(class MgmtSrvr * mgmsrv){
- m_mgmsrv = mgmsrv;
- }
-
- SocketServer::Session * newSession(NDB_SOCKET_TYPE socket){
- m_sockets.push_back(socket);
- m_mgmsrv->startStatisticEventReporting(5);
- return 0;
- }
-
- void stopSessions();
-
- void println_statistics(const BaseString &line);
-};
#endif
diff --git a/ndb/src/mgmsrv/main.cpp b/ndb/src/mgmsrv/main.cpp
index 323a836cdd4..a582d082312 100644
--- a/ndb/src/mgmsrv/main.cpp
+++ b/ndb/src/mgmsrv/main.cpp
@@ -15,7 +15,6 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <ndb_global.h>
-#include <my_sys.h>
#include "MgmtSrvr.hpp"
#include "EventLogger.hpp"
@@ -70,7 +69,6 @@ struct MgmGlobals {
bool use_specific_ip;
char * interface_name;
int port;
- int port_stats;
/** The configuration of the cluster */
Config * cluster_config;
@@ -82,6 +80,7 @@ struct MgmGlobals {
SocketServer * socketServer;
};
+int g_no_nodeid_checks= 0;
static MgmGlobals glob;
@@ -118,7 +117,9 @@ struct getargs args[] = {
"Specify configuration file connect string (will default use Ndb.cfg if available)",
"filename" },
{ "interactive", 0, arg_flag, &glob.interactive,
- "Run interactive. Not supported but provided for testing purposes", "" },
+ "Run interactive. Not supported but provided for testing purposes", "" },
+ { "no-nodeid-checks", 0, arg_flag, &g_no_nodeid_checks,
+ "Do not provide any node id checks", "" },
{ "nodaemon", 0, arg_flag, &glob.non_interactive,
"Don't run as daemon, but don't read from stdin", "non-interactive" }
};
@@ -129,6 +130,7 @@ int num_args = sizeof(args) / sizeof(args[0]);
* MAIN
*/
NDB_MAIN(mgmsrv){
+ ndb_init();
/**
* OSE specific. Enable shared ownership of file system resources.
* This is needed in order to use the cluster log since the events
@@ -151,7 +153,6 @@ NDB_MAIN(mgmsrv){
glob.daemon= 0;
}
- my_init();
#ifndef DBUG_OFF
if (debug_option)
DBUG_PUSH(debug_option);
@@ -169,8 +170,6 @@ NDB_MAIN(mgmsrv){
MgmApiService * mapi = new MgmApiService();
- MgmStatService * mstat = new MgmStatService();
-
/****************************
* Read configuration files *
****************************/
@@ -230,13 +229,6 @@ NDB_MAIN(mgmsrv){
goto error_end;
}
- if(!glob.socketServer->setup(mstat, glob.port_stats, glob.interface_name)){
- ndbout_c("Unable to setup statistic port: %d!\nPlease check if the port"
- " is already used.", glob.port_stats);
- delete mstat;
- goto error_end;
- }
-
if(!glob.mgmObject->check_start()){
ndbout_c("Unable to check start management server.");
ndbout_c("Probably caused by illegal initial configuration file.");
@@ -267,10 +259,7 @@ NDB_MAIN(mgmsrv){
}
//glob.mgmObject->saveConfig();
-
- mstat->setMgm(glob.mgmObject);
mapi->setMgm(glob.mgmObject);
- glob.mgmObject->setStatisticsListner(mstat);
char msg[256];
snprintf(msg, sizeof(msg),
@@ -278,8 +267,8 @@ NDB_MAIN(mgmsrv){
ndbout_c(msg);
g_EventLogger.info(msg);
- snprintf(msg, 256, "Id: %d, Command port: %d, Statistics port: %d",
- glob.localNodeId, glob.port, glob.port_stats);
+ snprintf(msg, 256, "Id: %d, Command port: %d",
+ glob.localNodeId, glob.port);
ndbout_c(msg);
g_EventLogger.info(msg);
@@ -309,7 +298,6 @@ NDB_MAIN(mgmsrv){
MgmGlobals::MgmGlobals(){
// Default values
port = 0;
- port_stats = 0;
config_filename = NULL;
local_config_filename = NULL;
interface_name = 0;
@@ -336,17 +324,12 @@ MgmGlobals::~MgmGlobals(){
* @fn readLocalConfig
* @param glob : Global variables
* @return true if success, false otherwise.
- *
- * How to get LOCAL CONFIGURATION FILE:
- * 1. Use local config file name (-l)
- * 2. Use environment NDB_HOME + Ndb.cfg
- * If NDB_HOME is not set this results in reading from local dir
*/
static bool
readLocalConfig(){
// Read local config file
LocalConfig lc;
- if(!lc.init(glob.local_config_filename)){
+ if(!lc.init(0,glob.local_config_filename)){
lc.printError();
return false;
}
@@ -360,10 +343,6 @@ readLocalConfig(){
* @fn readGlobalConfig
* @param glob : Global variables
* @return true if success, false otherwise.
- *
- * How to get the GLOBAL CONFIGURATION:
- * 1. Use config file name (this is a text file)(-c)
- * 2. Use name from line 2 of local config file, ex: file:///c/ndb/Ndb_cfg.bin
*/
static bool
readGlobalConfig() {
diff --git a/ndb/src/mgmsrv/mkconfig/mkconfig.cpp b/ndb/src/mgmsrv/mkconfig/mkconfig.cpp
index 3b2046d7b49..28823aaa35e 100644
--- a/ndb/src/mgmsrv/mkconfig/mkconfig.cpp
+++ b/ndb/src/mgmsrv/mkconfig/mkconfig.cpp
@@ -32,6 +32,7 @@ void usage(const char * prg){
NDB_COMMAND(mkconfig,
"mkconfig", "mkconfig",
"Make a binary configuration from a config file", 16384){
+ ndb_init();
if(argc < 3){
usage(argv[0]);
return 0;
diff --git a/ndb/src/ndbapi/NdbDictionary.cpp b/ndb/src/ndbapi/NdbDictionary.cpp
index 1e28fbc2db5..6cfacc2c340 100644
--- a/ndb/src/ndbapi/NdbDictionary.cpp
+++ b/ndb/src/ndbapi/NdbDictionary.cpp
@@ -65,7 +65,7 @@ NdbDictionary::Column::getName() const {
void
NdbDictionary::Column::setType(Type t){
- m_impl.m_type = t;
+ m_impl.init(t);
}
NdbDictionary::Column::Type
@@ -103,6 +103,54 @@ NdbDictionary::Column::getLength() const{
return m_impl.m_length;
}
+void
+NdbDictionary::Column::setInlineSize(int size)
+{
+ m_impl.m_precision = size;
+}
+
+void
+NdbDictionary::Column::setCharset(CHARSET_INFO* cs)
+{
+ m_impl.m_cs = cs;
+}
+
+CHARSET_INFO*
+NdbDictionary::Column::getCharset() const
+{
+ return m_impl.m_cs;
+}
+
+int
+NdbDictionary::Column::getInlineSize() const
+{
+ return m_impl.m_precision;
+}
+
+void
+NdbDictionary::Column::setPartSize(int size)
+{
+ m_impl.m_scale = size;
+}
+
+int
+NdbDictionary::Column::getPartSize() const
+{
+ return m_impl.m_scale;
+}
+
+void
+NdbDictionary::Column::setStripeSize(int size)
+{
+ m_impl.m_length = size;
+}
+
+int
+NdbDictionary::Column::getStripeSize() const
+{
+ return m_impl.m_length;
+}
+
int
NdbDictionary::Column::getSize() const{
return m_impl.m_attrSize;
@@ -821,6 +869,8 @@ NdbDictionary::Dictionary::getNdbError() const {
NdbOut&
operator<<(NdbOut& out, const NdbDictionary::Column& col)
{
+ const CHARSET_INFO *cs = col.getCharset();
+ const char *csname = cs ? cs->name : "?";
out << col.getName() << " ";
switch (col.getType()) {
case NdbDictionary::Column::Tinyint:
@@ -863,10 +913,10 @@ operator<<(NdbOut& out, const NdbDictionary::Column& col)
out << "Decimal(" << col.getScale() << "," << col.getPrecision() << ")";
break;
case NdbDictionary::Column::Char:
- out << "Char(" << col.getLength() << ")";
+ out << "Char(" << col.getLength() << ";" << csname << ")";
break;
case NdbDictionary::Column::Varchar:
- out << "Varchar(" << col.getLength() << ")";
+ out << "Varchar(" << col.getLength() << ";" << csname << ")";
break;
case NdbDictionary::Column::Binary:
out << "Binary(" << col.getLength() << ")";
@@ -886,7 +936,7 @@ operator<<(NdbOut& out, const NdbDictionary::Column& col)
break;
case NdbDictionary::Column::Text:
out << "Text(" << col.getInlineSize() << "," << col.getPartSize()
- << ";" << col.getStripeSize() << ")";
+ << ";" << col.getStripeSize() << ";" << csname << ")";
break;
case NdbDictionary::Column::Undefined:
out << "Undefined";
diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp
index 815ecf8ca6c..0b2a0386a6b 100644
--- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp
+++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp
@@ -36,6 +36,7 @@
#include "NdbEventOperationImpl.hpp"
#include "NdbBlob.hpp"
#include <AttributeHeader.hpp>
+#include <my_sys.h>
#define DEBUG_PRINT 0
#define INCOMPATIBLE_VERSION -2
@@ -64,6 +65,7 @@ NdbColumnImpl::operator=(const NdbColumnImpl& col)
m_name = col.m_name;
m_type = col.m_type;
m_precision = col.m_precision;
+ m_cs = col.m_cs;
m_scale = col.m_scale;
m_length = col.m_length;
m_pk = col.m_pk;
@@ -87,10 +89,66 @@ NdbColumnImpl::operator=(const NdbColumnImpl& col)
}
void
-NdbColumnImpl::init()
+NdbColumnImpl::init(Type t)
{
+ // do not use default_charset_info as it may not be initialized yet
+ // use binary collation until NDB tests can handle charsets
+ CHARSET_INFO* default_cs = &my_charset_latin1_bin;
m_attrId = -1;
- m_type = NdbDictionary::Column::Unsigned;
+ m_type = t;
+ switch (m_type) {
+ case Tinyint:
+ case Tinyunsigned:
+ case Smallint:
+ case Smallunsigned:
+ case Mediumint:
+ case Mediumunsigned:
+ case Int:
+ case Unsigned:
+ case Bigint:
+ case Bigunsigned:
+ case Float:
+ case Double:
+ m_precision = 0;
+ m_scale = 0;
+ m_length = 1;
+ m_cs = NULL;
+ break;
+ case Decimal:
+ m_precision = 10;
+ m_scale = 0;
+ m_length = 1;
+ m_cs = NULL;
+ break;
+ case Char:
+ case Varchar:
+ m_precision = 0;
+ m_scale = 0;
+ m_length = 1;
+ m_cs = default_cs;
+ break;
+ case Binary:
+ case Varbinary:
+ case Datetime:
+ case Timespec:
+ m_precision = 0;
+ m_scale = 0;
+ m_length = 1;
+ m_cs = NULL;
+ break;
+ case Blob:
+ m_precision = 256;
+ m_scale = 8000;
+ m_length = 4;
+ m_cs = NULL;
+ break;
+ case Text:
+ m_precision = 256;
+ m_scale = 8000;
+ m_length = 4;
+ m_cs = default_cs;
+ break;
+ }
m_pk = false;
m_nullable = false;
m_tupleKey = false;
@@ -98,12 +156,10 @@ NdbColumnImpl::init()
m_distributionKey = false;
m_distributionGroup = false;
m_distributionGroupBits = 8;
- m_length = 1;
- m_scale = 5;
- m_precision = 5;
m_keyInfoPos = 0;
- m_attrSize = 4,
- m_arraySize = 1,
+ // next 2 are set at run time
+ m_attrSize = 0;
+ m_arraySize = 0;
m_autoIncrement = false;
m_autoIncrementInitialValue = 1;
m_blobTable = NULL;
@@ -146,52 +202,12 @@ NdbColumnImpl::equal(const NdbColumnImpl& col) const
return false;
}
}
- if(m_length != col.m_length){
+ if (m_precision != col.m_precision ||
+ m_scale != col.m_scale ||
+ m_length != col.m_length ||
+ m_cs != col.m_cs) {
return false;
}
-
- switch(m_type){
- case NdbDictionary::Column::Undefined:
- break;
- case NdbDictionary::Column::Tinyint:
- case NdbDictionary::Column::Tinyunsigned:
- case NdbDictionary::Column::Smallint:
- case NdbDictionary::Column::Smallunsigned:
- case NdbDictionary::Column::Mediumint:
- case NdbDictionary::Column::Mediumunsigned:
- case NdbDictionary::Column::Int:
- case NdbDictionary::Column::Unsigned:
- case NdbDictionary::Column::Float:
- break;
- case NdbDictionary::Column::Decimal:
- if(m_scale != col.m_scale ||
- m_precision != col.m_precision){
- return false;
- }
- break;
- case NdbDictionary::Column::Char:
- case NdbDictionary::Column::Varchar:
- case NdbDictionary::Column::Binary:
- case NdbDictionary::Column::Varbinary:
- if(m_length != col.m_length){
- return false;
- }
- break;
- case NdbDictionary::Column::Bigint:
- case NdbDictionary::Column::Bigunsigned:
- case NdbDictionary::Column::Double:
- case NdbDictionary::Column::Datetime:
- case NdbDictionary::Column::Timespec:
- break;
- case NdbDictionary::Column::Blob:
- case NdbDictionary::Column::Text:
- if (m_precision != col.m_precision ||
- m_scale != col.m_scale ||
- m_length != col.m_length) {
- return false;
- }
- break;
- }
if (m_autoIncrement != col.m_autoIncrement){
return false;
}
@@ -209,14 +225,18 @@ NdbColumnImpl::create_psuedo(const char * name){
if(!strcmp(name, "NDB$FRAGMENT")){
col->setType(NdbDictionary::Column::Unsigned);
col->m_impl.m_attrId = AttributeHeader::FRAGMENT;
+ col->m_impl.m_attrSize = 4;
+ col->m_impl.m_arraySize = 1;
} else if(!strcmp(name, "NDB$ROW_COUNT")){
col->setType(NdbDictionary::Column::Bigunsigned);
col->m_impl.m_attrId = AttributeHeader::ROW_COUNT;
col->m_impl.m_attrSize = 8;
+ col->m_impl.m_arraySize = 1;
} else if(!strcmp(name, "NDB$COMMIT_COUNT")){
col->setType(NdbDictionary::Column::Bigunsigned);
col->m_impl.m_attrId = AttributeHeader::COMMIT_COUNT;
col->m_impl.m_attrSize = 8;
+ col->m_impl.m_arraySize = 1;
} else {
abort();
}
@@ -1127,6 +1147,7 @@ indexTypeMapping[] = {
{ -1, -1 }
};
+// TODO: remove, api-kernel type codes must match now
static const
ApiKernelMapping
columnTypeMapping[] = {
@@ -1233,9 +1254,23 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret,
return 703;
}
col->m_extType = attrDesc.AttributeExtType;
- col->m_precision = attrDesc.AttributeExtPrecision;
+ col->m_precision = (attrDesc.AttributeExtPrecision & 0xFFFF);
col->m_scale = attrDesc.AttributeExtScale;
col->m_length = attrDesc.AttributeExtLength;
+ // charset in upper half of precision
+ unsigned cs_number = (attrDesc.AttributeExtPrecision >> 16);
+ // charset is defined exactly for char types
+ if (col->getCharType() != (cs_number != 0)) {
+ delete impl;
+ return 703;
+ }
+ if (col->getCharType()) {
+ col->m_cs = get_charset(cs_number, MYF(0));
+ if (col->m_cs == NULL) {
+ delete impl;
+ return 743;
+ }
+ }
// translate to old kernel types and sizes
if (! attrDesc.translateExtType()) {
@@ -1486,9 +1521,23 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb,
getKernelConstant(col->m_type,
columnTypeMapping,
DictTabInfo::ExtUndefined);
- tmpAttr.AttributeExtPrecision = col->m_precision;
+ tmpAttr.AttributeExtPrecision = ((unsigned)col->m_precision & 0xFFFF);
tmpAttr.AttributeExtScale = col->m_scale;
tmpAttr.AttributeExtLength = col->m_length;
+ // charset is defined exactly for char types
+ if (col->getCharType() != (col->m_cs != NULL)) {
+ m_error.code = 703;
+ return -1;
+ }
+ // primary key type check
+ if (col->m_pk && ! NdbSqlUtil::usable_in_pk(col->m_type, col->m_cs)) {
+ m_error.code = 743;
+ return -1;
+ }
+ // charset in upper half of precision
+ if (col->getCharType()) {
+ tmpAttr.AttributeExtPrecision |= (col->m_cs->number << 16);
+ }
// DICT will ignore and recompute this
(void)tmpAttr.translateExtType();
@@ -1950,6 +1999,14 @@ NdbDictInterface::createIndex(Ndb & ndb,
m_error.code = 4245;
return -1;
}
+ // index key type check
+ if (it == DictTabInfo::UniqueHashIndex &&
+ ! NdbSqlUtil::usable_in_hash_index(col->m_type, col->m_cs) ||
+ it == DictTabInfo::OrderedIndex &&
+ ! NdbSqlUtil::usable_in_ordered_index(col->m_type, col->m_cs)) {
+ m_error.code = 743;
+ return -1;
+ }
attributeList.id[i] = col->m_attrId;
}
if (it == DictTabInfo::UniqueHashIndex) {
diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.hpp b/ndb/src/ndbapi/NdbDictionaryImpl.hpp
index da5e7e45c36..cf659c71397 100644
--- a/ndb/src/ndbapi/NdbDictionaryImpl.hpp
+++ b/ndb/src/ndbapi/NdbDictionaryImpl.hpp
@@ -52,7 +52,7 @@ public:
NdbColumnImpl(NdbDictionary::Column &); // This is not a copy constructor
~NdbColumnImpl();
NdbColumnImpl& operator=(const NdbColumnImpl&);
- void init();
+ void init(Type t = Unsigned);
int m_attrId;
BaseString m_name;
@@ -60,6 +60,7 @@ public:
int m_precision;
int m_scale;
int m_length;
+ CHARSET_INFO * m_cs; // not const in MySQL
bool m_pk;
bool m_tupleKey;
@@ -82,6 +83,7 @@ public:
Uint32 m_keyInfoPos;
Uint32 m_extType; // used by restore (kernel type in versin v2x)
bool getInterpretableType() const ;
+ bool getCharType() const;
bool getBlobType() const;
/**
@@ -448,6 +450,14 @@ NdbColumnImpl::getInterpretableType() const {
inline
bool
+NdbColumnImpl::getCharType() const {
+ return (m_type == NdbDictionary::Column::Char ||
+ m_type == NdbDictionary::Column::Varchar ||
+ m_type == NdbDictionary::Column::Text);
+}
+
+inline
+bool
NdbColumnImpl::getBlobType() const {
return (m_type == NdbDictionary::Column::Blob ||
m_type == NdbDictionary::Column::Text);
diff --git a/ndb/src/ndbapi/Ndbinit.cpp b/ndb/src/ndbapi/Ndbinit.cpp
index d4b4c92e78a..fd357ef4e37 100644
--- a/ndb/src/ndbapi/Ndbinit.cpp
+++ b/ndb/src/ndbapi/Ndbinit.cpp
@@ -16,7 +16,6 @@
#include <ndb_global.h>
-#include <my_sys.h>
#include "NdbApiSignal.hpp"
#include "NdbImpl.hpp"
@@ -62,7 +61,6 @@ Ndb::Ndb( const char* aDataBase , const char* aSchema) {
abort(); // old and new Ndb constructor used mixed
theNoOfNdbObjects++;
if (global_ndb_cluster_connection == 0) {
- my_init();
global_ndb_cluster_connection= new Ndb_cluster_connection(ndbConnectString);
global_ndb_cluster_connection->connect();
}
diff --git a/ndb/src/ndbapi/ndberror.c b/ndb/src/ndbapi/ndberror.c
index 7991004e3d0..2ebcf4be444 100644
--- a/ndb/src/ndbapi/ndberror.c
+++ b/ndb/src/ndbapi/ndberror.c
@@ -280,6 +280,9 @@ ErrorBundle ErrorCodes[] = {
{ 739, SE, "Unsupported primary key length" },
{ 740, SE, "Nullable primary key not supported" },
{ 741, SE, "Unsupported alter table" },
+ { 742, SE, "Unsupported attribute type in index" },
+ { 743, SE, "Unsupported character set in table or index" },
+ { 744, SE, "Character conversion error" },
{ 241, SE, "Invalid schema object version" },
{ 283, SE, "Table is being dropped" },
{ 284, SE, "Table not defined in transaction coordinator" },
diff --git a/ndb/test/include/NDBT_Table.hpp b/ndb/test/include/NDBT_Table.hpp
index 59db3ed1092..d2f99b85187 100644
--- a/ndb/test/include/NDBT_Table.hpp
+++ b/ndb/test/include/NDBT_Table.hpp
@@ -33,10 +33,10 @@ public:
{
assert(_name != 0);
+ setType(_type);
+ setLength(_length);
setNullable(_nullable);
setPrimaryKey(_pk);
- setLength(_length);
- setType(_type);
}
};
diff --git a/ndb/test/ndbapi/Makefile.am b/ndb/test/ndbapi/Makefile.am
index 95fcf621e89..787589dd9b6 100644
--- a/ndb/test/ndbapi/Makefile.am
+++ b/ndb/test/ndbapi/Makefile.am
@@ -30,7 +30,7 @@ testSystemRestart \
testTimeout \
testTransactions \
testDeadlock \
-test_event ndbapi_slow_select testReadPerf
+test_event ndbapi_slow_select testReadPerf testLcp
#flexTimedAsynch
#testBlobs
@@ -68,6 +68,7 @@ testDeadlock_SOURCES = testDeadlock.cpp
test_event_SOURCES = test_event.cpp
ndbapi_slow_select_SOURCES = slow_select.cpp
testReadPerf_SOURCES = testReadPerf.cpp
+testLcp_SOURCES = testLcp.cpp
INCLUDES_LOC = -I$(top_srcdir)/ndb/include/kernel
diff --git a/ndb/test/ndbapi/acid.cpp b/ndb/test/ndbapi/acid.cpp
index 157b3c7b3ef..3eb1625be26 100644
--- a/ndb/test/ndbapi/acid.cpp
+++ b/ndb/test/ndbapi/acid.cpp
@@ -434,6 +434,7 @@ extern "C" void* NdbThreadFuncRead(void* pArg)
NDB_COMMAND(acid, "acid", "acid", "acid", 65535)
{
+ ndb_init();
long nSeconds = 60;
int rc = NDBT_OK;
diff --git a/ndb/test/ndbapi/acid2.cpp b/ndb/test/ndbapi/acid2.cpp
index 434a0450daa..7bd7ec00ac5 100644
--- a/ndb/test/ndbapi/acid2.cpp
+++ b/ndb/test/ndbapi/acid2.cpp
@@ -610,6 +610,7 @@ extern "C" void* ThreadFunc(void*)
int main(int argc, char* argv[])
{
+ ndb_init();
Uint32 nSeconds = 1;
Uint32 nThread = 1;
diff --git a/ndb/test/ndbapi/bank/Bank.cpp b/ndb/test/ndbapi/bank/Bank.cpp
index 7a2c5b057a1..c6029259357 100644
--- a/ndb/test/ndbapi/bank/Bank.cpp
+++ b/ndb/test/ndbapi/bank/Bank.cpp
@@ -156,7 +156,14 @@ int Bank::performTransactionImpl1(int fromAccountId,
int check;
+ // Ok, all clear to do the transaction
+ Uint64 transId;
+ if (getNextTransactionId(transId) != NDBT_OK){
+ return NDBT_FAILED;
+ }
+
NdbConnection* pTrans = m_ndb.startTransaction();
+
if( pTrans == NULL ) {
const NdbError err = m_ndb.getNdbError();
if (err.status == NdbError::TemporaryError){
@@ -167,6 +174,13 @@ int Bank::performTransactionImpl1(int fromAccountId,
return NDBT_FAILED;
}
+ Uint64 currTime;
+ if (prepareGetCurrTimeOp(pTrans, currTime) != NDBT_OK){
+ ERR(pTrans->getNdbError());
+ m_ndb.closeTransaction(pTrans);
+ return NDBT_FAILED;
+ }
+
/**
* Check balance on from account
*/
@@ -205,29 +219,6 @@ int Bank::performTransactionImpl1(int fromAccountId,
return NDBT_FAILED;
}
- check = pTrans->execute(NoCommit);
- if( check == -1 ) {
- const NdbError err = pTrans->getNdbError();
- m_ndb.closeTransaction(pTrans);
- if (err.status == NdbError::TemporaryError){
- ERR(err);
- return NDBT_TEMPORARY;
- }
- ERR(err);
- return NDBT_FAILED;
- }
-
- Uint32 balanceFrom = balanceFromRec->u_32_value();
- // ndbout << "balanceFrom: " << balanceFrom << endl;
-
- if (((Int64)balanceFrom - amount) < 0){
- m_ndb.closeTransaction(pTrans);
- //ndbout << "Not enough funds" << endl;
- return NOT_ENOUGH_FUNDS;
- }
-
- Uint32 fromAccountType = fromAccountTypeRec->u_32_value();
-
/**
* Read balance on to account
*/
@@ -278,21 +269,22 @@ int Bank::performTransactionImpl1(int fromAccountId,
return NDBT_FAILED;
}
- Uint32 balanceTo = balanceToRec->u_32_value();
- // ndbout << "balanceTo: " << balanceTo << endl;
- Uint32 toAccountType = toAccountTypeRec->u_32_value();
- // Ok, all clear to do the transaction
- Uint64 transId;
- if (getNextTransactionId(transId) != NDBT_OK){
- return NDBT_FAILED;
- }
+ Uint32 balanceFrom = balanceFromRec->u_32_value();
+ // ndbout << "balanceFrom: " << balanceFrom << endl;
- Uint64 currTime;
- if (getCurrTime(currTime) != NDBT_OK){
- return NDBT_FAILED;
+ if (((Int64)balanceFrom - amount) < 0){
+ m_ndb.closeTransaction(pTrans);
+ //ndbout << "Not enough funds" << endl;
+ return NOT_ENOUGH_FUNDS;
}
+ Uint32 fromAccountType = fromAccountTypeRec->u_32_value();
+
+ Uint32 balanceTo = balanceToRec->u_32_value();
+ // ndbout << "balanceTo: " << balanceTo << endl;
+ Uint32 toAccountType = toAccountTypeRec->u_32_value();
+
/**
* Update balance on from account
*/
@@ -1988,47 +1980,50 @@ int Bank::readSystemValue(SystemValueId sysValId, Uint64 & value){
ERR(m_ndb.getNdbError());
return NDBT_FAILED;
}
-
- NdbOperation* pOp = pTrans->getNdbOperation("SYSTEM_VALUES");
- if (pOp == NULL) {
+
+ if (prepareReadSystemValueOp(pTrans, sysValId, value) != NDBT_OK) {
ERR(pTrans->getNdbError());
m_ndb.closeTransaction(pTrans);
return NDBT_FAILED;
}
-
- check = pOp->readTuple();
+
+ check = pTrans->execute(Commit);
if( check == -1 ) {
ERR(pTrans->getNdbError());
m_ndb.closeTransaction(pTrans);
return NDBT_FAILED;
}
- check = pOp->equal("SYSTEM_VALUES_ID", sysValId);
- if( check == -1 ) {
- ERR(pTrans->getNdbError());
- m_ndb.closeTransaction(pTrans);
+ m_ndb.closeTransaction(pTrans);
+ return NDBT_OK;
+
+}
+
+int Bank::prepareReadSystemValueOp(NdbConnection* pTrans, SystemValueId sysValId, Uint64 & value){
+
+ int check;
+
+ NdbOperation* pOp = pTrans->getNdbOperation("SYSTEM_VALUES");
+ if (pOp == NULL) {
return NDBT_FAILED;
}
- NdbRecAttr* valueRec = pOp->getValue("VALUE");
- if( valueRec ==NULL ) {
- ERR(pTrans->getNdbError());
- m_ndb.closeTransaction(pTrans);
+ check = pOp->readTuple();
+ if( check == -1 ) {
return NDBT_FAILED;
}
- check = pTrans->execute(Commit);
+ check = pOp->equal("SYSTEM_VALUES_ID", sysValId);
if( check == -1 ) {
- ERR(pTrans->getNdbError());
- m_ndb.closeTransaction(pTrans);
return NDBT_FAILED;
}
- value = valueRec->u_64_value();
+ NdbRecAttr* valueRec = pOp->getValue("VALUE", (char *)&value);
+ if( valueRec == NULL ) {
+ return NDBT_FAILED;
+ }
- m_ndb.closeTransaction(pTrans);
return NDBT_OK;
-
}
int Bank::writeSystemValue(SystemValueId sysValId, Uint64 value){
@@ -2097,47 +2092,50 @@ int Bank::increaseSystemValue(SystemValueId sysValId, Uint64 &value){
*
*/
+ DBUG_ENTER("Bank::increaseSystemValue");
+
int check;
NdbConnection* pTrans = m_ndb.startTransaction();
if (pTrans == NULL){
ERR(m_ndb.getNdbError());
- return NDBT_FAILED;
+ DBUG_RETURN(NDBT_FAILED);
}
NdbOperation* pOp = pTrans->getNdbOperation("SYSTEM_VALUES");
if (pOp == NULL) {
ERR(pTrans->getNdbError());
m_ndb.closeTransaction(pTrans);
- return NDBT_FAILED;
+ DBUG_RETURN(NDBT_FAILED);
}
check = pOp->readTupleExclusive();
+ // check = pOp->readTuple();
if( check == -1 ) {
ERR(pTrans->getNdbError());
m_ndb.closeTransaction(pTrans);
- return NDBT_FAILED;
+ DBUG_RETURN(NDBT_FAILED);
}
check = pOp->equal("SYSTEM_VALUES_ID", sysValId);
if( check == -1 ) {
ERR(pTrans->getNdbError());
m_ndb.closeTransaction(pTrans);
- return NDBT_FAILED;
+ DBUG_RETURN(NDBT_FAILED);
}
NdbRecAttr* valueRec = pOp->getValue("VALUE");
if( valueRec ==NULL ) {
ERR(pTrans->getNdbError());
m_ndb.closeTransaction(pTrans);
- return NDBT_FAILED;
+ DBUG_RETURN(NDBT_FAILED);
}
check = pTrans->execute(NoCommit);
if( check == -1 ) {
ERR(pTrans->getNdbError());
m_ndb.closeTransaction(pTrans);
- return NDBT_FAILED;
+ DBUG_RETURN(NDBT_FAILED);
}
value = valueRec->u_64_value();
@@ -2147,49 +2145,56 @@ int Bank::increaseSystemValue(SystemValueId sysValId, Uint64 &value){
if (pOp2 == NULL) {
ERR(pTrans->getNdbError());
m_ndb.closeTransaction(pTrans);
- return NDBT_FAILED;
+ DBUG_RETURN(NDBT_FAILED);
}
check = pOp2->updateTuple();
if( check == -1 ) {
ERR(pTrans->getNdbError());
m_ndb.closeTransaction(pTrans);
- return NDBT_FAILED;
+ DBUG_RETURN(NDBT_FAILED);
}
check = pOp2->equal("SYSTEM_VALUES_ID", sysValId);
if( check == -1 ) {
ERR(pTrans->getNdbError());
m_ndb.closeTransaction(pTrans);
- return NDBT_FAILED;
+ DBUG_RETURN(NDBT_FAILED);
}
check = pOp2->setValue("VALUE", value);
if( check == -1 ) {
ERR(pTrans->getNdbError());
m_ndb.closeTransaction(pTrans);
- return NDBT_FAILED;
+ DBUG_RETURN(NDBT_FAILED);
+ }
+
+ check = pTrans->execute(NoCommit);
+ if( check == -1 ) {
+ ERR(pTrans->getNdbError());
+ m_ndb.closeTransaction(pTrans);
+ DBUG_RETURN(NDBT_FAILED);
}
NdbOperation* pOp3 = pTrans->getNdbOperation("SYSTEM_VALUES");
if (pOp3 == NULL) {
ERR(pTrans->getNdbError());
m_ndb.closeTransaction(pTrans);
- return NDBT_FAILED;
+ DBUG_RETURN(NDBT_FAILED);
}
check = pOp3->readTuple();
if( check == -1 ) {
ERR(pTrans->getNdbError());
m_ndb.closeTransaction(pTrans);
- return NDBT_FAILED;
+ DBUG_RETURN(NDBT_FAILED);
}
check = pOp3->equal("SYSTEM_VALUES_ID", sysValId);
if( check == -1 ) {
ERR(pTrans->getNdbError());
m_ndb.closeTransaction(pTrans);
- return NDBT_FAILED;
+ DBUG_RETURN(NDBT_FAILED);
}
// Read new value
@@ -2197,28 +2202,31 @@ int Bank::increaseSystemValue(SystemValueId sysValId, Uint64 &value){
if( valueNewRec ==NULL ) {
ERR(pTrans->getNdbError());
m_ndb.closeTransaction(pTrans);
- return NDBT_FAILED;
+ DBUG_RETURN(NDBT_FAILED);
}
check = pTrans->execute(Commit);
if( check == -1 ) {
ERR(pTrans->getNdbError());
m_ndb.closeTransaction(pTrans);
- return NDBT_FAILED;
+ DBUG_RETURN(NDBT_FAILED);
}
// Check that value updated equals the value we read after the update
if (valueNewRec->u_64_value() != value){
+
+ printf("value actual=%lld\n", valueNewRec->u_64_value());
+ printf("value expected=%lld actual=%lld\n", value, valueNewRec->u_64_value());
+
+ DBUG_PRINT("info", ("value expected=%ld actual=%ld", value, valueNewRec->u_64_value()));
g_err << "getNextTransactionId: value was not updated" << endl;
m_ndb.closeTransaction(pTrans);
- return NDBT_FAILED;
+ DBUG_RETURN(NDBT_FAILED);
}
m_ndb.closeTransaction(pTrans);
-
-
- return 0;
+ DBUG_RETURN(0);
}
int Bank::increaseSystemValue2(SystemValueId sysValId, Uint64 &value){
@@ -2294,6 +2302,10 @@ int Bank::getCurrTime(Uint64 &time){
return readSystemValue(CurrentTime, time);
}
+int Bank::prepareGetCurrTimeOp(NdbConnection *pTrans, Uint64 &time){
+ return prepareReadSystemValueOp(pTrans, CurrentTime, time);
+}
+
int Bank::performSumAccounts(int maxSleepBetweenSums, int yield){
if (init() != NDBT_OK)
diff --git a/ndb/test/ndbapi/bank/Bank.hpp b/ndb/test/ndbapi/bank/Bank.hpp
index e6816fd7111..34c5ff51cc2 100644
--- a/ndb/test/ndbapi/bank/Bank.hpp
+++ b/ndb/test/ndbapi/bank/Bank.hpp
@@ -29,7 +29,7 @@ public:
Bank();
- int createAndLoadBank(bool overWrite);
+ int createAndLoadBank(bool overWrite, int num_accounts=10);
int dropBank();
int performTransactions(int maxSleepBetweenTrans = 20, int yield=0);
@@ -118,6 +118,9 @@ private:
int incCurrTime(Uint64 &value);
int getCurrTime(Uint64 &time);
+ int prepareReadSystemValueOp(NdbConnection*, SystemValueId sysValId, Uint64 &time);
+ int prepareGetCurrTimeOp(NdbConnection*, Uint64 &time);
+
int createTables();
int createTable(const char* tabName);
diff --git a/ndb/test/ndbapi/bank/BankLoad.cpp b/ndb/test/ndbapi/bank/BankLoad.cpp
index bbaac27735b..39dc8097115 100644
--- a/ndb/test/ndbapi/bank/BankLoad.cpp
+++ b/ndb/test/ndbapi/bank/BankLoad.cpp
@@ -53,7 +53,7 @@ int Bank::getNumAccountTypes(){
return accountTypesSize;
}
-int Bank::createAndLoadBank(bool ovrWrt){
+int Bank::createAndLoadBank(bool ovrWrt, int num_accounts){
m_ndb.init();
if (m_ndb.waitUntilReady() != 0)
@@ -78,7 +78,7 @@ int Bank::createAndLoadBank(bool ovrWrt){
if (loadAccountType() != NDBT_OK)
return NDBT_FAILED;
- if (loadAccount(10) != NDBT_OK)
+ if (loadAccount(num_accounts) != NDBT_OK)
return NDBT_FAILED;
if (loadSystemValues() != NDBT_OK)
diff --git a/ndb/test/ndbapi/bank/bankCreator.cpp b/ndb/test/ndbapi/bank/bankCreator.cpp
index 5331ec6ba69..301d8bda6d2 100644
--- a/ndb/test/ndbapi/bank/bankCreator.cpp
+++ b/ndb/test/ndbapi/bank/bankCreator.cpp
@@ -27,6 +27,7 @@
int main(int argc, const char** argv){
+ ndb_init();
int _help = 0;
struct getargs args[] = {
diff --git a/ndb/test/ndbapi/bank/bankMakeGL.cpp b/ndb/test/ndbapi/bank/bankMakeGL.cpp
index 54bc559fbf9..9e2762ed8ae 100644
--- a/ndb/test/ndbapi/bank/bankMakeGL.cpp
+++ b/ndb/test/ndbapi/bank/bankMakeGL.cpp
@@ -27,6 +27,7 @@
int main(int argc, const char** argv){
+ ndb_init();
int _help = 0;
struct getargs args[] = {
diff --git a/ndb/test/ndbapi/bank/bankSumAccounts.cpp b/ndb/test/ndbapi/bank/bankSumAccounts.cpp
index c0a903f9034..b576161b27b 100644
--- a/ndb/test/ndbapi/bank/bankSumAccounts.cpp
+++ b/ndb/test/ndbapi/bank/bankSumAccounts.cpp
@@ -27,6 +27,7 @@
int main(int argc, const char** argv){
+ ndb_init();
int _help = 0;
struct getargs args[] = {
diff --git a/ndb/test/ndbapi/bank/bankTimer.cpp b/ndb/test/ndbapi/bank/bankTimer.cpp
index ba3165fccb4..874afd9c21e 100644
--- a/ndb/test/ndbapi/bank/bankTimer.cpp
+++ b/ndb/test/ndbapi/bank/bankTimer.cpp
@@ -28,6 +28,7 @@
int main(int argc, const char** argv){
+ ndb_init();
int _help = 0;
int _wait = 30;
diff --git a/ndb/test/ndbapi/bank/bankTransactionMaker.cpp b/ndb/test/ndbapi/bank/bankTransactionMaker.cpp
index fe9b53e0c8d..e5ff9aeb918 100644
--- a/ndb/test/ndbapi/bank/bankTransactionMaker.cpp
+++ b/ndb/test/ndbapi/bank/bankTransactionMaker.cpp
@@ -28,6 +28,7 @@
int main(int argc, const char** argv){
+ ndb_init();
int _help = 0;
int _wait = 20;
diff --git a/ndb/test/ndbapi/bank/bankValidateAllGLs.cpp b/ndb/test/ndbapi/bank/bankValidateAllGLs.cpp
index f9d974bb5f7..cf298ecc8e3 100644
--- a/ndb/test/ndbapi/bank/bankValidateAllGLs.cpp
+++ b/ndb/test/ndbapi/bank/bankValidateAllGLs.cpp
@@ -28,6 +28,7 @@
int main(int argc, const char** argv){
+ ndb_init();
int _help = 0;
struct getargs args[] = {
diff --git a/ndb/test/ndbapi/bank/testBank.cpp b/ndb/test/ndbapi/bank/testBank.cpp
index 77ac1172d7c..3ef2799cd3c 100644
--- a/ndb/test/ndbapi/bank/testBank.cpp
+++ b/ndb/test/ndbapi/bank/testBank.cpp
@@ -141,6 +141,7 @@ TESTCASE("Bank",
NDBT_TESTSUITE_END(testBank);
int main(int argc, const char** argv){
+ ndb_init();
// Tables should not be auto created
testBank.setCreateTable(false);
diff --git a/ndb/test/ndbapi/benchronja.cpp b/ndb/test/ndbapi/benchronja.cpp
index ce0aee35e8f..91b2a041186 100644
--- a/ndb/test/ndbapi/benchronja.cpp
+++ b/ndb/test/ndbapi/benchronja.cpp
@@ -66,6 +66,7 @@ static int ThreadReady[MAXTHREADS];
static int ThreadStart[MAXTHREADS];
NDB_COMMAND(benchronja, "benchronja", "benchronja", "benchronja", 65535){
+ ndb_init();
ThreadNdb tabThread[MAXTHREADS];
int i = 0 ;
diff --git a/ndb/test/ndbapi/bulk_copy.cpp b/ndb/test/ndbapi/bulk_copy.cpp
index 18881cae216..8821a92fb27 100644
--- a/ndb/test/ndbapi/bulk_copy.cpp
+++ b/ndb/test/ndbapi/bulk_copy.cpp
@@ -221,6 +221,7 @@ int insertFile(Ndb* pNdb,
int main(int argc, const char** argv){
+ ndb_init();
const char* _tabname = NULL;
int _help = 0;
diff --git a/ndb/test/ndbapi/cdrserver.cpp b/ndb/test/ndbapi/cdrserver.cpp
index 8354d28f53f..8d15061e94b 100644
--- a/ndb/test/ndbapi/cdrserver.cpp
+++ b/ndb/test/ndbapi/cdrserver.cpp
@@ -113,6 +113,7 @@ using namespace std;
int main(int argc, const char** argv)
{
+ ndb_init();
/******** NDB ***********/
/*
Ndb MyNdb( "TEST_DB" );
diff --git a/ndb/test/ndbapi/celloDb.cpp b/ndb/test/ndbapi/celloDb.cpp
index ec61e783585..2d6401c355a 100644
--- a/ndb/test/ndbapi/celloDb.cpp
+++ b/ndb/test/ndbapi/celloDb.cpp
@@ -73,6 +73,7 @@ static int failed = 0 ;
NDB_COMMAND(celloDb, "celloDb", "celloDb", "celloDb", 65535)
{
+ ndb_init();
int tTableId;
int i;
diff --git a/ndb/test/ndbapi/create_all_tabs.cpp b/ndb/test/ndbapi/create_all_tabs.cpp
index 55d04888144..97236b98b36 100644
--- a/ndb/test/ndbapi/create_all_tabs.cpp
+++ b/ndb/test/ndbapi/create_all_tabs.cpp
@@ -25,6 +25,7 @@
int main(int argc, const char** argv){
+ ndb_init();
int _temp = false;
int _help = 0;
diff --git a/ndb/test/ndbapi/create_tab.cpp b/ndb/test/ndbapi/create_tab.cpp
index c2e3b7f64ea..f3f18982ed0 100644
--- a/ndb/test/ndbapi/create_tab.cpp
+++ b/ndb/test/ndbapi/create_tab.cpp
@@ -25,6 +25,7 @@
int main(int argc, const char** argv){
+ ndb_init();
int _temp = false;
int _help = 0;
diff --git a/ndb/test/ndbapi/drop_all_tabs.cpp b/ndb/test/ndbapi/drop_all_tabs.cpp
index 59c57396acd..c024a81a5e6 100644
--- a/ndb/test/ndbapi/drop_all_tabs.cpp
+++ b/ndb/test/ndbapi/drop_all_tabs.cpp
@@ -23,6 +23,7 @@
#include <getarg.h>
int main(int argc, const char** argv){
+ ndb_init();
int _help = 0;
struct getargs args[] = {
diff --git a/ndb/test/ndbapi/flexAsynch.cpp b/ndb/test/ndbapi/flexAsynch.cpp
index 9192ec21b93..8c0ba46130c 100644
--- a/ndb/test/ndbapi/flexAsynch.cpp
+++ b/ndb/test/ndbapi/flexAsynch.cpp
@@ -145,6 +145,7 @@ tellThreads(StartType what)
NDB_COMMAND(flexAsynch, "flexAsynch", "flexAsynch", "flexAsynch", 65535)
{
+ ndb_init();
ThreadNdb* pThreadData;
int tLoops=0, i;
int returnValue = NDBT_OK;
diff --git a/ndb/test/ndbapi/flexBench.cpp b/ndb/test/ndbapi/flexBench.cpp
index 38c8f6e280f..b19944498f4 100644
--- a/ndb/test/ndbapi/flexBench.cpp
+++ b/ndb/test/ndbapi/flexBench.cpp
@@ -281,6 +281,7 @@ tellThreads(ThreadData* pt, StartType what)
NDB_COMMAND(flexBench, "flexBench", "flexBench", "flexbench", 65535)
{
+ ndb_init();
ThreadData* pThreadsData;
int tLoops = 0, i;
int returnValue = NDBT_OK;
diff --git a/ndb/test/ndbapi/flexHammer.cpp b/ndb/test/ndbapi/flexHammer.cpp
index c1c47923de9..80cc7c5a53f 100644
--- a/ndb/test/ndbapi/flexHammer.cpp
+++ b/ndb/test/ndbapi/flexHammer.cpp
@@ -178,6 +178,7 @@ tellThreads(ThreadNdb* threadArrayP, const StartType what)
NDB_COMMAND(flexHammer, "flexHammer", "flexHammer", "flexHammer", 65535)
//main(int argc, const char** argv)
{
+ ndb_init();
ThreadNdb* pThreads = NULL; // Pointer to thread data array
Ndb* pMyNdb = NULL; // Pointer to Ndb object
int tLoops = 0;
diff --git a/ndb/test/ndbapi/flexScan.cpp b/ndb/test/ndbapi/flexScan.cpp
index 5b5b4dde730..b09d71fb010 100644
--- a/ndb/test/ndbapi/flexScan.cpp
+++ b/ndb/test/ndbapi/flexScan.cpp
@@ -297,6 +297,7 @@ static int checkThreadResults(ThreadNdb *threadArrayP, char *action)
NDB_COMMAND(flexScan, "flexScan", "flexScan", "flexScan", 65535)
{
+ ndb_init();
ThreadNdb* pThreads = NULL;
Ndb* pMyNdb = NULL;
int tLoops = 0;
diff --git a/ndb/test/ndbapi/flexTT.cpp b/ndb/test/ndbapi/flexTT.cpp
index c0ff31d1677..162fc080218 100644
--- a/ndb/test/ndbapi/flexTT.cpp
+++ b/ndb/test/ndbapi/flexTT.cpp
@@ -171,6 +171,7 @@ tellThreads(StartType what)
NDB_COMMAND(flexTT, "flexTT", "flexTT", "flexTT", 65535)
{
+ ndb_init();
ThreadNdb* pThreadData;
int returnValue = NDBT_OK;
int i;
diff --git a/ndb/test/ndbapi/flexTimedAsynch.cpp b/ndb/test/ndbapi/flexTimedAsynch.cpp
index 761be53fdd3..27380cc79fd 100644
--- a/ndb/test/ndbapi/flexTimedAsynch.cpp
+++ b/ndb/test/ndbapi/flexTimedAsynch.cpp
@@ -174,6 +174,7 @@ void deleteAttributeSpace(){
NDB_COMMAND(flexTimedAsynch, "flexTimedAsynch", "flexTimedAsynch [-tpoilcas]", "flexTimedAsynch", 65535)
{
+ ndb_init();
ThreadNdb tabThread[MAXTHREADS];
int tLoops=0;
int returnValue;
diff --git a/ndb/test/ndbapi/flex_bench_mysql.cpp b/ndb/test/ndbapi/flex_bench_mysql.cpp
index 7cc883ab3e6..8e1fbcd9058 100644
--- a/ndb/test/ndbapi/flex_bench_mysql.cpp
+++ b/ndb/test/ndbapi/flex_bench_mysql.cpp
@@ -308,6 +308,7 @@ tellThreads(ThreadData* pt, StartType what)
NDB_COMMAND(flexBench, "flexBench", "flexBench", "flexbench", 65535)
{
+ ndb_init();
ThreadData* pThreadsData;
int tLoops = 0;
int returnValue = NDBT_OK;
diff --git a/ndb/test/ndbapi/index.cpp b/ndb/test/ndbapi/index.cpp
index 508186de529..c22da594164 100644
--- a/ndb/test/ndbapi/index.cpp
+++ b/ndb/test/ndbapi/index.cpp
@@ -81,63 +81,63 @@ static void createTable(Ndb &myNdb, bool storeInACC, bool twoKey, bool longKey)
int res;
column.setName("NAME");
- column.setPrimaryKey(true);
column.setType(NdbDictionary::Column::Char);
column.setLength((longKey)?
1024 // 1KB => long key
:12);
+ column.setPrimaryKey(true);
column.setNullable(false);
table.addColumn(column);
if (twoKey) {
column.setName("KEY2");
- column.setPrimaryKey(true);
column.setType(NdbDictionary::Column::Unsigned);
column.setLength(1);
+ column.setPrimaryKey(true);
column.setNullable(false);
table.addColumn(column);
}
column.setName("PNUM1");
- column.setPrimaryKey(false);
column.setType(NdbDictionary::Column::Unsigned);
column.setLength(1);
+ column.setPrimaryKey(false);
column.setNullable(false);
table.addColumn(column);
column.setName("PNUM2");
- column.setPrimaryKey(false);
column.setType(NdbDictionary::Column::Unsigned);
column.setLength(1);
+ column.setPrimaryKey(false);
column.setNullable(false);
table.addColumn(column);
column.setName("PNUM3");
- column.setPrimaryKey(false);
column.setType(NdbDictionary::Column::Unsigned);
column.setLength(1);
+ column.setPrimaryKey(false);
column.setNullable(false);
table.addColumn(column);
column.setName("PNUM4");
- column.setPrimaryKey(false);
column.setType(NdbDictionary::Column::Unsigned);
column.setLength(1);
+ column.setPrimaryKey(false);
column.setNullable(false);
table.addColumn(column);
column.setName("AGE");
- column.setPrimaryKey(false);
column.setType(NdbDictionary::Column::Unsigned);
column.setLength(1);
+ column.setPrimaryKey(false);
column.setNullable(false);
table.addColumn(column);
column.setName("STRING_AGE");
- column.setPrimaryKey(false);
column.setType(NdbDictionary::Column::Char);
column.setLength(1);
column.setLength(256);
+ column.setPrimaryKey(false);
column.setNullable(false);
table.addColumn(column);
@@ -771,6 +771,7 @@ static void dropIndex(Ndb &myNdb, unsigned int noOfIndexes)
NDB_COMMAND(indexTest, "indexTest", "indexTest", "indexTest", 65535)
{
+ ndb_init();
bool createTableOp, createIndexOp, dropIndexOp, insertOp, updateOp, deleteOp, readOp, readIndexOp, updateIndexOp, deleteIndexOp, twoKey, longKey;
unsigned int noOfTuples = 1;
unsigned int noOfOperations = 1;
diff --git a/ndb/test/ndbapi/index2.cpp b/ndb/test/ndbapi/index2.cpp
index e49113d2f1b..f739468d7df 100644
--- a/ndb/test/ndbapi/index2.cpp
+++ b/ndb/test/ndbapi/index2.cpp
@@ -81,16 +81,16 @@ static void createTable(Ndb &myNdb, bool storeInACC, bool twoKey, bool longKey)
int res;
column.setName("X");
- column.setPrimaryKey(true);
column.setType(NdbDictionary::Column::Unsigned);
column.setLength(1);
+ column.setPrimaryKey(true);
column.setNullable(false);
table.addColumn(column);
column.setName("Y");
- column.setPrimaryKey(false);
column.setType(NdbDictionary::Column::Unsigned);
column.setLength(1);
+ column.setPrimaryKey(false);
column.setNullable(false);
table.addColumn(column);
@@ -608,6 +608,7 @@ static void dropIndex(Ndb &myNdb, unsigned int noOfIndexes)
NDB_COMMAND(indexTest, "indexTest", "indexTest", "indexTest", 65535)
{
+ ndb_init();
bool createTableOp, createIndexOp, dropIndexOp, insertOp, updateOp, deleteOp, readOp, readIndexOp, updateIndexOp, deleteIndexOp, twoKey, longKey;
unsigned int noOfTuples = 1;
unsigned int noOfOperations = 1;
diff --git a/ndb/test/ndbapi/initronja.cpp b/ndb/test/ndbapi/initronja.cpp
index b3215104822..3ce274e4319 100644
--- a/ndb/test/ndbapi/initronja.cpp
+++ b/ndb/test/ndbapi/initronja.cpp
@@ -46,6 +46,7 @@ static char attrName[MAXATTR][MAXSTRLEN];
inline int InsertRecords(Ndb*, int) ;
NDB_COMMAND(initronja, "initronja", "initronja", "initronja", 65535){
+ ndb_init();
Ndb* pNdb = NULL ;
NdbSchemaCon *MySchemaTransaction = NULL ;
diff --git a/ndb/test/ndbapi/interpreterInTup.cpp b/ndb/test/ndbapi/interpreterInTup.cpp
index 47960cd5d12..20d84e6e96d 100644
--- a/ndb/test/ndbapi/interpreterInTup.cpp
+++ b/ndb/test/ndbapi/interpreterInTup.cpp
@@ -105,6 +105,7 @@ int bTestPassed = 0;
int main(int argc, const char** argv) {
+ ndb_init();
int operationType = 0;
int tupTest = 0;
diff --git a/ndb/test/ndbapi/mainAsyncGenerator.cpp b/ndb/test/ndbapi/mainAsyncGenerator.cpp
index f613c66d07b..16cb50e160f 100644
--- a/ndb/test/ndbapi/mainAsyncGenerator.cpp
+++ b/ndb/test/ndbapi/mainAsyncGenerator.cpp
@@ -282,6 +282,7 @@ threadRoutine(void *arg)
NDB_COMMAND(DbAsyncGenerator, "DbAsyncGenerator",
"DbAsyncGenerator", "DbAsyncGenerator", 65535)
{
+ ndb_init();
int i;
int j;
int k;
diff --git a/ndb/test/ndbapi/msa.cpp b/ndb/test/ndbapi/msa.cpp
index 7a734f9cb79..e39f7a8c64a 100644
--- a/ndb/test/ndbapi/msa.cpp
+++ b/ndb/test/ndbapi/msa.cpp
@@ -971,6 +971,7 @@ void ShowHelp(const char* szCmd)
int main(int argc, char* argv[])
{
+ ndb_init();
int iRes = -1;
g_nNumThreads = 0;
g_nMaxCallsPerSecond = 0;
diff --git a/ndb/test/ndbapi/restarter.cpp b/ndb/test/ndbapi/restarter.cpp
index 9a522f5dcac..d6831494b48 100644
--- a/ndb/test/ndbapi/restarter.cpp
+++ b/ndb/test/ndbapi/restarter.cpp
@@ -28,6 +28,7 @@
#include <NDBT.hpp>
int main(int argc, const char** argv){
+ ndb_init();
const char* _hostName = NULL;
int _loops = 10;
diff --git a/ndb/test/ndbapi/restarter2.cpp b/ndb/test/ndbapi/restarter2.cpp
index f2bcf6f8e7b..846748a7bba 100644
--- a/ndb/test/ndbapi/restarter2.cpp
+++ b/ndb/test/ndbapi/restarter2.cpp
@@ -26,6 +26,7 @@
#include <NDBT.hpp>
int main(int argc, const char** argv){
+ ndb_init();
const char* _hostName = NULL;
int _loops = 10;
diff --git a/ndb/test/ndbapi/restarts.cpp b/ndb/test/ndbapi/restarts.cpp
index 0ec2883d53c..184e754de4a 100644
--- a/ndb/test/ndbapi/restarts.cpp
+++ b/ndb/test/ndbapi/restarts.cpp
@@ -27,6 +27,7 @@
#include <NDBT.hpp>
int main(int argc, const char** argv){
+ ndb_init();
const char* _restartName = NULL;
int _loops = 1;
diff --git a/ndb/test/ndbapi/size.cpp b/ndb/test/ndbapi/size.cpp
index c506771ebde..ff178b11d68 100644
--- a/ndb/test/ndbapi/size.cpp
+++ b/ndb/test/ndbapi/size.cpp
@@ -19,6 +19,7 @@
int main(void)
{
+ ndb_init();
printf("cdrstruct=%d\n",sizeof(struct cdr_record));
printf("long int=%d\n",sizeof(long int));
printf("int=%d\n",sizeof(int));
diff --git a/ndb/test/ndbapi/slow_select.cpp b/ndb/test/ndbapi/slow_select.cpp
index a953e1539d0..625dbc34457 100644
--- a/ndb/test/ndbapi/slow_select.cpp
+++ b/ndb/test/ndbapi/slow_select.cpp
@@ -36,6 +36,7 @@ static void lookup();
int
main(void){
+ ndb_init();
Ndb g_ndb("test");
g_ndb.init(1024);
diff --git a/ndb/test/ndbapi/testBackup.cpp b/ndb/test/ndbapi/testBackup.cpp
index d328a7db292..509cd4780bf 100644
--- a/ndb/test/ndbapi/testBackup.cpp
+++ b/ndb/test/ndbapi/testBackup.cpp
@@ -215,7 +215,7 @@ int runDropTable(NDBT_Context* ctx, NDBT_Step* step){
int runCreateBank(NDBT_Context* ctx, NDBT_Step* step){
Bank bank;
int overWriteExisting = true;
- if (bank.createAndLoadBank(overWriteExisting) != NDBT_OK)
+ if (bank.createAndLoadBank(overWriteExisting, 10) != NDBT_OK)
return NDBT_FAILED;
return NDBT_OK;
}
@@ -428,6 +428,15 @@ TESTCASE("BackupBank",
INITIALIZER(runCreateBank);
STEP(runBankTimer);
STEP(runBankTransactions);
+ STEP(runBankTransactions);
+ STEP(runBankTransactions);
+ STEP(runBankTransactions);
+ STEP(runBankTransactions);
+ STEP(runBankTransactions);
+ STEP(runBankTransactions);
+ STEP(runBankTransactions);
+ STEP(runBankTransactions);
+ STEP(runBankTransactions);
STEP(runBankGL);
// TODO STEP(runBankSum);
STEP(runBackupBank);
@@ -473,6 +482,7 @@ TESTCASE("FailSlave",
NDBT_TESTSUITE_END(testBackup);
int main(int argc, const char** argv){
+ ndb_init();
return testBackup.execute(argc, argv);
}
diff --git a/ndb/test/ndbapi/testBasic.cpp b/ndb/test/ndbapi/testBasic.cpp
index 26622f9b066..7d03016b87a 100644
--- a/ndb/test/ndbapi/testBasic.cpp
+++ b/ndb/test/ndbapi/testBasic.cpp
@@ -1278,6 +1278,7 @@ TESTCASE("MassiveTransaction",
NDBT_TESTSUITE_END(testBasic);
int main(int argc, const char** argv){
+ ndb_init();
return testBasic.execute(argc, argv);
}
diff --git a/ndb/test/ndbapi/testBasicAsynch.cpp b/ndb/test/ndbapi/testBasicAsynch.cpp
index a97920e53da..6daa22fdc6a 100644
--- a/ndb/test/ndbapi/testBasicAsynch.cpp
+++ b/ndb/test/ndbapi/testBasicAsynch.cpp
@@ -181,6 +181,7 @@ TESTCASE("PkDeleteAsynch",
NDBT_TESTSUITE_END(testBasicAsynch);
int main(int argc, const char** argv){
+ ndb_init();
return testBasicAsynch.execute(argc, argv);
}
diff --git a/ndb/test/ndbapi/testBlobs.cpp b/ndb/test/ndbapi/testBlobs.cpp
index 64881ca39ab..e18f4a8bd1a 100644
--- a/ndb/test/ndbapi/testBlobs.cpp
+++ b/ndb/test/ndbapi/testBlobs.cpp
@@ -1338,6 +1338,7 @@ static struct {
NDB_COMMAND(testOdbcDriver, "testBlobs", "testBlobs", "testBlobs", 65535)
{
+ ndb_init();
while (++argv, --argc > 0) {
const char* arg = argv[0];
if (strcmp(arg, "-batch") == 0) {
diff --git a/ndb/test/ndbapi/testDataBuffers.cpp b/ndb/test/ndbapi/testDataBuffers.cpp
index 2e29dbb0d7b..94658d5c6b9 100644
--- a/ndb/test/ndbapi/testDataBuffers.cpp
+++ b/ndb/test/ndbapi/testDataBuffers.cpp
@@ -545,6 +545,7 @@ testcase(int flag)
NDB_COMMAND(testDataBuffers, "testDataBuffers", "testDataBuffers", "testDataBuffers", 65535)
{
+ ndb_init();
while (++argv, --argc > 0) {
char const* p = argv[0];
if (*p++ != '-' || strlen(p) != 1)
diff --git a/ndb/test/ndbapi/testDeadlock.cpp b/ndb/test/ndbapi/testDeadlock.cpp
index f51b3cea1e5..a445823b8a8 100644
--- a/ndb/test/ndbapi/testDeadlock.cpp
+++ b/ndb/test/ndbapi/testDeadlock.cpp
@@ -491,6 +491,7 @@ wl1822_main(char scantx)
NDB_COMMAND(testOdbcDriver, "testDeadlock", "testDeadlock", "testDeadlock", 65535)
{
+ ndb_init();
while (++argv, --argc > 0) {
const char* arg = argv[0];
if (strcmp(arg, "-scan") == 0) {
diff --git a/ndb/test/ndbapi/testDict.cpp b/ndb/test/ndbapi/testDict.cpp
index a0c7bb1414b..7cba5ce4cc8 100644
--- a/ndb/test/ndbapi/testDict.cpp
+++ b/ndb/test/ndbapi/testDict.cpp
@@ -1128,9 +1128,9 @@ runCreateAutoincrementTable(NDBT_Context* ctx, NDBT_Step* step){
myTable.setName(tabname);
myColumn.setName("ATTR1");
- myColumn.setPrimaryKey(true);
myColumn.setType(NdbDictionary::Column::Unsigned);
myColumn.setLength(1);
+ myColumn.setPrimaryKey(true);
myColumn.setNullable(false);
myColumn.setAutoIncrement(true);
if (startvalue != ~0) // check that default value starts with 1
@@ -1576,6 +1576,7 @@ TESTCASE("DictionaryPerf",
NDBT_TESTSUITE_END(testDict);
int main(int argc, const char** argv){
+ ndb_init();
// Tables should not be auto created
testDict.setCreateTable(false);
myRandom48Init(NdbTick_CurrentMillisecond());
diff --git a/ndb/test/ndbapi/testGrep.cpp b/ndb/test/ndbapi/testGrep.cpp
index 0bf84cb4ec8..713aefbeafa 100644
--- a/ndb/test/ndbapi/testGrep.cpp
+++ b/ndb/test/ndbapi/testGrep.cpp
@@ -533,6 +533,7 @@ TESTCASE("FailSlave",
NDBT_TESTSUITE_END(testGrep);
int main(int argc, const char** argv){
+ ndb_init();
return testGrep.execute(argc, argv);
}
diff --git a/ndb/test/ndbapi/testGrepVerify.cpp b/ndb/test/ndbapi/testGrepVerify.cpp
index 05445c1ba1b..52dcda9a162 100644
--- a/ndb/test/ndbapi/testGrepVerify.cpp
+++ b/ndb/test/ndbapi/testGrepVerify.cpp
@@ -40,6 +40,7 @@
continue; }
int main(int argc, const char** argv){
+ ndb_init();
const char * connectString = NULL;
diff --git a/ndb/test/ndbapi/testIndex.cpp b/ndb/test/ndbapi/testIndex.cpp
index 6ebbfd8b680..bef3b310c96 100644
--- a/ndb/test/ndbapi/testIndex.cpp
+++ b/ndb/test/ndbapi/testIndex.cpp
@@ -1528,6 +1528,7 @@ TESTCASE("UniqueNull",
NDBT_TESTSUITE_END(testIndex);
int main(int argc, const char** argv){
+ ndb_init();
return testIndex.execute(argc, argv);
}
diff --git a/ndb/test/ndbapi/testInterpreter.cpp b/ndb/test/ndbapi/testInterpreter.cpp
index 9c584d6f581..0baba33d2b2 100644
--- a/ndb/test/ndbapi/testInterpreter.cpp
+++ b/ndb/test/ndbapi/testInterpreter.cpp
@@ -224,6 +224,7 @@ TESTCASE("NdbErrorOperation",
NDBT_TESTSUITE_END(testInterpreter);
int main(int argc, const char** argv){
+ ndb_init();
// TABLE("T1");
return testInterpreter.execute(argc, argv);
}
diff --git a/ndb/test/ndbapi/testLcp.cpp b/ndb/test/ndbapi/testLcp.cpp
new file mode 100644
index 00000000000..c92be091a97
--- /dev/null
+++ b/ndb/test/ndbapi/testLcp.cpp
@@ -0,0 +1,320 @@
+
+#include <NDBT.hpp>
+#include <NdbApi.hpp>
+#include <NdbRestarter.hpp>
+#include <HugoOperations.hpp>
+#include <UtilTransactions.hpp>
+#include <signaldata/DumpStateOrd.hpp>
+
+struct CASE
+{
+ bool start_row;
+ bool end_row;
+ bool curr_row;
+ const char * op1;
+ const char * op2;
+ int val;
+};
+
+static CASE g_ops[] =
+{
+ { false, true, false, "INSERT", 0, 0 },
+ { false, true, false, "INSERT", "UPDATE", 0 },
+ { false, false, false, "INSERT", "DELETE", 0 },
+ { true, true, false, "UPDATE", 0, 0 },
+ { true, true, false, "UPDATE", "UPDATE", 0 },
+ { true, false, false, "UPDATE", "DELETE", 0 },
+ { true, false, false, "DELETE", 0, 0 },
+ { true, true, false, "DELETE", "INSERT", 0 }
+};
+const size_t OP_COUNT = (sizeof(g_ops)/sizeof(g_ops[0]));
+
+static Ndb* g_ndb = 0;
+static CASE* g_cases;
+static HugoOperations* g_hugo_ops;
+
+static int g_rows = 1000;
+static int g_setup_tables = 1;
+static const char * g_tablename = "T1";
+static const NdbDictionary::Table* g_table = 0;
+static NdbRestarter g_restarter;
+
+static int init_ndb(int argc, char** argv);
+static int parse_args(int argc, char** argv);
+static int connect_ndb();
+static int drop_all_tables();
+static int load_table();
+static int pause_lcp();
+static int do_op(int row);
+static int continue_lcp(int error);
+static int commit();
+static int restart();
+static int validate();
+
+#define require(x) { bool b = x; if(!b){g_err << __LINE__ << endl; abort();}}
+
+int
+main(int argc, char ** argv){
+
+ require(!init_ndb(argc, argv));
+ require(!parse_args(argc, argv));
+ require(!connect_ndb());
+
+ if(g_setup_tables){
+ require(!drop_all_tables());
+
+ if(NDBT_Tables::createTable(g_ndb, g_tablename) != 0){
+ exit(-1);
+ }
+ }
+
+ g_table = g_ndb->getDictionary()->getTable(g_tablename);
+ if(g_table == 0){
+ g_err << "Failed to retreive table: " << g_tablename << endl;
+ exit(-1);
+ }
+ require(g_hugo_ops = new HugoOperations(* g_table));
+ require(!g_hugo_ops->startTransaction(g_ndb));
+
+ g_cases= new CASE[g_rows];
+ require(!load_table());
+
+ g_info << "Performing all ops wo/ inteference of LCP" << endl;
+
+ g_info << "Testing pre LCP operations, ZLCP_OP_WRITE_RT_BREAK" << endl;
+ g_info << " where ZLCP_OP_WRITE_RT_BREAK is finished before SAVE_PAGES"
+ << endl;
+ require(!pause_lcp());
+ for(size_t j = 0; j<g_rows; j++){
+ require(!do_op(j));
+ }
+ require(!continue_lcp(5900));
+ require(!commit());
+ require(!restart());
+ require(!validate());
+
+ g_info << "Testing pre LCP operations, ZLCP_OP_WRITE_RT_BREAK" << endl;
+ g_info << " where ZLCP_OP_WRITE_RT_BREAK is finished after SAVE_PAGES"
+ << endl;
+ require(!load_table());
+ require(!pause_lcp());
+ for(size_t j = 0; j<g_rows; j++){
+ require(!do_op(j));
+ }
+ require(!continue_lcp(5901));
+ require(!commit());
+ require(!restart());
+ require(!validate());
+
+ g_info << "Testing pre LCP operations, undo-ed at commit" << endl;
+ require(!load_table());
+ require(!pause_lcp());
+ for(size_t j = 0; j<g_rows; j++){
+ require(!do_op(j));
+ }
+ require(!continue_lcp(5902));
+ require(!commit());
+ require(!continue_lcp(5903));
+ require(!restart());
+ require(!validate());
+}
+
+static int init_ndb(int argc, char** argv)
+{
+ return 0;
+}
+
+static int parse_args(int argc, char** argv)
+{
+ return 0;
+}
+
+static int connect_ndb()
+{
+ g_ndb = new Ndb("TEST_DB");
+ g_ndb->init();
+ if(g_ndb->waitUntilReady(30) == 0){
+ int args[] = { DumpStateOrd::DihMaxTimeBetweenLCP };
+ return g_restarter.dumpStateAllNodes(args, 1);
+ }
+ return -1;
+}
+
+static int disconnect_ndb()
+{
+ delete g_ndb;
+ g_ndb = 0;
+ g_table = 0;
+ return 0;
+}
+
+static int drop_all_tables()
+{
+ NdbDictionary::Dictionary * dict = g_ndb->getDictionary();
+ require(dict);
+
+ BaseString db = g_ndb->getDatabaseName();
+ BaseString schema = g_ndb->getSchemaName();
+
+ NdbDictionary::Dictionary::List list;
+ if (dict->listObjects(list, NdbDictionary::Object::TypeUndefined) == -1){
+ g_err << "Failed to list tables: " << endl
+ << dict->getNdbError() << endl;
+ return -1;
+ }
+ for (unsigned i = 0; i < list.count; i++) {
+ NdbDictionary::Dictionary::List::Element& elt = list.elements[i];
+ switch (elt.type) {
+ case NdbDictionary::Object::SystemTable:
+ case NdbDictionary::Object::UserTable:
+ g_ndb->setDatabaseName(elt.database);
+ g_ndb->setSchemaName(elt.schema);
+ if(dict->dropTable(elt.name) != 0){
+ g_err << "Failed to drop table: "
+ << elt.database << "/" << elt.schema << "/" << elt.name <<endl;
+ g_err << dict->getNdbError() << endl;
+ return -1;
+ }
+ break;
+ case NdbDictionary::Object::UniqueHashIndex:
+ case NdbDictionary::Object::OrderedIndex:
+ case NdbDictionary::Object::HashIndexTrigger:
+ case NdbDictionary::Object::IndexTrigger:
+ case NdbDictionary::Object::SubscriptionTrigger:
+ case NdbDictionary::Object::ReadOnlyConstraint:
+ default:
+ break;
+ }
+ }
+
+ g_ndb->setDatabaseName(db.c_str());
+ g_ndb->setSchemaName(schema.c_str());
+
+ return 0;
+}
+
+static int load_table()
+{
+ UtilTransactions clear(* g_table);
+ require(!clear.clearTable(g_ndb));
+
+ HugoOperations ops(* g_table);
+ require(!ops.startTransaction(g_ndb));
+ for(size_t i = 0; i<g_rows; i++){
+ g_cases[i] = g_ops[ i % OP_COUNT];
+ if(g_cases[i].start_row){
+ g_cases[i].curr_row = true;
+ g_cases[i].val = rand();
+ require(!ops.pkInsertRecord(g_ndb, i, 1, g_cases[i].val));
+ }
+ if((i+1) % 100 == 0){
+ require(!ops.execute_Commit(g_ndb));
+ require(!ops.getTransaction()->restart());
+ }
+ }
+ if((g_rows+1) % 100 != 0)
+ require(!ops.execute_Commit(g_ndb));
+ return 0;
+}
+
+static int pause_lcp()
+{
+ return 0;
+}
+
+static int do_op(int row)
+{
+ HugoOperations & ops = * g_hugo_ops;
+ if(strcmp(g_cases[row].op1, "INSERT") == 0){
+ require(!g_cases[row].curr_row);
+ g_cases[row].curr_row = true;
+ g_cases[row].val = rand();
+ require(!ops.pkInsertRecord(g_ndb, row, 1, g_cases[row].val));
+ } else if(strcmp(g_cases[row].op1, "UPDATE") == 0){
+ require(g_cases[row].curr_row);
+ g_cases[row].val = rand();
+ require(!ops.pkUpdateRecord(g_ndb, row, 1, g_cases[row].val));
+ } else if(strcmp(g_cases[row].op1, "DELETE") == 0){
+ require(g_cases[row].curr_row);
+ g_cases[row].curr_row = false;
+ require(!ops.pkDeleteRecord(g_ndb, row, 1));
+ }
+
+ require(!ops.execute_NoCommit(g_ndb));
+
+ if(g_cases[row].op2 == 0){
+ } else if(strcmp(g_cases[row].op2, "INSERT") == 0){
+ require(!g_cases[row].curr_row);
+ g_cases[row].curr_row = true;
+ g_cases[row].val = rand();
+ require(!ops.pkInsertRecord(g_ndb, row, 1, g_cases[row].val));
+ } else if(strcmp(g_cases[row].op2, "UPDATE") == 0){
+ require(g_cases[row].curr_row);
+ g_cases[row].val = rand();
+ require(!ops.pkUpdateRecord(g_ndb, row, 1, g_cases[row].val));
+ } else if(strcmp(g_cases[row].op2, "DELETE") == 0){
+ require(g_cases[row].curr_row);
+ g_cases[row].curr_row = false;
+ require(!ops.pkDeleteRecord(g_ndb, row, 1));
+ }
+
+ if(g_cases[row].op2 != 0)
+ require(!ops.execute_NoCommit(g_ndb));
+ return 0;
+}
+
+static int continue_lcp(int error)
+{
+ error = 0;
+ if(g_restarter.insertErrorInAllNodes(error) == 0){
+ int args[] = { DumpStateOrd::DihStartLcpImmediately };
+ return g_restarter.dumpStateAllNodes(args, 1);
+ }
+ return -1;
+}
+
+static int commit()
+{
+ HugoOperations & ops = * g_hugo_ops;
+ int res = ops.execute_Commit(g_ndb);
+ if(res == 0){
+ return ops.getTransaction()->restart();
+ }
+ return res;
+}
+
+static int restart()
+{
+ g_info << "Restarting cluster" << endl;
+ disconnect_ndb();
+ delete g_hugo_ops;
+
+ require(!g_restarter.restartAll());
+ require(!g_restarter.waitClusterStarted(30));
+ require(!connect_ndb());
+
+ g_table = g_ndb->getDictionary()->getTable(g_tablename);
+ require(g_table);
+ require(g_hugo_ops = new HugoOperations(* g_table));
+ require(!g_hugo_ops->startTransaction(g_ndb));
+ return 0;
+}
+
+static int validate()
+{
+ HugoOperations ops(* g_table);
+ for(size_t i = 0; i<g_rows; i++){
+ require(g_cases[i].curr_row == g_cases[i].end_row);
+ require(!ops.startTransaction(g_ndb));
+ ops.pkReadRecord(g_ndb, i, 1);
+ int res = ops.execute_Commit(g_ndb);
+ if(g_cases[i].curr_row){
+ require(res == 0 && ops.verifyUpdatesValue(g_cases[i].val) == 0);
+ } else {
+ require(res == 626);
+ }
+ ops.closeTransaction(g_ndb);
+ }
+ return 0;
+}
+
diff --git a/ndb/test/ndbapi/testMgm.cpp b/ndb/test/ndbapi/testMgm.cpp
index d5b9372cc9b..ef653d3f972 100644
--- a/ndb/test/ndbapi/testMgm.cpp
+++ b/ndb/test/ndbapi/testMgm.cpp
@@ -178,6 +178,7 @@ TESTCASE("SingleUserMode",
NDBT_TESTSUITE_END(testMgm);
int main(int argc, const char** argv){
+ ndb_init();
myRandom48Init(NdbTick_CurrentMillisecond());
return testMgm.execute(argc, argv);
}
diff --git a/ndb/test/ndbapi/testNdbApi.cpp b/ndb/test/ndbapi/testNdbApi.cpp
index 5b171d42578..47987629fe3 100644
--- a/ndb/test/ndbapi/testNdbApi.cpp
+++ b/ndb/test/ndbapi/testNdbApi.cpp
@@ -1006,6 +1006,7 @@ TESTCASE("NdbErrorOperation",
NDBT_TESTSUITE_END(testNdbApi);
int main(int argc, const char** argv){
+ ndb_init();
// TABLE("T1");
return testNdbApi.execute(argc, argv);
}
diff --git a/ndb/test/ndbapi/testNodeRestart.cpp b/ndb/test/ndbapi/testNodeRestart.cpp
index 89b38c78e71..6bfe59f8d3f 100644
--- a/ndb/test/ndbapi/testNodeRestart.cpp
+++ b/ndb/test/ndbapi/testNodeRestart.cpp
@@ -434,6 +434,7 @@ TESTCASE("StopOnError",
NDBT_TESTSUITE_END(testNodeRestart);
int main(int argc, const char** argv){
+ ndb_init();
#if 0
// It might be interesting to have longer defaults for num
// loops in this test
diff --git a/ndb/test/ndbapi/testOIBasic.cpp b/ndb/test/ndbapi/testOIBasic.cpp
index 29d03f0c33e..ac28b96af80 100644
--- a/ndb/test/ndbapi/testOIBasic.cpp
+++ b/ndb/test/ndbapi/testOIBasic.cpp
@@ -979,9 +979,9 @@ createtable(Par par)
for (unsigned k = 0; k < tab.m_cols; k++) {
const Col& col = tab.m_col[k];
NdbDictionary::Column c(col.m_name);
- c.setPrimaryKey(col.m_pk);
c.setType(col.m_type);
c.setLength(col.m_length);
+ c.setPrimaryKey(col.m_pk);
c.setNullable(col.m_nullable);
t.addColumn(c);
}
@@ -2236,9 +2236,8 @@ pkreadfast(Par par, unsigned count)
keyrow.calc(par, i);
CHK(keyrow.selrow(par) == 0);
NdbRecAttr* rec;
- CHK(con.getValue((Uint32)0, rec) == 0);
- CHK(con.executeScan() == 0);
// get 1st column
+ CHK(con.getValue((Uint32)0, rec) == 0);
CHK(con.execute(Commit) == 0);
con.closeTransaction();
}
@@ -3201,6 +3200,7 @@ runtest(Par par)
NDB_COMMAND(testOIBasic, "testOIBasic", "testOIBasic", "testOIBasic", 65535)
{
+ ndb_init();
while (++argv, --argc > 0) {
const char* arg = argv[0];
if (*arg != '-') {
diff --git a/ndb/test/ndbapi/testOperations.cpp b/ndb/test/ndbapi/testOperations.cpp
index bb58e69e898..ba41e1d1c40 100644
--- a/ndb/test/ndbapi/testOperations.cpp
+++ b/ndb/test/ndbapi/testOperations.cpp
@@ -230,6 +230,7 @@ runClearTable(NDBT_Context* ctx, NDBT_Step* step){
int
main(int argc, const char** argv){
+ ndb_init();
NDBT_TestSuite ts("testOperations");
for(Uint32 i = 0; i<sizeof(matrix)/sizeof(matrix[0]); i++){
diff --git a/ndb/test/ndbapi/testOrderedIndex.cpp b/ndb/test/ndbapi/testOrderedIndex.cpp
index 51cc53c9975..b3a75410646 100644
--- a/ndb/test/ndbapi/testOrderedIndex.cpp
+++ b/ndb/test/ndbapi/testOrderedIndex.cpp
@@ -218,6 +218,7 @@ NDBT_TESTSUITE_END(testOrderedIndex);
int
main(int argc, const char** argv)
{
+ ndb_init();
return testOrderedIndex.execute(argc, argv);
}
diff --git a/ndb/test/ndbapi/testReadPerf.cpp b/ndb/test/ndbapi/testReadPerf.cpp
index 412661c4ff8..7cf3755d66f 100644
--- a/ndb/test/ndbapi/testReadPerf.cpp
+++ b/ndb/test/ndbapi/testReadPerf.cpp
@@ -91,6 +91,7 @@ void print_result();
int
main(int argc, const char** argv){
+ ndb_init();
int verbose = 1;
int optind = 0;
diff --git a/ndb/test/ndbapi/testRestartGci.cpp b/ndb/test/ndbapi/testRestartGci.cpp
index 54d38654ff2..4cdfca29e6f 100644
--- a/ndb/test/ndbapi/testRestartGci.cpp
+++ b/ndb/test/ndbapi/testRestartGci.cpp
@@ -214,6 +214,7 @@ TESTCASE("InsertRestartGci",
NDBT_TESTSUITE_END(testRestartGci);
int main(int argc, const char** argv){
+ ndb_init();
return testRestartGci.execute(argc, argv);
}
diff --git a/ndb/test/ndbapi/testScan.cpp b/ndb/test/ndbapi/testScan.cpp
index 3d8b37df0ca..0cd30dfefde 100644
--- a/ndb/test/ndbapi/testScan.cpp
+++ b/ndb/test/ndbapi/testScan.cpp
@@ -1400,6 +1400,7 @@ TESTCASE("ScanRestart",
NDBT_TESTSUITE_END(testScan);
int main(int argc, const char** argv){
+ ndb_init();
myRandom48Init(NdbTick_CurrentMillisecond());
return testScan.execute(argc, argv);
}
diff --git a/ndb/test/ndbapi/testScanInterpreter.cpp b/ndb/test/ndbapi/testScanInterpreter.cpp
index 3b5baf954e0..3a5ef22b613 100644
--- a/ndb/test/ndbapi/testScanInterpreter.cpp
+++ b/ndb/test/ndbapi/testScanInterpreter.cpp
@@ -273,6 +273,7 @@ TESTCASE("ScanLessThanLoop",
NDBT_TESTSUITE_END(testScanInterpreter);
int main(int argc, const char** argv){
+ ndb_init();
return testScanInterpreter.execute(argc, argv);
}
diff --git a/ndb/test/ndbapi/testScanPerf.cpp b/ndb/test/ndbapi/testScanPerf.cpp
index 829ba5a0f15..8c1a41047ca 100644
--- a/ndb/test/ndbapi/testScanPerf.cpp
+++ b/ndb/test/ndbapi/testScanPerf.cpp
@@ -72,6 +72,7 @@ int drop_table();
int
main(int argc, const char** argv){
+ ndb_init();
int verbose = 1;
int optind = 0;
diff --git a/ndb/test/ndbapi/testSystemRestart.cpp b/ndb/test/ndbapi/testSystemRestart.cpp
index 61e086ff941..68e5eacc631 100644
--- a/ndb/test/ndbapi/testSystemRestart.cpp
+++ b/ndb/test/ndbapi/testSystemRestart.cpp
@@ -1179,6 +1179,7 @@ TESTCASE("SR8",
NDBT_TESTSUITE_END(testSystemRestart);
int main(int argc, const char** argv){
+ ndb_init();
return testSystemRestart.execute(argc, argv);
}
diff --git a/ndb/test/ndbapi/testTimeout.cpp b/ndb/test/ndbapi/testTimeout.cpp
index 62e69125073..5cabb86541d 100644
--- a/ndb/test/ndbapi/testTimeout.cpp
+++ b/ndb/test/ndbapi/testTimeout.cpp
@@ -406,6 +406,7 @@ TESTCASE("BuddyTransNoTimeout5",
NDBT_TESTSUITE_END(testTimeout);
int main(int argc, const char** argv){
+ ndb_init();
myRandom48Init(NdbTick_CurrentMillisecond());
return testTimeout.execute(argc, argv);
}
diff --git a/ndb/test/ndbapi/testTransactions.cpp b/ndb/test/ndbapi/testTransactions.cpp
index 67a2df24390..2dca9e24fb4 100644
--- a/ndb/test/ndbapi/testTransactions.cpp
+++ b/ndb/test/ndbapi/testTransactions.cpp
@@ -364,6 +364,7 @@ runClearTable(NDBT_Context* ctx, NDBT_Step* step){
int
main(int argc, const char** argv){
+ ndb_init();
NDBT_TestSuite ts("testOperations");
for(Uint32 i = 0; i<sizeof(matrix)/sizeof(matrix[0]); i++){
diff --git a/ndb/test/ndbapi/test_event.cpp b/ndb/test/ndbapi/test_event.cpp
index 40fc1c6defa..cb2793e42b9 100644
--- a/ndb/test/ndbapi/test_event.cpp
+++ b/ndb/test/ndbapi/test_event.cpp
@@ -137,6 +137,7 @@ NDBT_TESTSUITE_END(test_event);
#endif
int main(int argc, const char** argv){
+ ndb_init();
return test_event.execute(argc, argv);
}
diff --git a/ndb/test/run-test/atrt-mysql-test-run b/ndb/test/run-test/atrt-mysql-test-run
index 3a044e43288..e36fe1f3882 100755
--- a/ndb/test/run-test/atrt-mysql-test-run
+++ b/ndb/test/run-test/atrt-mysql-test-run
@@ -1,5 +1,20 @@
#!/bin/sh
set -e -x
+p=`pwd`
cd $MYSQL_BASE_DIR/mysql-test
-./mysql-test-run --with-ndbcluster --ndbconnectstring=$NDB_CONNECTSTRING $*
+./mysql-test-run --with-ndbcluster --ndbconnectstring=$NDB_CONNECTSTRING $* | tee $p/output.txt
+
+f=`grep -c fail $p/output.txt`
+o=`grep -c pass $p/output.txt`
+
+if [ $o -gt 0 -a $f -eq 0 ]
+then
+ echo "NDBT_ProgramExit: OK"
+ exit 0
+fi
+
+echo "NDBT_ProgramExit: Failed"
+exit 1
+
+
diff --git a/ndb/test/run-test/daily-basic-tests.txt b/ndb/test/run-test/daily-basic-tests.txt
index 631378cb636..8d7e8a06c72 100644
--- a/ndb/test/run-test/daily-basic-tests.txt
+++ b/ndb/test/run-test/daily-basic-tests.txt
@@ -1006,3 +1006,18 @@ max-time: 1500
cmd: testSystemRestart
args: -n SR2 T7
+max-time: 1500
+cmd: testSystemRestart
+args: -n SR_UNDO T1
+
+max-time: 1500
+cmd: testSystemRestart
+args: -n SR_UNDO T6
+
+max-time: 1500
+cmd: testSystemRestart
+args: -n SR_UNDO T7
+
+max-time: 1500
+cmd: testSystemRestart
+args: -n SR_UNDO T8
diff --git a/ndb/test/run-test/daily-devel-tests.txt b/ndb/test/run-test/daily-devel-tests.txt
index 35e0d2e9a46..522bbde32bc 100644
--- a/ndb/test/run-test/daily-devel-tests.txt
+++ b/ndb/test/run-test/daily-devel-tests.txt
@@ -26,10 +26,10 @@ max-time: 600
cmd: atrt-testBackup
args: -n BackupOne T1 T6 T3 I3
-#max-time: 600
-#cmd: testBackup
-#args: -n BackupBank T6
-#
+max-time: 1000
+cmd: testBackup
+args: -n BackupBank T6
+
#
# MGMAPI AND MGSRV
#
@@ -43,22 +43,6 @@ args: -n SingleUserMode T1
#
max-time: 1500
cmd: testSystemRestart
-args: -n SR_UNDO T1
-
-max-time: 1500
-cmd: testSystemRestart
-args: -n SR_UNDO T6
-
-max-time: 1500
-cmd: testSystemRestart
-args: -n SR_UNDO T7
-
-max-time: 1500
-cmd: testSystemRestart
-args: -n SR_UNDO T8
-
-max-time: 1500
-cmd: testSystemRestart
args: -n SR3 T6
max-time: 1500
diff --git a/ndb/test/run-test/main.cpp b/ndb/test/run-test/main.cpp
index 653e16e0947..22799a9a1b2 100644
--- a/ndb/test/run-test/main.cpp
+++ b/ndb/test/run-test/main.cpp
@@ -79,6 +79,7 @@ const int arg_count = 10;
int
main(int argc, const char ** argv){
+ ndb_init();
bool restart = true;
int lineno = 1;
diff --git a/ndb/test/src/HugoTransactions.cpp b/ndb/test/src/HugoTransactions.cpp
index 05039562c76..53809ecc851 100644
--- a/ndb/test/src/HugoTransactions.cpp
+++ b/ndb/test/src/HugoTransactions.cpp
@@ -728,7 +728,8 @@ HugoTransactions::loadTable(Ndb* pNdb,
if (doSleep > 0)
NdbSleep_MilliSleep(doSleep);
- if (first_batch || !oneTrans) {
+ // if (first_batch || !oneTrans) {
+ if (first_batch) {
first_batch = false;
pTrans = pNdb->startTransaction();
@@ -774,8 +775,10 @@ HugoTransactions::loadTable(Ndb* pNdb,
// Execute the transaction and insert the record
if (!oneTrans || (c + batch) >= records) {
- closeTrans = true;
+ // closeTrans = true;
+ closeTrans = false;
check = pTrans->execute( Commit );
+ pTrans->restart();
} else {
closeTrans = false;
check = pTrans->execute( NoCommit );
diff --git a/ndb/test/src/NDBT_Test.cpp b/ndb/test/src/NDBT_Test.cpp
index 7ccc9e5588f..4ff94bcf296 100644
--- a/ndb/test/src/NDBT_Test.cpp
+++ b/ndb/test/src/NDBT_Test.cpp
@@ -15,7 +15,6 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <ndb_global.h>
-#include <my_sys.h>
#include "NDBT.hpp"
#include "NDBT_Test.hpp"
@@ -859,6 +858,11 @@ void NDBT_TestSuite::execute(Ndb* ndb, const NdbDictionary::Table* pTab,
else
numTestsOk++;
numTestsExecuted++;
+
+ if (result == NDBT_OK && createTable == true){
+ pDict->dropTable(pTab->getName());
+ }
+
delete ctx;
}
}
@@ -985,7 +989,6 @@ int NDBT_TestSuite::execute(int argc, const char** argv){
}
#ifndef DBUG_OFF
- my_init();
if (debug_option)
DBUG_PUSH(debug_option);
#endif
diff --git a/ndb/test/src/NdbBackup.cpp b/ndb/test/src/NdbBackup.cpp
index f33c5d8c313..71b4b49b3a6 100644
--- a/ndb/test/src/NdbBackup.cpp
+++ b/ndb/test/src/NdbBackup.cpp
@@ -140,14 +140,16 @@ NdbBackup::execRestore(bool _restore_data,
*/
snprintf(buf, buf_len,
- "scp %s:%s/BACKUP/BACKUP-%d/* .",
+ "scp %s:%s/BACKUP/BACKUP-%d/BACKUP-%d*.%d.* .",
host, path,
- _backup_id);
+ _backup_id,
+ _backup_id,
+ _node_id);
ndbout << "buf: "<< buf <<endl;
int res = system(buf);
- ndbout << "res: " << res << endl;
+ ndbout << "scp res: " << res << endl;
snprintf(buf, 255, "%sndb_restore -c \"host=%s\" -n %d -b %d %s %s .",
#if 1
@@ -162,9 +164,9 @@ NdbBackup::execRestore(bool _restore_data,
_restore_meta?"-m":"");
ndbout << "buf: "<< buf <<endl;
- res = system(buf);
+ res = system(buf);
- ndbout << "res: " << res << endl;
+ ndbout << "ndb_restore res: " << res << endl;
return res;
@@ -180,20 +182,13 @@ NdbBackup::restore(unsigned _backup_id){
return -1;
int res;
- if ( ndbNodes.size() == 1) {
- // restore metadata and data in one call
- res = execRestore(true, true, ndbNodes[0].node_id, _backup_id);
- } else {
- assert(ndbNodes.size() > 1);
-
- // restore metadata first
- res = execRestore(false, true, ndbNodes[0].node_id, _backup_id);
-
- // Restore data once for each node
- for(size_t i = 0; i < ndbNodes.size(); i++){
- res = execRestore(true, false, ndbNodes[i].node_id, _backup_id);
- }
+ // restore metadata first and data for first node
+ res = execRestore(true, true, ndbNodes[0].node_id, _backup_id);
+
+ // Restore data once for each node
+ for(size_t i = 1; i < ndbNodes.size(); i++){
+ res = execRestore(true, false, ndbNodes[i].node_id, _backup_id);
}
return 0;
diff --git a/ndb/test/tools/copy_tab.cpp b/ndb/test/tools/copy_tab.cpp
index 33ce8e01d9a..30141acaa78 100644
--- a/ndb/test/tools/copy_tab.cpp
+++ b/ndb/test/tools/copy_tab.cpp
@@ -24,6 +24,7 @@
#include <getarg.h>
int main(int argc, const char** argv){
+ ndb_init();
const char* _tabname = NULL;
const char* _to_tabname = NULL;
diff --git a/ndb/test/tools/cpcc.cpp b/ndb/test/tools/cpcc.cpp
index e30d458ffee..dd59e577f2c 100644
--- a/ndb/test/tools/cpcc.cpp
+++ b/ndb/test/tools/cpcc.cpp
@@ -173,6 +173,7 @@ add_hosts(Vector<SimpleCpcClient*> & hosts, BaseString list){
int
main(int argc, const char** argv){
+ ndb_init();
int help = 0;
const char *cmd=0, *name=0, *group=0, *owner=0;
int list = 0, start = 0, stop = 0, rm = 0;
diff --git a/ndb/test/tools/create_index.cpp b/ndb/test/tools/create_index.cpp
index f883755ea24..75a657522f6 100644
--- a/ndb/test/tools/create_index.cpp
+++ b/ndb/test/tools/create_index.cpp
@@ -26,6 +26,7 @@
int
main(int argc, const char** argv){
+ ndb_init();
const char* _dbname = "TEST_DB";
int _help = 0;
diff --git a/ndb/test/tools/hugoCalculator.cpp b/ndb/test/tools/hugoCalculator.cpp
index 7f2751be2ba..82c4bbff1a4 100644
--- a/ndb/test/tools/hugoCalculator.cpp
+++ b/ndb/test/tools/hugoCalculator.cpp
@@ -28,6 +28,7 @@
int main(int argc, const char** argv)
{
+ ndb_init();
int _row = 0;
int _column = 0;
int _updates = 0;
diff --git a/ndb/test/tools/hugoFill.cpp b/ndb/test/tools/hugoFill.cpp
index dee6ce2e6c8..6253bd1bb12 100644
--- a/ndb/test/tools/hugoFill.cpp
+++ b/ndb/test/tools/hugoFill.cpp
@@ -25,6 +25,7 @@
int main(int argc, const char** argv){
+ ndb_init();
int _records = 0;
const char* _tabname = NULL;
diff --git a/ndb/test/tools/hugoLoad.cpp b/ndb/test/tools/hugoLoad.cpp
index be7f878d106..c697ad22aad 100644
--- a/ndb/test/tools/hugoLoad.cpp
+++ b/ndb/test/tools/hugoLoad.cpp
@@ -24,6 +24,7 @@
int main(int argc, const char** argv){
+ ndb_init();
int _records = 0;
const char* _tabname = NULL;
diff --git a/ndb/test/tools/hugoLockRecords.cpp b/ndb/test/tools/hugoLockRecords.cpp
index e2c2cd13f00..629408d401d 100644
--- a/ndb/test/tools/hugoLockRecords.cpp
+++ b/ndb/test/tools/hugoLockRecords.cpp
@@ -27,6 +27,7 @@
#include <HugoTransactions.hpp>
int main(int argc, const char** argv){
+ ndb_init();
int _records = 0;
int _loops = 1;
diff --git a/ndb/test/tools/hugoPkDelete.cpp b/ndb/test/tools/hugoPkDelete.cpp
index 1855f19796f..78a90ebcb46 100644
--- a/ndb/test/tools/hugoPkDelete.cpp
+++ b/ndb/test/tools/hugoPkDelete.cpp
@@ -27,6 +27,7 @@
#include <HugoTransactions.hpp>
int main(int argc, const char** argv){
+ ndb_init();
int _records = 0;
int _loops = 1;
diff --git a/ndb/test/tools/hugoPkRead.cpp b/ndb/test/tools/hugoPkRead.cpp
index 50351f08195..cf08b137e8e 100644
--- a/ndb/test/tools/hugoPkRead.cpp
+++ b/ndb/test/tools/hugoPkRead.cpp
@@ -28,6 +28,7 @@
int main(int argc, const char** argv){
+ ndb_init();
int _records = 0;
int _loops = 1;
diff --git a/ndb/test/tools/hugoPkReadRecord.cpp b/ndb/test/tools/hugoPkReadRecord.cpp
index 85f20bd2060..38b7cae2bf4 100644
--- a/ndb/test/tools/hugoPkReadRecord.cpp
+++ b/ndb/test/tools/hugoPkReadRecord.cpp
@@ -28,6 +28,7 @@
int main(int argc, const char** argv)
{
+ ndb_init();
int _row = 0;
int _hex = 0;
int _primaryKey = 0;
diff --git a/ndb/test/tools/hugoPkUpdate.cpp b/ndb/test/tools/hugoPkUpdate.cpp
index e7edc3a991d..286be14a01c 100644
--- a/ndb/test/tools/hugoPkUpdate.cpp
+++ b/ndb/test/tools/hugoPkUpdate.cpp
@@ -27,6 +27,7 @@
#include <HugoTransactions.hpp>
int main(int argc, const char** argv){
+ ndb_init();
int _records = 0;
int _loops = 1;
diff --git a/ndb/test/tools/hugoScanRead.cpp b/ndb/test/tools/hugoScanRead.cpp
index 47ea8f4a8a7..cdfdcea4654 100644
--- a/ndb/test/tools/hugoScanRead.cpp
+++ b/ndb/test/tools/hugoScanRead.cpp
@@ -27,6 +27,7 @@
#include <HugoTransactions.hpp>
int main(int argc, const char** argv){
+ ndb_init();
int _records = 0;
int _loops = 1;
diff --git a/ndb/test/tools/hugoScanUpdate.cpp b/ndb/test/tools/hugoScanUpdate.cpp
index 3e2255ca0f3..96a487a02bf 100644
--- a/ndb/test/tools/hugoScanUpdate.cpp
+++ b/ndb/test/tools/hugoScanUpdate.cpp
@@ -27,6 +27,7 @@
#include <HugoTransactions.hpp>
int main(int argc, const char** argv){
+ ndb_init();
int _records = 0;
int _loops = 1;
diff --git a/ndb/test/tools/restart.cpp b/ndb/test/tools/restart.cpp
index 88cfb231a72..9ad20801fd7 100644
--- a/ndb/test/tools/restart.cpp
+++ b/ndb/test/tools/restart.cpp
@@ -27,6 +27,7 @@
#include <NDBT.hpp>
int main(int argc, const char** argv){
+ ndb_init();
const char* _hostName = NULL;
int _initial = 0;
diff --git a/ndb/test/tools/transproxy.cpp b/ndb/test/tools/transproxy.cpp
index 384a8a34f03..90e216ec785 100644
--- a/ndb/test/tools/transproxy.cpp
+++ b/ndb/test/tools/transproxy.cpp
@@ -346,6 +346,7 @@ start()
int
main(int av, char** ac)
{
+ ndb_init();
debug("start");
hostname = "ndb-srv7";
if (Ndb_getInAddr(&hostaddr.sin_addr, hostname) != 0) {
diff --git a/ndb/test/tools/verify_index.cpp b/ndb/test/tools/verify_index.cpp
index 1295b657e9b..6c8e304e1a1 100644
--- a/ndb/test/tools/verify_index.cpp
+++ b/ndb/test/tools/verify_index.cpp
@@ -27,6 +27,7 @@
int main(int argc, const char** argv){
+ ndb_init();
int _parallelism = 240;
const char* _tabname = NULL;
const char* _indexname = NULL;
diff --git a/ndb/tools/delete_all.cpp b/ndb/tools/delete_all.cpp
index 5110947c6a2..aa5798376ae 100644
--- a/ndb/tools/delete_all.cpp
+++ b/ndb/tools/delete_all.cpp
@@ -26,6 +26,7 @@
static int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism=240);
int main(int argc, const char** argv){
+ ndb_init();
const char* _tabname = NULL;
const char* _dbname = "TEST_DB";
diff --git a/ndb/tools/desc.cpp b/ndb/tools/desc.cpp
index 859a9544a79..0ab11a0fdd2 100644
--- a/ndb/tools/desc.cpp
+++ b/ndb/tools/desc.cpp
@@ -22,6 +22,7 @@
int main(int argc, const char** argv){
+ ndb_init();
const char* _tabname = NULL;
const char* _dbname = "TEST_DB";
int _unqualified = 0;
diff --git a/ndb/tools/drop_index.cpp b/ndb/tools/drop_index.cpp
index 327f15741c9..70c29461c23 100644
--- a/ndb/tools/drop_index.cpp
+++ b/ndb/tools/drop_index.cpp
@@ -23,6 +23,7 @@
#include <getarg.h>
int main(int argc, const char** argv){
+ ndb_init();
const char* _tabname = NULL;
const char* _dbname = "TEST_DB";
diff --git a/ndb/tools/drop_tab.cpp b/ndb/tools/drop_tab.cpp
index 70e5d85aabe..15c229cb0fb 100644
--- a/ndb/tools/drop_tab.cpp
+++ b/ndb/tools/drop_tab.cpp
@@ -23,6 +23,7 @@
#include <getarg.h>
int main(int argc, const char** argv){
+ ndb_init();
const char* _tabname = NULL;
const char* _dbname = "TEST_DB";
diff --git a/ndb/tools/listTables.cpp b/ndb/tools/listTables.cpp
index d6465f3214f..4b24929ee4b 100644
--- a/ndb/tools/listTables.cpp
+++ b/ndb/tools/listTables.cpp
@@ -22,7 +22,6 @@
*/
#include <ndb_global.h>
-#include <my_sys.h>
#include <getarg.h>
#include <NdbApi.hpp>
@@ -167,6 +166,7 @@ const char *debug_option= 0;
#endif
int main(int argc, const char** argv){
+ ndb_init();
int _loops = 1;
const char* _tabname = NULL;
const char* _dbname = "TEST_DB";
@@ -209,7 +209,6 @@ int main(int argc, const char** argv){
_tabname = argv[optind];
#ifndef DBUG_OFF
- my_init();
if (debug_option)
DBUG_PUSH(debug_option);
#endif
diff --git a/ndb/tools/ndbsql.cpp b/ndb/tools/ndbsql.cpp
index 6af5f47f6f4..1997e4abebd 100644
--- a/ndb/tools/ndbsql.cpp
+++ b/ndb/tools/ndbsql.cpp
@@ -671,6 +671,7 @@ void print_help_virtual() {
int main(int argc, const char** argv)
{
+ ndb_init();
const char* usage = "Usage: ndbsql [-h] [-d dsn] [-f file] [stmt]\n-h help\n-d <database name or connect string>\n-f <file name> batch mode\nstmt single SQL statement\n";
const char* dsn = "TEST_DB";
bool helpFlg = false, batchMode = false;
diff --git a/ndb/tools/select_all.cpp b/ndb/tools/select_all.cpp
index eb95947fc0f..8fb8437ba5f 100644
--- a/ndb/tools/select_all.cpp
+++ b/ndb/tools/select_all.cpp
@@ -16,7 +16,6 @@
#include <ndb_global.h>
-#include <my_sys.h>
#include <NdbOut.hpp>
@@ -42,6 +41,7 @@ int scanReadRecords(Ndb*,
bool orderby);
int main(int argc, const char** argv){
+ ndb_init();
int _parallelism = 240;
const char* _delimiter = "\t";
int _header = true;
@@ -89,7 +89,6 @@ int main(int argc, const char** argv){
_tabname = argv[optind];
#ifndef DBUG_OFF
- my_init();
if (debug_option)
DBUG_PUSH(debug_option);
#endif
diff --git a/ndb/tools/select_count.cpp b/ndb/tools/select_count.cpp
index bb7c9dea49b..6650421e637 100644
--- a/ndb/tools/select_count.cpp
+++ b/ndb/tools/select_count.cpp
@@ -33,6 +33,7 @@ select_count(Ndb* pNdb, const NdbDictionary::Table* pTab,
UtilTransactions::ScanLock lock);
int main(int argc, const char** argv){
+ ndb_init();
const char* _dbname = "TEST_DB";
int _parallelism = 240;
int _help = 0;
diff --git a/ndb/tools/waiter.cpp b/ndb/tools/waiter.cpp
index 63469c6d746..c27b46c9356 100644
--- a/ndb/tools/waiter.cpp
+++ b/ndb/tools/waiter.cpp
@@ -30,6 +30,7 @@ int
waitClusterStatus(const char* _addr, ndb_mgm_node_status _status, unsigned int _timeout);
int main(int argc, const char** argv){
+ ndb_init();
const char* _hostName = NULL;
int _no_contact = 0;
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index da32476ae74..7df69c8e4c7 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -2915,6 +2915,8 @@ static int create_ndb_column(NDBCOL &col,
{
// Set name
col.setName(field->field_name);
+ // Get char set
+ CHARSET_INFO *cs= field->charset();
// Set type and sizes
const enum enum_field_types mysql_type= field->real_type();
switch (mysql_type) {
@@ -2986,15 +2988,19 @@ static int create_ndb_column(NDBCOL &col,
case MYSQL_TYPE_STRING:
if (field->flags & BINARY_FLAG)
col.setType(NDBCOL::Binary);
- else
+ else {
col.setType(NDBCOL::Char);
+ col.setCharset(cs);
+ }
col.setLength(field->pack_length());
break;
case MYSQL_TYPE_VAR_STRING:
if (field->flags & BINARY_FLAG)
col.setType(NDBCOL::Varbinary);
- else
+ else {
col.setType(NDBCOL::Varchar);
+ col.setCharset(cs);
+ }
col.setLength(field->pack_length());
break;
// Blob types (all come in as MYSQL_TYPE_BLOB)
@@ -3002,8 +3008,10 @@ static int create_ndb_column(NDBCOL &col,
case MYSQL_TYPE_TINY_BLOB:
if (field->flags & BINARY_FLAG)
col.setType(NDBCOL::Blob);
- else
+ else {
col.setType(NDBCOL::Text);
+ col.setCharset(cs);
+ }
col.setInlineSize(256);
// No parts
col.setPartSize(0);
@@ -3013,8 +3021,10 @@ static int create_ndb_column(NDBCOL &col,
case MYSQL_TYPE_BLOB:
if (field->flags & BINARY_FLAG)
col.setType(NDBCOL::Blob);
- else
+ else {
col.setType(NDBCOL::Text);
+ col.setCharset(cs);
+ }
// Use "<=" even if "<" is the exact condition
if (field->max_length() <= (1 << 8))
goto mysql_type_tiny_blob;
@@ -3033,8 +3043,10 @@ static int create_ndb_column(NDBCOL &col,
case MYSQL_TYPE_MEDIUM_BLOB:
if (field->flags & BINARY_FLAG)
col.setType(NDBCOL::Blob);
- else
+ else {
col.setType(NDBCOL::Text);
+ col.setCharset(cs);
+ }
col.setInlineSize(256);
col.setPartSize(4000);
col.setStripeSize(8);
@@ -3043,8 +3055,10 @@ static int create_ndb_column(NDBCOL &col,
case MYSQL_TYPE_LONG_BLOB:
if (field->flags & BINARY_FLAG)
col.setType(NDBCOL::Blob);
- else
+ else {
col.setType(NDBCOL::Text);
+ col.setCharset(cs);
+ }
col.setInlineSize(256);
col.setPartSize(8000);
col.setStripeSize(4);