diff options
author | unknown <stewart@mysql.com> | 2005-01-19 15:20:57 +1100 |
---|---|---|
committer | unknown <stewart@mysql.com> | 2005-01-19 15:20:57 +1100 |
commit | 22ae0e897a042f3c1d7660e72ff2739990062471 (patch) | |
tree | bb58f5d564b0ddc450b0d52613c8af2d1f24508a /ndb | |
parent | 4f5de2f3930fcfe4f47bc3b6ebae1e1b28be787a (diff) | |
parent | d357a5a058bf1d8b34e674f59756205cc1ddf0d3 (diff) | |
download | mariadb-git-22ae0e897a042f3c1d7660e72ff2739990062471.tar.gz |
Merge mysql.com:/home/stewart/Documents/MySQL/5.0/ndb-dynamic-ports-impl3
into mysql.com:/home/stewart/Documents/MySQL/5.0/ndb-dynamic-ports-impl4
ndb/src/ndbapi/ndb_cluster_connection.cpp:
Auto merged
Diffstat (limited to 'ndb')
49 files changed, 1687 insertions, 602 deletions
diff --git a/ndb/examples/ndbapi_event_example/ndbapi_event.cpp b/ndb/examples/ndbapi_event_example/ndbapi_event.cpp index f03564744c7..286f6fafbab 100644 --- a/ndb/examples/ndbapi_event_example/ndbapi_event.cpp +++ b/ndb/examples/ndbapi_event_example/ndbapi_event.cpp @@ -70,12 +70,13 @@ * mysql> use TEST_DB; * mysql> create table TAB0 (COL0 int primary key, COL1 int, COL11 int) engine=ndb; * - * In another window start ndbapi_example5, wait until properly started + * In another window start ndbapi_event, wait until properly started * - * mysql> insert into TAB0 values (1,2,3); - * mysql> insert into TAB0 values (2,2,3); - * mysql> insert into TAB0 values (3,2,9); - * mysql> + insert into TAB0 values (1,2,3); + insert into TAB0 values (2,2,3); + insert into TAB0 values (3,2,9); + update TAB0 set COL1=10 where COL0=1; + delete from TAB0 where COL0=1; * * you should see the data popping up in the example window * diff --git a/ndb/include/kernel/AttributeHeader.hpp b/ndb/include/kernel/AttributeHeader.hpp index e3900b63fdc..3af5d01f007 100644 --- a/ndb/include/kernel/AttributeHeader.hpp +++ b/ndb/include/kernel/AttributeHeader.hpp @@ -40,6 +40,7 @@ public: STATIC_CONST( RANGE_NO = 0xFFFB ); // Read range no (when batched ranges) STATIC_CONST( ROW_SIZE = 0xFFFA ); + STATIC_CONST( FRAGMENT_MEMORY= 0xFFF9 ); /** Initialize AttributeHeader at location aHeaderPtr */ static AttributeHeader& init(void* aHeaderPtr, Uint32 anAttributeId, diff --git a/ndb/include/kernel/signaldata/SignalData.hpp b/ndb/include/kernel/signaldata/SignalData.hpp index f9d3a6faa64..2b29ca06ba0 100644 --- a/ndb/include/kernel/signaldata/SignalData.hpp +++ b/ndb/include/kernel/signaldata/SignalData.hpp @@ -177,9 +177,16 @@ GSN_PRINT_SIGNATURE(printFAIL_REP); GSN_PRINT_SIGNATURE(printDISCONNECT_REP); GSN_PRINT_SIGNATURE(printSUB_CREATE_REQ); GSN_PRINT_SIGNATURE(printSUB_CREATE_CONF); +GSN_PRINT_SIGNATURE(printSUB_CREATE_REF); +GSN_PRINT_SIGNATURE(printSUB_REMOVE_REQ); +GSN_PRINT_SIGNATURE(printSUB_REMOVE_CONF); +GSN_PRINT_SIGNATURE(printSUB_REMOVE_REF); GSN_PRINT_SIGNATURE(printSUB_START_REQ); GSN_PRINT_SIGNATURE(printSUB_START_REF); GSN_PRINT_SIGNATURE(printSUB_START_CONF); +GSN_PRINT_SIGNATURE(printSUB_STOP_REQ); +GSN_PRINT_SIGNATURE(printSUB_STOP_REF); +GSN_PRINT_SIGNATURE(printSUB_STOP_CONF); GSN_PRINT_SIGNATURE(printSUB_SYNC_REQ); GSN_PRINT_SIGNATURE(printSUB_SYNC_REF); GSN_PRINT_SIGNATURE(printSUB_SYNC_CONF); diff --git a/ndb/include/kernel/trigger_definitions.h b/ndb/include/kernel/trigger_definitions.h index 7ce74877de4..11410654a15 100644 --- a/ndb/include/kernel/trigger_definitions.h +++ b/ndb/include/kernel/trigger_definitions.h @@ -56,6 +56,7 @@ struct TriggerActionTime { }; struct TriggerEvent { + /** TableEvent must match 1 << TriggerEvent */ enum Value { TE_INSERT = 0, TE_DELETE = 1, diff --git a/ndb/include/ndbapi/NdbDictionary.hpp b/ndb/include/ndbapi/NdbDictionary.hpp index b4e670dfb89..80c0831f675 100644 --- a/ndb/include/ndbapi/NdbDictionary.hpp +++ b/ndb/include/ndbapi/NdbDictionary.hpp @@ -438,10 +438,13 @@ public: const char* getDefaultValue() const; static const Column * FRAGMENT; + static const Column * FRAGMENT_MEMORY; static const Column * ROW_COUNT; static const Column * COMMIT_COUNT; static const Column * ROW_SIZE; static const Column * RANGE_NO; + + int getSizeInBytes() const; #endif private: @@ -714,6 +717,8 @@ public: int getRowSizeInBytes() const ; int createTableInDb(Ndb*, bool existingEqualIsOk = true) const ; + + int getReplicaCount() const ; #endif private: @@ -914,6 +919,9 @@ public: /** * Specifies the type of database operations an Event listens to */ +#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL + /** TableEvent must match 1 << TriggerEvent */ +#endif enum TableEvent { TE_INSERT=1, ///< Insert event on table TE_DELETE=2, ///< Delete event on table diff --git a/ndb/include/ndbapi/NdbOperation.hpp b/ndb/include/ndbapi/NdbOperation.hpp index 24af18bb507..fca610772cc 100644 --- a/ndb/include/ndbapi/NdbOperation.hpp +++ b/ndb/include/ndbapi/NdbOperation.hpp @@ -709,6 +709,11 @@ public: */ const char* getTableName() const; + /** + * Get table object for this operation + */ + const NdbDictionary::Table * getTable() const; + /** @} *********************************************************************/ #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL diff --git a/ndb/include/ndbapi/NdbTransaction.hpp b/ndb/include/ndbapi/NdbTransaction.hpp index 148f4911ed9..e0b78511ca3 100644 --- a/ndb/include/ndbapi/NdbTransaction.hpp +++ b/ndb/include/ndbapi/NdbTransaction.hpp @@ -560,6 +560,11 @@ public: * ops are used (read, insert, update, delete). */ int executePendingBlobOps(Uint8 flags = 0xFF); + + /** + * Get nodeId of TC for this transaction + */ + Uint32 getConnectedNodeId(); // Get Connected node id #endif private: @@ -593,7 +598,6 @@ private: */ void setConnectedNodeId( Uint32 nodeId, Uint32 sequence); - Uint32 getConnectedNodeId(); // Get Connected node id void setMyBlockReference( int ); // Set my block refrerence void setTC_ConnectPtr( Uint32 ); // Sets TC Connect pointer int getTC_ConnectPtr(); // Gets TC Connect pointer diff --git a/ndb/include/ndbapi/ndb_cluster_connection.hpp b/ndb/include/ndbapi/ndb_cluster_connection.hpp index 2b59ff1a055..97db76563aa 100644 --- a/ndb/include/ndbapi/ndb_cluster_connection.hpp +++ b/ndb/include/ndbapi/ndb_cluster_connection.hpp @@ -86,6 +86,7 @@ public: void set_optimized_node_selection(int val); unsigned no_db_nodes(); + unsigned node_id(); #endif private: diff --git a/ndb/include/util/Base64.hpp b/ndb/include/util/Base64.hpp index 1156636eec8..f4b11ad9214 100644 --- a/ndb/include/util/Base64.hpp +++ b/ndb/include/util/Base64.hpp @@ -21,6 +21,7 @@ #include <BaseString.hpp> int base64_encode(const UtilBuffer &src, BaseString &dst); +int base64_encode(const void * s, size_t src_len, BaseString &dst); int base64_decode(const BaseString &src, UtilBuffer &dst); int base64_decode(const char * s, size_t len, UtilBuffer &dst); diff --git a/ndb/src/common/debugger/signaldata/SignalDataPrint.cpp b/ndb/src/common/debugger/signaldata/SignalDataPrint.cpp index e879b7b9206..ab23c04bffa 100644 --- a/ndb/src/common/debugger/signaldata/SignalDataPrint.cpp +++ b/ndb/src/common/debugger/signaldata/SignalDataPrint.cpp @@ -151,11 +151,17 @@ SignalDataPrintFunctions[] = { { GSN_DISCONNECT_REP, printDISCONNECT_REP }, { GSN_SUB_CREATE_REQ, printSUB_CREATE_REQ }, - //{ GSN_SUB_CREATE_REF, printSUB_CREATE_REF }, + { GSN_SUB_CREATE_REF, printSUB_CREATE_REF }, { GSN_SUB_CREATE_CONF, printSUB_CREATE_CONF }, + { GSN_SUB_REMOVE_REQ, printSUB_REMOVE_REQ }, + { GSN_SUB_REMOVE_REF, printSUB_REMOVE_REF }, + { GSN_SUB_REMOVE_CONF, printSUB_REMOVE_CONF }, { GSN_SUB_START_REQ, printSUB_START_REQ }, { GSN_SUB_START_REF, printSUB_START_REF }, { GSN_SUB_START_CONF, printSUB_START_CONF }, + { GSN_SUB_STOP_REQ, printSUB_STOP_REQ }, + { GSN_SUB_STOP_REF, printSUB_STOP_REF }, + { GSN_SUB_STOP_CONF, printSUB_STOP_CONF }, { GSN_SUB_SYNC_REQ, printSUB_SYNC_REQ }, { GSN_SUB_SYNC_REF, printSUB_SYNC_REF }, { GSN_SUB_SYNC_CONF, printSUB_SYNC_CONF }, diff --git a/ndb/src/common/debugger/signaldata/SignalNames.cpp b/ndb/src/common/debugger/signaldata/SignalNames.cpp index 9228e305677..984d28819c0 100644 --- a/ndb/src/common/debugger/signaldata/SignalNames.cpp +++ b/ndb/src/common/debugger/signaldata/SignalNames.cpp @@ -578,6 +578,9 @@ const GsnName SignalNames [] = { ,{ GSN_SUB_CREATE_REQ, "SUB_CREATE_REQ" } ,{ GSN_SUB_CREATE_REF, "SUB_CREATE_REF" } ,{ GSN_SUB_CREATE_CONF, "SUB_CREATE_CONF" } + ,{ GSN_SUB_REMOVE_REQ, "SUB_REMOVE_REQ" } + ,{ GSN_SUB_REMOVE_REF, "SUB_REMOVE_REF" } + ,{ GSN_SUB_REMOVE_CONF, "SUB_REMOVE_CONF" } ,{ GSN_SUB_START_REQ, "SUB_START_REQ" } ,{ GSN_SUB_START_REF, "SUB_START_REF" } ,{ GSN_SUB_START_CONF, "SUB_START_CONF" } diff --git a/ndb/src/common/debugger/signaldata/SumaImpl.cpp b/ndb/src/common/debugger/signaldata/SumaImpl.cpp index 558842ed2ba..e50a3040fe3 100644 --- a/ndb/src/common/debugger/signaldata/SumaImpl.cpp +++ b/ndb/src/common/debugger/signaldata/SumaImpl.cpp @@ -40,12 +40,55 @@ printSUB_CREATE_CONF(FILE * output, const Uint32 * theData, } bool +printSUB_CREATE_REF(FILE * output, const Uint32 * theData, + Uint32 len, Uint16 receiverBlockNo) { + const SubCreateRef * const sig = (SubCreateRef *)theData; + fprintf(output, " subscriptionId: %x\n", sig->subscriptionId); + fprintf(output, " subscriptionKey: %x\n", sig->subscriptionKey); + fprintf(output, " subscriberData: %x\n", sig->subscriberData); + return false; +} + +bool +printSUB_REMOVE_REQ(FILE * output, const Uint32 * theData, + Uint32 len, Uint16 receiverBlockNo) +{ + const SubRemoveReq * const sig = (SubRemoveReq *)theData; + fprintf(output, " subscriptionId: %x\n", sig->subscriptionId); + fprintf(output, " subscriptionKey: %x\n", sig->subscriptionKey); + return false; +} + +bool +printSUB_REMOVE_CONF(FILE * output, const Uint32 * theData, + Uint32 len, Uint16 receiverBlockNo) +{ + const SubRemoveConf * const sig = (SubRemoveConf *)theData; + fprintf(output, " subscriptionId: %x\n", sig->subscriptionId); + fprintf(output, " subscriptionKey: %x\n", sig->subscriptionKey); + fprintf(output, " subscriberData: %x\n", sig->subscriberData); + return false; +} + +bool +printSUB_REMOVE_REF(FILE * output, const Uint32 * theData, + Uint32 len, Uint16 receiverBlockNo) +{ + const SubRemoveRef * const sig = (SubRemoveRef *)theData; + fprintf(output, " subscriptionId: %x\n", sig->subscriptionId); + fprintf(output, " subscriptionKey: %x\n", sig->subscriptionKey); + fprintf(output, " subscriberData: %x\n", sig->subscriberData); + fprintf(output, " err: %x\n", sig->err); + return false; +} + +bool printSUB_START_REQ(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo) { const SubStartReq * const sig = (SubStartReq *)theData; fprintf(output, " subscriptionId: %x\n", sig->subscriptionId); fprintf(output, " subscriptionKey: %x\n", sig->subscriptionKey); - fprintf(output, " startPart: %x\n", sig->part); + fprintf(output, " subscriberData: %x\n", sig->subscriberData); return false; } @@ -73,6 +116,37 @@ printSUB_START_CONF(FILE * output, const Uint32 * theData, } bool +printSUB_STOP_REQ(FILE * output, const Uint32 * theData, + Uint32 len, Uint16 receiverBlockNo) { + const SubStopReq * const sig = (SubStopReq *)theData; + fprintf(output, " subscriptionId: %x\n", sig->subscriptionId); + fprintf(output, " subscriptionKey: %x\n", sig->subscriptionKey); + fprintf(output, " subscriberData: %x\n", sig->subscriberData); + return false; +} + +bool +printSUB_STOP_REF(FILE * output, const Uint32 * theData, + Uint32 len, Uint16 receiverBlockNo) { + const SubStopRef * const sig = (SubStopRef *)theData; + fprintf(output, " subscriptionId: %x\n", sig->subscriptionId); + fprintf(output, " subscriptionKey: %x\n", sig->subscriptionKey); + fprintf(output, " subscriberData: %x\n", sig->subscriberData); + fprintf(output, " err: %x\n", sig->err); + return false; +} + +bool +printSUB_STOP_CONF(FILE * output, const Uint32 * theData, + Uint32 len, Uint16 receiverBlockNo) { + const SubStopConf * const sig = (SubStopConf *)theData; + fprintf(output, " subscriptionId: %x\n", sig->subscriptionId); + fprintf(output, " subscriptionKey: %x\n", sig->subscriptionKey); + fprintf(output, " subscriberData: %x\n", sig->subscriberData); + return false; +} + +bool printSUB_SYNC_REQ(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo) { const SubSyncReq * const sig = (SubSyncReq *)theData; diff --git a/ndb/src/common/util/Base64.cpp b/ndb/src/common/util/Base64.cpp index f7a490d427d..3db911f481f 100644 --- a/ndb/src/common/util/Base64.cpp +++ b/ndb/src/common/util/Base64.cpp @@ -22,17 +22,22 @@ static char base64_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789+/"; int -base64_encode(const UtilBuffer &src, BaseString &dst) { - const unsigned char *s = (const unsigned char *)src.get_data(); +base64_encode(const UtilBuffer &src, BaseString &dst) +{ + return base64_encode(src.get_data(), src.length(), dst); +} + +int +base64_encode(const void * _s, size_t src_len, BaseString &dst) { + const unsigned char * s = (const unsigned char*)_s; size_t i = 0; size_t len = 0; - size_t src_len = src.length(); while(i < src_len) { if(len == 76){ len = 0; dst.append('\n'); } - + unsigned c; c = s[i++]; c <<= 8; diff --git a/ndb/src/kernel/blocks/ERROR_codes.txt b/ndb/src/kernel/blocks/ERROR_codes.txt index 5193d3eae9d..a30021607cc 100644 --- a/ndb/src/kernel/blocks/ERROR_codes.txt +++ b/ndb/src/kernel/blocks/ERROR_codes.txt @@ -196,6 +196,8 @@ Delay execution of ABORTREQ signal 2 seconds to generate time-out. 8048: Make TC not choose own node for simple/dirty read 5041: Crash is receiving simple read from other TC on different node +8050: Send TCKEYREF is operation is non local + ERROR CODES FOR TESTING TIME-OUT HANDLING IN DBTC ------------------------------------------------- 8040: @@ -409,6 +411,8 @@ Drop Table/Index: 8033: Fail next trigger create in TC 8034: Fail next index create in TC + + System Restart: --------------- diff --git a/ndb/src/kernel/blocks/backup/Backup.cpp b/ndb/src/kernel/blocks/backup/Backup.cpp index dc695580783..86bbf27f40e 100644 --- a/ndb/src/kernel/blocks/backup/Backup.cpp +++ b/ndb/src/kernel/blocks/backup/Backup.cpp @@ -992,7 +992,11 @@ Backup::execUTIL_SEQUENCE_CONF(Signal* signal) }//if ndbrequire(ptr.p->masterData.state.getState() == DEFINING); - ptr.p->backupId = conf->sequenceValue[0]; + { + Uint64 backupId; + memcpy(&backupId,conf->sequenceValue,8); + ptr.p->backupId= (Uint32)backupId; + } ptr.p->backupKey[0] = (getOwnNodeId() << 16) | (ptr.p->backupId & 0xFFFF); ptr.p->backupKey[1] = NdbTick_CurrentMillisecond(); diff --git a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp index adae429e65d..b579c37c842 100644 --- a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp +++ b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp @@ -7475,6 +7475,22 @@ void Dbdih::execDIHNDBTAMPER(Signal* signal) #ifdef ERROR_INSERT case 5: jam(); + if(tuserpointer == 0) + { + jam(); + signal->theData[0] = 0; + sendSignal(QMGR_REF, GSN_NDB_TAMPER, signal, 1, JBB); + sendSignal(NDBCNTR_REF, GSN_NDB_TAMPER, signal, 1, JBB); + sendSignal(NDBFS_REF, GSN_NDB_TAMPER, signal, 1, JBB); + sendSignal(DBACC_REF, GSN_NDB_TAMPER, signal, 1, JBB); + sendSignal(DBTUP_REF, GSN_NDB_TAMPER, signal, 1, JBB); + sendSignal(DBLQH_REF, GSN_NDB_TAMPER, signal, 1, JBB); + sendSignal(DBDICT_REF, GSN_NDB_TAMPER, signal, 1, JBB); + sendSignal(DBDIH_REF, GSN_NDB_TAMPER, signal, 1, JBB); + sendSignal(DBTC_REF, GSN_NDB_TAMPER, signal, 1, JBB); + sendSignal(CMVMI_REF, GSN_NDB_TAMPER, signal, 1, JBB); + return; + } /*----------------------------------------------------------------------*/ // Insert errors. /*----------------------------------------------------------------------*/ diff --git a/ndb/src/kernel/blocks/dbtc/Dbtc.hpp b/ndb/src/kernel/blocks/dbtc/Dbtc.hpp index 6b823de1e5a..2baa4400409 100644 --- a/ndb/src/kernel/blocks/dbtc/Dbtc.hpp +++ b/ndb/src/kernel/blocks/dbtc/Dbtc.hpp @@ -1177,7 +1177,7 @@ public: Uint32 nextScan; // Length of expected attribute information - Uint32 scanAiLength; + union { Uint32 scanAiLength; Uint32 m_booked_fragments_count; }; Uint32 scanKeyLen; diff --git a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp index 5164ce572f4..ce38c355c91 100644 --- a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp +++ b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp @@ -3081,6 +3081,15 @@ void Dbtc::tckeyreq050Lab(Signal* signal) execDIGETNODESREF(signal); return; } + + if(ERROR_INSERTED(8050) && signal->theData[3] != getOwnNodeId()) + { + ndbassert(false); + signal->theData[1] = 626; + execDIGETNODESREF(signal); + return; + } + /****************>>*/ /* DIGETNODESCONF >*/ /* ***************>*/ @@ -3195,7 +3204,6 @@ void Dbtc::attrinfoDihReceivedLab(Signal* signal) CacheRecord * const regCachePtr = cachePtr.p; TcConnectRecord * const regTcPtr = tcConnectptr.p; Uint16 Tnode = regTcPtr->tcNodedata[0]; - Uint16 TscanTakeOverInd = regCachePtr->scanTakeOverInd; TableRecordPtr localTabptr; localTabptr.i = regCachePtr->tableref; @@ -8931,6 +8939,7 @@ void Dbtc::diFcountReqLab(Signal* signal, ScanRecordPtr scanptr) } scanptr.p->scanNextFragId = 0; + scanptr.p->m_booked_fragments_count= 0; scanptr.p->scanState = ScanRecord::WAIT_FRAGMENT_COUNT; if(!cachePtr.p->distributionKeyIndicator) @@ -9403,7 +9412,7 @@ void Dbtc::execSCAN_FRAGCONF(Signal* signal) } if(noCompletedOps == 0 && status != 0 && - scanptr.p->scanNextFragId < scanptr.p->scanNoFrag){ + scanptr.p->scanNextFragId+scanptr.p->m_booked_fragments_count < scanptr.p->scanNoFrag){ /** * Start on next fragment */ @@ -9573,6 +9582,9 @@ void Dbtc::execSCAN_NEXTREQ(Signal* signal) */ jam(); ndbrequire(scanptr.p->scanNextFragId < scanptr.p->scanNoFrag); + jam(); + ndbassert(scanptr.p->m_booked_fragments_count); + scanptr.p->m_booked_fragments_count--; scanFragptr.p->scanFragState = ScanFragRec::WAIT_GET_PRIMCONF; tcConnectptr.i = scanptr.p->scanTcrec; @@ -9814,8 +9826,9 @@ void Dbtc::sendScanTabConf(Signal* signal, ScanRecordPtr scanPtr) { jam(); ops += 21; } - - Uint32 left = scanPtr.p->scanNoFrag - scanPtr.p->scanNextFragId; + + int left = scanPtr.p->scanNoFrag - scanPtr.p->scanNextFragId; + Uint32 booked = scanPtr.p->m_booked_fragments_count; ScanTabConf * conf = (ScanTabConf*)&signal->theData[0]; conf->apiConnectPtr = apiConnectptr.p->ndbapiConnect; @@ -9831,8 +9844,10 @@ void Dbtc::sendScanTabConf(Signal* signal, ScanRecordPtr scanPtr) { ScanFragRecPtr curr = ptr; // Remove while iterating... queued.next(ptr); - bool done = curr.p->m_scan_frag_conf_status && --left; - + bool done = curr.p->m_scan_frag_conf_status && (left <= (int)booked); + if(curr.p->m_scan_frag_conf_status) + booked++; + * ops++ = curr.p->m_apiPtr; * ops++ = done ? RNIL : curr.i; * ops++ = (curr.p->m_totalLen << 10) + curr.p->m_ops; @@ -9850,8 +9865,10 @@ void Dbtc::sendScanTabConf(Signal* signal, ScanRecordPtr scanPtr) { } } + scanPtr.p->m_booked_fragments_count = booked; if(scanPtr.p->m_delivered_scan_frags.isEmpty() && - scanPtr.p->m_running_scan_frags.isEmpty()){ + scanPtr.p->m_running_scan_frags.isEmpty()) + { conf->requestInfo = op_count | ScanTabConf::EndOfData; releaseScanResources(scanPtr); } diff --git a/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp b/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp index 8e1cba24359..0f0e6d61f41 100644 --- a/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp +++ b/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp @@ -632,14 +632,11 @@ void Dbtup::execREAD_CONFIG_REQ(Signal* signal) ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUP_FRAG, &cnoOfFragrec)); ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUP_OP_RECS, &cnoOfOprec)); - - // MemorySpaceTuples is specified in 8k pages, divide by 4 for 32k pages - Uint32 tmp; - ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUP_PAGE, &tmp)); - Uint64 pages = (tmp * 2048 + (ZWORDS_ON_PAGE - 1))/ (Uint64)ZWORDS_ON_PAGE; - cnoOfPage = (Uint32)pages; + + ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUP_PAGE, &cnoOfPage)); Uint32 noOfTriggers= 0; + Uint32 tmp= 0; ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUP_PAGE_RANGE, &tmp)); initPageRangeSize(tmp); ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUP_TABLE, &cnoOfTablerec)); diff --git a/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp b/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp index 06b2b3f4cb4..c3f85cdebd5 100644 --- a/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp +++ b/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp @@ -1001,6 +1001,13 @@ Dbtup::read_psuedo(Uint32 attrId, Uint32* outBuffer){ case AttributeHeader::FRAGMENT: * outBuffer = operPtr.p->fragId >> 1; // remove "hash" bit return 1; + case AttributeHeader::FRAGMENT_MEMORY: + { + Uint64 tmp= fragptr.p->noOfPages; + tmp*= 32768; + memcpy(outBuffer,&tmp,8); + } + return 2; case AttributeHeader::ROW_SIZE: * outBuffer = tabptr.p->tupheadsize << 2; return 1; diff --git a/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp b/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp index a01f094cffd..ddf1681479c 100644 --- a/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp +++ b/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp @@ -27,6 +27,14 @@ #include <NdbThread.h> #include <signaldata/FsOpenReq.hpp> +// use this to test broken pread code +//#define HAVE_BROKEN_PREAD + +#ifdef HAVE_BROKEN_PREAD +#undef HAVE_PWRITE +#undef HAVE_PREAD +#endif + #if defined NDB_WIN32 || defined NDB_OSE || defined NDB_SOFTOSE #else // For readv and writev @@ -379,9 +387,12 @@ AsyncFile::readBuffer(char * buf, size_t size, off_t offset){ if(dwSFP != offset) { return GetLastError(); } -#elif defined NDB_OSE || defined NDB_SOFTOSE - return_value = lseek(theFd, offset, SEEK_SET); - if (return_value != offset) { +#elif ! defined(HAVE_PREAD) + off_t seek_val; + while((seek_val= lseek(theFd, offset, SEEK_SET)) == (off_t)-1 + && errno == EINTR); + if(seek_val == (off_t)-1) + { return errno; } #endif @@ -400,10 +411,10 @@ AsyncFile::readBuffer(char * buf, size_t size, off_t offset){ return GetLastError(); } bytes_read = dwBytesRead; -#elif defined NDB_OSE || defined NDB_SOFTOSE +#elif ! defined(HAVE_PREAD) return_value = ::read(theFd, buf, size); #else // UNIX - return_value = my_pread(theFd, buf, size, offset,0); + return_value = ::pread(theFd, buf, size, offset); #endif #ifndef NDB_WIN32 if (return_value == -1 && errno == EINTR) { @@ -453,7 +464,7 @@ AsyncFile::readReq( Request * request) void AsyncFile::readvReq( Request * request) { -#if defined NDB_OSE || defined NDB_SOFTOSE +#if ! defined(HAVE_PREAD) readReq(request); return; #elif defined NDB_WIN32 @@ -483,7 +494,7 @@ AsyncFile::readvReq( Request * request) int AsyncFile::extendfile(Request* request) { -#if defined NDB_OSE || defined NDB_SOFTOSE +#if ! defined(HAVE_PWRITE) // Find max size of this file in this request int maxOffset = 0; int maxSize = 0; @@ -592,27 +603,13 @@ AsyncFile::writeBuffer(const char * buf, size_t size, off_t offset, if(dwSFP != offset) { return GetLastError(); } -#elif defined NDB_OSE || defined NDB_SOFTOSE - return_value = lseek(theFd, offset, SEEK_SET); - if (return_value != offset) { - DEBUG(ndbout_c("AsyncFile::writeReq, err1: return_value=%d, offset=%d\n", - return_value, chunk_offset)); - PRINT_ERRORANDFLAGS(0); - if (errno == 78) { - // Could not write beyond end of file, try to extend file - DEBUG(ndbout_c("AsyncFile::writeReq, Extend. file! filename=\"%s\" \n", - theFileName.c_str())); - return_value = extendfile(request); - if (return_value == -1) { - return errno; - } - return_value = lseek(theFd, offset, SEEK_SET); - if (return_value != offset) { - return errno; - } - } else { - return errno; - } +#elif ! defined(HAVE_PWRITE) + off_t seek_val; + while((seek_val= lseek(theFd, offset, SEEK_SET)) == (off_t)-1 + && errno == EINTR); + if(seek_val == (off_t)-1) + { + return errno; } #endif @@ -634,10 +631,10 @@ AsyncFile::writeBuffer(const char * buf, size_t size, off_t offset, DEBUG(ndbout_c("Warning partial write %d != %d", bytes_written, bytes_to_write)); } -#elif defined NDB_OSE || defined NDB_SOFTOSE +#elif ! defined(HAVE_PWRITE) return_value = ::write(theFd, buf, bytes_to_write); #else // UNIX - return_value = my_pwrite(theFd, buf, bytes_to_write, offset, 0); + return_value = ::pwrite(theFd, buf, bytes_to_write, offset); #endif #ifndef NDB_WIN32 if (return_value == -1 && errno == EINTR) { diff --git a/ndb/src/kernel/blocks/suma/Suma.cpp b/ndb/src/kernel/blocks/suma/Suma.cpp index 88e6dea35ac..754832cd954 100644 --- a/ndb/src/kernel/blocks/suma/Suma.cpp +++ b/ndb/src/kernel/blocks/suma/Suma.cpp @@ -824,7 +824,8 @@ Suma::execUTIL_SEQUENCE_CONF(Signal* signal) return; } - Uint32 subId = conf->sequenceValue[0]; + Uint64 subId; + memcpy(&subId,conf->sequenceValue,8); Uint32 subData = conf->senderData; SubscriberPtr subbPtr; @@ -832,8 +833,8 @@ Suma::execUTIL_SEQUENCE_CONF(Signal* signal) CreateSubscriptionIdConf * subconf = (CreateSubscriptionIdConf*)conf; - subconf->subscriptionId = subId; - subconf->subscriptionKey =(getOwnNodeId() << 16) | (subId & 0xFFFF); + subconf->subscriptionId = (Uint32)subId; + subconf->subscriptionKey =(getOwnNodeId() << 16) | (Uint32)(subId & 0xFFFF); subconf->subscriberData = subbPtr.p->m_senderData; sendSignal(subbPtr.p->m_subscriberRef, GSN_CREATE_SUBID_CONF, signal, @@ -3279,7 +3280,7 @@ SumaParticipant::execSUB_STOP_REQ(Signal* signal){ for (;!subbPtr.isNull(); c_dataSubscribers.next(subbPtr)){ jam(); if (subbPtr.p->m_subPtrI == subPtr.i && - subbPtr.p->m_subscriberRef == subscriberRef && + refToNode(subbPtr.p->m_subscriberRef) == refToNode(subscriberRef) && subbPtr.p->m_subscriberData == subscriberData){ // ndbout_c("STOP_REQ: before c_dataSubscribers.release"); jam(); @@ -3507,6 +3508,8 @@ SumaParticipant::sendSubRemoveRef(Signal* signal, const SubRemoveReq& req, jam(); SubRemoveRef * ref = (SubRemoveRef *)signal->getDataPtrSend(); ref->senderRef = reference(); + ref->subscriptionId = req.subscriptionId; + ref->subscriptionKey = req.subscriptionKey; ref->senderData = req.senderData; ref->err = errCode; if (temporary) diff --git a/ndb/src/kernel/vm/Configuration.cpp b/ndb/src/kernel/vm/Configuration.cpp index 29255fc9837..4ad7050ce63 100644 --- a/ndb/src/kernel/vm/Configuration.cpp +++ b/ndb/src/kernel/vm/Configuration.cpp @@ -521,7 +521,7 @@ Configuration::calcSizeAlt(ConfigValues * ownConfig){ ERROR_SET(fatal, ERR_INVALID_CONFIG, msg, buf); } - noOfDataPages = (dataMem / 8192); + noOfDataPages = (dataMem / 32768); noOfIndexPages = (indexMem / 8192); for(unsigned j = 0; j<LogLevel::LOGLEVEL_CATEGORIES; j++){ diff --git a/ndb/src/mgmsrv/ConfigInfo.cpp b/ndb/src/mgmsrv/ConfigInfo.cpp index 2e2f35f76fa..15ed7703899 100644 --- a/ndb/src/mgmsrv/ConfigInfo.cpp +++ b/ndb/src/mgmsrv/ConfigInfo.cpp @@ -98,6 +98,7 @@ static bool fixDepricated(InitConfigFileParser::Context & ctx, const char *); static bool saveInConfigValues(InitConfigFileParser::Context & ctx, const char *); static bool fixFileSystemPath(InitConfigFileParser::Context & ctx, const char * data); static bool fixBackupDataDir(InitConfigFileParser::Context & ctx, const char * data); +static bool fixShmUniqueId(InitConfigFileParser::Context & ctx, const char * data); const ConfigInfo::SectionRule ConfigInfo::m_SectionRules[] = { @@ -111,6 +112,8 @@ ConfigInfo::m_SectionRules[] = { { "REP", transformNode, 0 }, { "EXTERNAL REP", transformExtNode, 0 }, + { MGM_TOKEN, fixShmUniqueId, 0 }, + { "TCP", checkConnectionSupport, 0 }, { "SHM", checkConnectionSupport, 0 }, { "SCI", checkConnectionSupport, 0 }, @@ -3136,19 +3139,39 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){ DBUG_RETURN(true); } +static bool +fixShmUniqueId(InitConfigFileParser::Context & ctx, const char * data) +{ + DBUG_ENTER("fixShmUniqueId"); + Uint32 nodes= 0; + ctx.m_userProperties.get(ctx.fname, &nodes); + if (nodes == 1) // first management server + { + Uint32 portno= atoi(NDB_PORT); + ctx.m_currentSection->get("PortNumber", &portno); + ctx.m_userProperties.put("ShmUniqueId", portno); + } + DBUG_RETURN(true); +} + static bool fixShmKey(InitConfigFileParser::Context & ctx, const char *) { + DBUG_ENTER("fixShmKey"); Uint32 id1= 0, id2= 0, key= 0; require(ctx.m_currentSection->get("NodeId1", &id1)); require(ctx.m_currentSection->get("NodeId2", &id2)); if(ctx.m_currentSection->get("ShmKey", &key)) - return true; + { + DBUG_RETURN(true); + } - key= (id1 > id2 ? id1 << 16 | id2 : id2 << 16 | id1); + require(ctx.m_userProperties.get("ShmUniqueId", &key)); + key= key << 16 | (id1 > id2 ? id1 << 8 | id2 : id2 << 8 | id1); ctx.m_currentSection->put("ShmKey", key); - return true; + DBUG_PRINT("info",("Added ShmKey=0x%x", key)); + DBUG_RETURN(true); } /** diff --git a/ndb/src/mgmsrv/InitConfigFileParser.cpp b/ndb/src/mgmsrv/InitConfigFileParser.cpp index 5cc5c3e9b32..822e10c89aa 100644 --- a/ndb/src/mgmsrv/InitConfigFileParser.cpp +++ b/ndb/src/mgmsrv/InitConfigFileParser.cpp @@ -228,14 +228,22 @@ bool InitConfigFileParser::parseNameValuePair(Context& ctx, const char* line) Vector<BaseString> tmp_string_split; if (BaseString(line).split(tmp_string_split, - BaseString("=:"), - 2) != 2) + "=:", 2) != 2) { ctx.reportError("Parse error"); return false; } // ************************************* + // Remove all after # + // ************************************* + + Vector<BaseString> tmp_string_split2; + tmp_string_split[1].split(tmp_string_split2, + "#", 2); + tmp_string_split[1]=tmp_string_split2[0]; + + // ************************************* // Remove leading and trailing chars // ************************************* { diff --git a/ndb/src/ndbapi/NdbDictionary.cpp b/ndb/src/ndbapi/NdbDictionary.cpp index 4221c22121d..93a82e4bc83 100644 --- a/ndb/src/ndbapi/NdbDictionary.cpp +++ b/ndb/src/ndbapi/NdbDictionary.cpp @@ -231,6 +231,12 @@ NdbDictionary::Column::equal(const NdbDictionary::Column & col) const { return m_impl.equal(col.m_impl); } +int +NdbDictionary::Column::getSizeInBytes() const +{ + return m_impl.m_attrSize * m_impl.m_arraySize; +} + /***************************************************************** * Table facade */ @@ -426,13 +432,17 @@ NdbDictionary::Table::getRowSizeInBytes() const { int sz = 0; for(int i = 0; i<getNoOfColumns(); i++){ const NdbDictionary::Column * c = getColumn(i); - const NdbColumnImpl & col = NdbColumnImpl::getImpl(* c); - sz += (((col.m_attrSize * col.m_arraySize) + 3) / 4); + sz += (c->getSizeInBytes()+ 3) / 4; } return sz * 4; } int +NdbDictionary::Table::getReplicaCount() const { + return m_impl.m_replicaCount; +} + +int NdbDictionary::Table::createTableInDb(Ndb* pNdb, bool equalOk) const { const NdbDictionary::Table * pTab = pNdb->getDictionary()->getTable(getName()); @@ -1000,6 +1010,7 @@ operator<<(NdbOut& out, const NdbDictionary::Column& col) } const NdbDictionary::Column * NdbDictionary::Column::FRAGMENT = 0; +const NdbDictionary::Column * NdbDictionary::Column::FRAGMENT_MEMORY = 0; const NdbDictionary::Column * NdbDictionary::Column::ROW_COUNT = 0; const NdbDictionary::Column * NdbDictionary::Column::COMMIT_COUNT = 0; const NdbDictionary::Column * NdbDictionary::Column::ROW_SIZE = 0; diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp index d6d8fc5215f..2a9f9be5a30 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -232,6 +232,11 @@ NdbColumnImpl::create_psuedo(const char * name){ col->m_impl.m_attrId = AttributeHeader::FRAGMENT; col->m_impl.m_attrSize = 4; col->m_impl.m_arraySize = 1; + } else if(!strcmp(name, "NDB$FRAGMENT_MEMORY")){ + col->setType(NdbDictionary::Column::Bigunsigned); + col->m_impl.m_attrId = AttributeHeader::FRAGMENT_MEMORY; + col->m_impl.m_attrSize = 8; + 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; @@ -685,10 +690,12 @@ NdbDictionaryImpl::~NdbDictionaryImpl() m_globalHash->lock(); if(--f_dictionary_count == 0){ delete NdbDictionary::Column::FRAGMENT; + delete NdbDictionary::Column::FRAGMENT_MEMORY; delete NdbDictionary::Column::ROW_COUNT; delete NdbDictionary::Column::COMMIT_COUNT; delete NdbDictionary::Column::ROW_SIZE; NdbDictionary::Column::FRAGMENT= 0; + NdbDictionary::Column::FRAGMENT_MEMORY= 0; NdbDictionary::Column::ROW_COUNT= 0; NdbDictionary::Column::COMMIT_COUNT= 0; NdbDictionary::Column::ROW_SIZE= 0; @@ -754,6 +761,8 @@ NdbDictionaryImpl::setTransporter(class Ndb* ndb, if(f_dictionary_count++ == 0){ NdbDictionary::Column::FRAGMENT= NdbColumnImpl::create_psuedo("NDB$FRAGMENT"); + NdbDictionary::Column::FRAGMENT_MEMORY= + NdbColumnImpl::create_psuedo("NDB$FRAGMENT_MEMORY"); NdbDictionary::Column::ROW_COUNT= NdbColumnImpl::create_psuedo("NDB$ROW_COUNT"); NdbDictionary::Column::COMMIT_COUNT= @@ -793,7 +802,7 @@ NdbDictInterface::setTransporter(class TransporterFacade * tf) execNodeStatus); if ( m_blockNumber == -1 ) { - m_error.code = 4105; + m_error.code= 4105; return false; // no more free blocknumbers }//if Uint32 theNode = tf->ownId(); @@ -947,7 +956,7 @@ NdbDictInterface::dictSignal(NdbApiSignal* signal, aNodeId = m_transporter->get_an_alive_node(); } if(aNodeId == 0){ - m_error.code = 4009; + m_error.code= 4009; m_transporter->unlock_mutex(); DBUG_RETURN(-1); } @@ -974,7 +983,7 @@ NdbDictInterface::dictSignal(NdbApiSignal* signal, } } - m_error.code = 0; + m_error.code= 0; m_waiter.m_node = aNodeId; m_waiter.m_state = wst; @@ -1042,7 +1051,7 @@ NdbDictInterface::getTable(const char * name, bool fullyQualifiedNames) const Uint32 strLen = strlen(name) + 1; // NULL Terminated if(strLen > MAX_TAB_NAME_SIZE) {//sizeof(req->tableName)){ - m_error.code = 4307; + m_error.code= 4307; return 0; } @@ -1079,9 +1088,9 @@ NdbDictInterface::getTable(class NdbApiSignal * signal, if (r) return 0; NdbTableImpl * rt = 0; - m_error.code = parseTableInfo(&rt, - (Uint32*)m_buffer.get_data(), - m_buffer.length() / 4, fullyQualifiedNames); + m_error.code= parseTableInfo(&rt, + (Uint32*)m_buffer.get_data(), + m_buffer.length() / 4, fullyQualifiedNames); rt->buildColumnHash(); return rt; } @@ -1116,7 +1125,7 @@ NdbDictInterface::execGET_TABINFO_REF(NdbApiSignal * signal, { const GetTabInfoRef* ref = CAST_CONSTPTR(GetTabInfoRef, signal->getDataPtr()); - m_error.code = ref->errorCode; + m_error.code= ref->errorCode; m_waiter.signal(NO_WAIT); } @@ -1264,7 +1273,8 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret, Uint32 blobCount = 0; Uint32 distKeys = 0; - for(Uint32 i = 0; i < tableDesc.NoOfAttributes; i++) { + Uint32 i; + for(i = 0; i < tableDesc.NoOfAttributes; i++) { DictTabInfo::Attribute attrDesc; attrDesc.init(); s = SimpleProperties::unpack(it, &attrDesc, @@ -1348,9 +1358,9 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret, if(tableDesc.FragmentDataLen > 0) { - int i; - Uint32 fragCount = tableDesc.FragmentData[0]; - Uint32 replicaCount = tableDesc.FragmentData[1]; + Uint32 replicaCount = tableDesc.FragmentData[0]; + Uint32 fragCount = tableDesc.FragmentData[1]; + impl->m_replicaCount = replicaCount; impl->m_fragmentCount = fragCount; @@ -1359,9 +1369,6 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret, impl->m_fragments.push_back(tableDesc.FragmentData[i+2]); } - impl->m_replicaCount = replicaCount; - impl->m_fragmentCount = fragCount; - Uint32 topBit = (1 << 31); for(int i = 31; i>=0; i--){ if((fragCount & topBit) != 0) @@ -1379,6 +1386,15 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret, impl->m_hashpointerValue = 0; } + if(distKeys == 0) + { + for(i = 0; i < tableDesc.NoOfAttributes; i++) + { + if(impl->m_columns[i]->getPrimaryKey()) + impl->m_columns[i]->m_distributionKey = true; + } + } + * ret = impl; DBUG_RETURN(0); @@ -1398,13 +1414,13 @@ NdbDictionaryImpl::createTable(NdbTableImpl &t) Ndb_local_table_info *info= get_local_table_info(t.m_internalName.c_str(),false); if (info == NULL) { - m_error.code = 709; + m_error.code= 709; return -1; } if (createBlobTables(*(info->m_table_impl)) != 0) { int save_code = m_error.code; (void)dropTable(t); - m_error.code = save_code; + m_error.code= save_code; return -1; } return 0; @@ -1470,11 +1486,10 @@ int NdbDictionaryImpl::alterTable(NdbTableImpl &impl) BaseString internalName = impl.m_internalName; const char * originalInternalName = internalName.c_str(); BaseString externalName = impl.m_externalName; - const char * originalExternalName = externalName.c_str(); DBUG_ENTER("NdbDictionaryImpl::alterTable"); if(!get_local_table_info(originalInternalName, false)){ - m_error.code = 709; + m_error.code= 709; DBUG_RETURN(-1); } // Alter the table @@ -1510,12 +1525,12 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, DBUG_ENTER("NdbDictInterface::createOrAlterTable"); unsigned i; if((unsigned)impl.getNoOfPrimaryKeys() > NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY){ - m_error.code = 4317; + m_error.code= 4317; DBUG_RETURN(-1); } unsigned sz = impl.m_columns.size(); if (sz > NDB_MAX_ATTRIBUTES_IN_TABLE){ - m_error.code = 4318; + m_error.code= 4318; DBUG_RETURN(-1); } @@ -1540,7 +1555,7 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, continue; if (col->m_autoIncrement) { if (haveAutoIncrement) { - m_error.code = 4335; + m_error.code= 4335; DBUG_RETURN(-1); } haveAutoIncrement = true; @@ -1550,7 +1565,7 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, // Check max length of frm data if (impl.m_frm.length() > MAX_FRM_DATA_SIZE){ - m_error.code = 1229; + m_error.code= 1229; DBUG_RETURN(-1); } tmpTab.FrmLen = impl.m_frm.length(); @@ -1598,22 +1613,22 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, // check type and compute attribute size and array size if (! tmpAttr.translateExtType()) { - m_error.code = 703; + m_error.code= 703; DBUG_RETURN(-1); } // charset is defined exactly for char types if (col->getCharType() != (col->m_cs != NULL)) { - m_error.code = 703; + m_error.code= 703; DBUG_RETURN(-1); } // primary key type check if (col->m_pk && ! NdbSqlUtil::usable_in_pk(col->m_type, col->m_cs)) { - m_error.code = 743; + m_error.code= 743; DBUG_RETURN(-1); } // distribution key not supported for Char attribute if (col->m_distributionKey && col->m_cs != NULL) { - m_error.code = 745; + m_error.code= 745; DBUG_RETURN(-1); } // charset in upper half of precision @@ -1671,7 +1686,7 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, if (!ndb.setAutoIncrementValue(impl.m_externalName.c_str(), autoIncrementValue)) { if (ndb.theError.code == 0) { - m_error.code = 4336; + m_error.code= 4336; ndb.theError = m_error; } else m_error= ndb.theError; @@ -1707,11 +1722,12 @@ void NdbDictInterface::execCREATE_TABLE_CONF(NdbApiSignal * signal, LinearSectionPtr ptr[3]) { +#if 0 const CreateTableConf* const conf= CAST_CONSTPTR(CreateTableConf, signal->getDataPtr()); Uint32 tableId= conf->tableId; Uint32 tableVersion= conf->tableVersion; - +#endif m_waiter.signal(NO_WAIT); } @@ -1721,7 +1737,7 @@ NdbDictInterface::execCREATE_TABLE_REF(NdbApiSignal * signal, { const CreateTableRef* const ref= CAST_CONSTPTR(CreateTableRef, signal->getDataPtr()); - m_error.code = ref->errorCode; + m_error.code= ref->errorCode; m_masterNodeId = ref->masterNodeId; m_waiter.signal(NO_WAIT); } @@ -1765,7 +1781,7 @@ NdbDictInterface::execALTER_TABLE_REF(NdbApiSignal * signal, { const AlterTableRef * const ref = CAST_CONSTPTR(AlterTableRef, signal->getDataPtr()); - m_error.code = ref->errorCode; + m_error.code= ref->errorCode; m_masterNodeId = ref->masterNodeId; m_waiter.signal(NO_WAIT); } @@ -1810,7 +1826,7 @@ NdbDictionaryImpl::dropTable(NdbTableImpl & impl) } if (impl.m_indexType != NdbDictionary::Index::Undefined) { - m_receiver.m_error.code = 1228; + m_receiver.m_error.code= 1228; return -1; } @@ -1920,7 +1936,7 @@ NdbDictInterface::execDROP_TABLE_REF(NdbApiSignal * signal, LinearSectionPtr ptr[3]) { const DropTableRef* const ref = CAST_CONSTPTR(DropTableRef, signal->getDataPtr()); - m_error.code = ref->errorCode; + m_error.code= ref->errorCode; m_masterNodeId = ref->masterNodeId; m_waiter.signal(NO_WAIT); } @@ -2372,7 +2388,7 @@ NdbDictionaryImpl::createEvent(NdbEventImpl & evnt) const NdbColumnImpl* col = table.getColumn(evnt.m_columns[i]->m_name.c_str()); if(col == 0){ - m_error.code = 4247; + m_error.code= 4247; return -1; } // Copy column definition @@ -2398,7 +2414,7 @@ NdbDictionaryImpl::createEvent(NdbEventImpl & evnt) // Check for illegal duplicate attributes for(i = 1; i<attributeList_sz; i++) { if (evnt.m_columns[i-1]->m_attrId == evnt.m_columns[i]->m_attrId) { - m_error.code = 4258; + m_error.code= 4258; return -1; } } @@ -2446,7 +2462,7 @@ NdbDictInterface::createEvent(class Ndb & ndb, const size_t len = strlen(evnt.m_externalName.c_str()) + 1; if(len > MAX_TAB_NAME_SIZE) { - m_error.code = 4241; + m_error.code= 4241; return -1; } @@ -2559,9 +2575,7 @@ int NdbDictInterface::stopSubscribeEvent(class Ndb & ndb, NdbEventImpl & evnt) { -#ifdef EVENT_DEBUG - ndbout_c("SUB_STOP_REQ"); -#endif + DBUG_ENTER("NdbDictInterface::stopSubscribeEvent"); NdbApiSignal tSignal(m_reference); // tSignal.theReceiversBlockNumber = SUMA; @@ -2577,7 +2591,7 @@ NdbDictInterface::stopSubscribeEvent(class Ndb & ndb, sumaStop->part = (Uint32) SubscriptionData::TableData; sumaStop->subscriberRef = m_reference; - return stopSubscribeEvent(&tSignal, NULL); + DBUG_RETURN(stopSubscribeEvent(&tSignal, NULL)); } int @@ -2637,7 +2651,7 @@ NdbDictionaryImpl::getEvent(const char * eventName) #ifdef EVENT_DEBUG ndbout_c("NdbDictionaryImpl::getEvent could not find column id %d", id); #endif - m_error.code = 4247; + m_error.code= 4247; delete ev; return NULL; } @@ -2655,9 +2669,8 @@ void NdbDictInterface::execCREATE_EVNT_CONF(NdbApiSignal * signal, LinearSectionPtr ptr[3]) { -#ifdef EVENT_DEBUG - ndbout << "NdbDictionaryImpl.cpp: execCREATE_EVNT_CONF" << endl; -#endif + DBUG_ENTER("NdbDictInterface::execCREATE_EVNT_CONF"); + m_buffer.clear(); unsigned int len = signal->getLength() << 2; m_buffer.append((char *)&len, sizeof(len)); @@ -2667,45 +2680,49 @@ NdbDictInterface::execCREATE_EVNT_CONF(NdbApiSignal * signal, m_buffer.append((char *)ptr[0].p, strlen((char *)ptr[0].p)+1); } + const CreateEvntConf * const createEvntConf= + CAST_CONSTPTR(CreateEvntConf, signal->getDataPtr()); + + Uint32 subscriptionId = createEvntConf->getEventId(); + Uint32 subscriptionKey = createEvntConf->getEventKey(); + + DBUG_PRINT("info",("subscriptionId=%d,subscriptionKey=%d", + subscriptionId,subscriptionKey)); m_waiter.signal(NO_WAIT); + DBUG_VOID_RETURN; } void NdbDictInterface::execCREATE_EVNT_REF(NdbApiSignal * signal, LinearSectionPtr ptr[3]) { -#ifdef EVENT_DEBUG - ndbout << "NdbDictionaryImpl.cpp: execCREATE_EVNT_REF" << endl; - ndbout << "Exiting" << endl; - exit(-1); -#endif + DBUG_ENTER("NdbDictInterface::execCREATE_EVNT_REF"); - const CreateEvntRef* const ref = CAST_CONSTPTR(CreateEvntRef, signal->getDataPtr()); - m_error.code = ref->getErrorCode(); -#ifdef EVENT_DEBUG - ndbout_c("execCREATE_EVNT_REF"); - ndbout_c("ErrorCode %u", ref->getErrorCode()); - ndbout_c("Errorline %u", ref->getErrorLine()); - ndbout_c("ErrorNode %u", ref->getErrorNode()); -#endif - m_waiter.signal(NO_WAIT); + const CreateEvntRef* const ref= + CAST_CONSTPTR(CreateEvntRef, signal->getDataPtr()); + m_error.code= ref->getErrorCode(); + DBUG_PRINT("error",("error=%d,line=%d,node=%d",ref->getErrorCode(), + ref->getErrorLine(),ref->getErrorNode())); + m_waiter.signal(NO_WAIT); + DBUG_VOID_RETURN; } void NdbDictInterface::execSUB_STOP_CONF(NdbApiSignal * signal, LinearSectionPtr ptr[3]) { - DBUG_ENTER("NdbDictInterface::execSUB_STOP_REF"); -#ifdef EVENT_DEBUG - ndbout << "Got GSN_SUB_STOP_CONF" << endl; -#endif - // SubRemoveConf * const sumaRemoveConf = CAST_CONSTPTR(SubRemoveConf, signal->getDataPtr()); + DBUG_ENTER("NdbDictInterface::execSUB_STOP_CONF"); + const SubStopConf * const subStopConf= + CAST_CONSTPTR(SubStopConf, signal->getDataPtr()); - // Uint32 subscriptionId = sumaRemoveConf->subscriptionId; - // Uint32 subscriptionKey = sumaRemoveConf->subscriptionKey; - // Uint32 senderData = sumaRemoveConf->senderData; + Uint32 subscriptionId = subStopConf->subscriptionId; + Uint32 subscriptionKey = subStopConf->subscriptionKey; + Uint32 subscriberData = subStopConf->subscriberData; + DBUG_PRINT("info",("subscriptionId=%d,subscriptionKey=%d,subscriberData=%d", + subscriptionId,subscriptionKey,subscriberData)); m_waiter.signal(NO_WAIT); + DBUG_VOID_RETURN; } void @@ -2713,19 +2730,17 @@ NdbDictInterface::execSUB_STOP_REF(NdbApiSignal * signal, LinearSectionPtr ptr[3]) { DBUG_ENTER("NdbDictInterface::execSUB_STOP_REF"); -#ifdef EVENT_DEBUG - ndbout << "Got GSN_SUB_STOP_REF" << endl; -#endif - const SubRemoveRef * const sumaRemoveRef= - CAST_CONSTPTR(SubRemoveRef, signal->getDataPtr()); + const SubStopRef * const subStopRef= + CAST_CONSTPTR(SubStopRef, signal->getDataPtr()); - // Uint32 subscriptionId = sumaRemoveRef->subscriptionId; - // Uint32 subscriptionKey = sumaRemoveRef->subscriptionKey; - // Uint32 senderData = sumaRemoveRef->senderData; + Uint32 subscriptionId = subStopRef->subscriptionId; + Uint32 subscriptionKey = subStopRef->subscriptionKey; + Uint32 subscriberData = subStopRef->subscriberData; + m_error.code= subStopRef->errorCode; - m_error.code= sumaRemoveRef->errorCode; + DBUG_PRINT("error",("subscriptionId=%d,subscriptionKey=%d,subscriberData=%d,error=%d", + subscriptionId,subscriptionKey,subscriberData,m_error.code)); m_waiter.signal(NO_WAIT); - DBUG_VOID_RETURN; } @@ -2733,57 +2748,55 @@ void NdbDictInterface::execSUB_START_CONF(NdbApiSignal * signal, LinearSectionPtr ptr[3]) { -#ifdef EVENT_DEBUG - ndbout << "Got GSN_SUB_START_CONF" << endl; -#endif - const SubStartConf * const sumaStartConf = CAST_CONSTPTR(SubStartConf, signal->getDataPtr()); + DBUG_ENTER("NdbDictInterface::execSUB_START_CONF"); + const SubStartConf * const subStartConf= + CAST_CONSTPTR(SubStartConf, signal->getDataPtr()); - // Uint32 subscriptionId = sumaStartConf->subscriptionId; - // Uint32 subscriptionKey = sumaStartConf->subscriptionKey; + Uint32 subscriptionId = subStartConf->subscriptionId; + Uint32 subscriptionKey = subStartConf->subscriptionKey; SubscriptionData::Part part = - (SubscriptionData::Part)sumaStartConf->part; - // Uint32 subscriberData = sumaStartConf->subscriberData; + (SubscriptionData::Part)subStartConf->part; + Uint32 subscriberData = subStartConf->subscriberData; switch(part) { case SubscriptionData::MetaData: { -#ifdef EVENT_DEBUG - ndbout << "SubscriptionData::MetaData" << endl; -#endif - m_error.code = 1; + DBUG_PRINT("error",("SubscriptionData::MetaData")); + m_error.code= 1; break; } case SubscriptionData::TableData: { -#ifdef EVENT_DEBUG - ndbout << "SubscriptionData::TableData" << endl; -#endif + DBUG_PRINT("info",("SubscriptionData::TableData")); break; } default: { -#ifdef EVENT_DEBUG - ndbout_c("NdbDictInterface::execSUB_START_CONF wrong data"); -#endif - m_error.code = 1; + DBUG_PRINT("error",("wrong data")); + m_error.code= 2; break; } } + DBUG_PRINT("info",("subscriptionId=%d,subscriptionKey=%d,subscriberData=%d", + subscriptionId,subscriptionKey,subscriberData)); m_waiter.signal(NO_WAIT); + DBUG_VOID_RETURN; } void NdbDictInterface::execSUB_START_REF(NdbApiSignal * signal, LinearSectionPtr ptr[3]) { -#ifdef EVENT_DEBUG - ndbout << "Got GSN_SUB_START_REF" << endl; -#endif - m_error.code = 1; - m_waiter.signal(NO_WAIT); + DBUG_ENTER("NdbDictInterface::execSUB_START_REF"); + const SubStartRef * const subStartRef= + CAST_CONSTPTR(SubStartRef, signal->getDataPtr()); + m_error.code= subStartRef->errorCode; + m_waiter.signal(NO_WAIT); + DBUG_VOID_RETURN; } void NdbDictInterface::execSUB_GCP_COMPLETE_REP(NdbApiSignal * signal, LinearSectionPtr ptr[3]) { - const SubGcpCompleteRep * const rep = CAST_CONSTPTR(SubGcpCompleteRep, signal->getDataPtr()); + const SubGcpCompleteRep * const rep= + CAST_CONSTPTR(SubGcpCompleteRep, signal->getDataPtr()); const Uint32 gci = rep->gci; // const Uint32 senderRef = rep->senderRef; @@ -2794,7 +2807,8 @@ NdbDictInterface::execSUB_GCP_COMPLETE_REP(NdbApiSignal * signal, const Uint32 ref = signal->theSendersBlockRef; NdbApiSignal tSignal(m_reference); - SubGcpCompleteAcc * acc = CAST_PTR(SubGcpCompleteAcc, tSignal.getDataPtrSend()); + SubGcpCompleteAcc * acc= + CAST_PTR(SubGcpCompleteAcc, tSignal.getDataPtrSend()); acc->rep = *rep; @@ -2852,9 +2866,9 @@ NdbDictInterface::execSUB_TABLE_DATA(NdbApiSignal * signal, int NdbDictionaryImpl::dropEvent(const char * eventName) { - NdbEventImpl *ev = new NdbEventImpl(); + NdbEventImpl *ev= new NdbEventImpl(); ev->setName(eventName); - int ret = m_receiver.dropEvent(*ev); + int ret= m_receiver.dropEvent(*ev); delete ev; // printf("__________________RET %u\n", ret); @@ -2903,31 +2917,25 @@ void NdbDictInterface::execDROP_EVNT_CONF(NdbApiSignal * signal, LinearSectionPtr ptr[3]) { -#ifdef EVENT_DEBUG - ndbout << "NdbDictionaryImpl.cpp: execDROP_EVNT_CONF" << endl; -#endif - + DBUG_ENTER("NdbDictInterface::execDROP_EVNT_CONF"); m_waiter.signal(NO_WAIT); + DBUG_VOID_RETURN; } void NdbDictInterface::execDROP_EVNT_REF(NdbApiSignal * signal, LinearSectionPtr ptr[3]) { -#ifdef EVENT_DEBUG - ndbout << "NdbDictionaryImpl.cpp: execDROP_EVNT_REF" << endl; -#endif - const DropEvntRef* const ref = CAST_CONSTPTR(DropEvntRef, signal->getDataPtr()); - m_error.code = ref->getErrorCode(); + DBUG_ENTER("NdbDictInterface::execDROP_EVNT_REF"); + const DropEvntRef* const ref= + CAST_CONSTPTR(DropEvntRef, signal->getDataPtr()); + m_error.code= ref->getErrorCode(); -#if 0 - ndbout_c("execDROP_EVNT_REF"); - ndbout_c("ErrorCode %u", ref->getErrorCode()); - ndbout_c("Errorline %u", ref->getErrorLine()); - ndbout_c("ErrorNode %u", ref->getErrorNode()); -#endif + DBUG_PRINT("info",("ErrorCode=%u Errorline=%u ErrorNode=%u", + ref->getErrorCode(), ref->getErrorLine(), ref->getErrorNode())); - m_waiter.signal(NO_WAIT); + m_waiter.signal(NO_WAIT); + DBUG_VOID_RETURN; } /***************************************************************** @@ -2992,7 +3000,7 @@ NdbDictInterface::listObjects(NdbDictionary::Dictionary::List& list, } if (! ok) { // bad signal data - m_error.code = 4213; + m_error.code= 4213; return -1; } list.count = count; @@ -3058,7 +3066,7 @@ NdbDictInterface::listObjects(NdbApiSignal* signal) m_transporter->lock_mutex(); Uint16 aNodeId = m_transporter->get_an_alive_node(); if (aNodeId == 0) { - m_error.code = 4009; + m_error.code= 4009; m_transporter->unlock_mutex(); return -1; } @@ -3066,7 +3074,7 @@ NdbDictInterface::listObjects(NdbApiSignal* signal) m_transporter->unlock_mutex(); continue; } - m_error.code = 0; + m_error.code= 0; m_waiter.m_node = aNodeId; m_waiter.m_state = WAIT_LIST_TABLES_CONF; m_waiter.wait(WAITFOR_RESPONSE_TIMEOUT); diff --git a/ndb/src/ndbapi/NdbEventOperationImpl.cpp b/ndb/src/ndbapi/NdbEventOperationImpl.cpp index 69c05dcb0b7..9cea3ec83cd 100644 --- a/ndb/src/ndbapi/NdbEventOperationImpl.cpp +++ b/ndb/src/ndbapi/NdbEventOperationImpl.cpp @@ -120,24 +120,26 @@ NdbEventOperationImpl::getState() NdbRecAttr* NdbEventOperationImpl::getValue(const char *colName, char *aValue, int n) { + DBUG_ENTER("NdbEventOperationImpl::getValue"); if (m_state != EO_CREATED) { ndbout_c("NdbEventOperationImpl::getValue may only be called between instantiation and execute()"); - return NULL; + DBUG_RETURN(NULL); } NdbColumnImpl *tAttrInfo = m_eventImpl->m_tableImpl->getColumn(colName); if (tAttrInfo == NULL) { ndbout_c("NdbEventOperationImpl::getValue attribute %s not found",colName); - return NULL; + DBUG_RETURN(NULL); } - return NdbEventOperationImpl::getValue(tAttrInfo, aValue, n); + DBUG_RETURN(NdbEventOperationImpl::getValue(tAttrInfo, aValue, n)); } NdbRecAttr* NdbEventOperationImpl::getValue(const NdbColumnImpl *tAttrInfo, char *aValue, int n) { + DBUG_ENTER("NdbEventOperationImpl::getValue"); // Insert Attribute Id into ATTRINFO part. NdbRecAttr *&theFirstRecAttr = theFirstRecAttrs[n]; NdbRecAttr *&theCurrentRecAttr = theCurrentRecAttrs[n]; @@ -149,7 +151,7 @@ NdbEventOperationImpl::getValue(const NdbColumnImpl *tAttrInfo, char *aValue, in if (tRecAttr == NULL) { exit(-1); //setErrorCodeAbort(4000); - return NULL; + DBUG_RETURN(NULL); } /********************************************************************** @@ -161,7 +163,7 @@ NdbEventOperationImpl::getValue(const NdbColumnImpl *tAttrInfo, char *aValue, in //setErrorCodeAbort(4000); m_ndb->releaseRecAttr(tRecAttr); exit(-1); - return NULL; + DBUG_RETURN(NULL); } //theErrorLine++; @@ -193,7 +195,7 @@ NdbEventOperationImpl::getValue(const NdbColumnImpl *tAttrInfo, char *aValue, in tRecAttr->release(); // do I need to do this? m_ndb->releaseRecAttr(tRecAttr); exit(-1); - return NULL; + DBUG_RETURN(NULL); } // this is it, between p and p_next p->next(tRecAttr); @@ -201,16 +203,17 @@ NdbEventOperationImpl::getValue(const NdbColumnImpl *tAttrInfo, char *aValue, in } } - return tRecAttr; + DBUG_RETURN(tRecAttr); } int NdbEventOperationImpl::execute() { + DBUG_ENTER("NdbEventOperationImpl::execute"); NdbDictionary::Dictionary *myDict = m_ndb->getDictionary(); if (!myDict) { m_error.code= m_ndb->getNdbError().code; - return -1; + DBUG_RETURN(-1); } if (theFirstRecAttrs[0] == NULL) { // defaults to get all @@ -221,13 +224,14 @@ NdbEventOperationImpl::execute() int hasSubscriber; - int r= - m_bufferHandle->prepareAddSubscribeEvent(m_eventImpl->m_eventId, - hasSubscriber /* return value */); + int r= m_bufferHandle->prepareAddSubscribeEvent(this, + hasSubscriber /*return value*/); m_error.code= 4709; if (r < 0) - return -1; + { + DBUG_RETURN(-1); + } m_eventImpl->m_bufferId = m_bufferId = (Uint32)r; @@ -252,7 +256,7 @@ NdbEventOperationImpl::execute() //Error m_state = EO_ERROR; } - return r; + DBUG_RETURN(r); } int @@ -260,7 +264,9 @@ NdbEventOperationImpl::stop() { DBUG_ENTER("NdbEventOperationImpl::stop"); if (m_state != EO_EXECUTING) + { DBUG_RETURN(-1); + } // ndbout_c("NdbEventOperation::stopping()"); @@ -330,6 +336,7 @@ NdbEventOperationImpl::getLatestGCI() int NdbEventOperationImpl::next(int *pOverrun) { + DBUG_ENTER("NdbEventOperationImpl::next"); int nr = 10000; // a high value int tmpOverrun = 0; int *ptmpOverrun; @@ -346,7 +353,10 @@ NdbEventOperationImpl::next(int *pOverrun) *pOverrun = tmpOverrun; } - if (r <= 0) return r; // no data + if (r <= 0) + { + DBUG_RETURN(r); // no data + } if (r < nr) r = nr; else nr--; // we don't want to be stuck here forever @@ -356,7 +366,10 @@ NdbEventOperationImpl::next(int *pOverrun) // now move the data into the RecAttrs if ((theFirstRecAttrs[0] == NULL) && - (theFirstRecAttrs[1] == NULL)) return r; + (theFirstRecAttrs[1] == NULL)) + { + DBUG_RETURN(r); + } // no copying since no RecAttr's @@ -464,9 +477,11 @@ NdbEventOperationImpl::next(int *pOverrun) } if (hasSomeData) - return r; + { + DBUG_RETURN(r); + } } - return 0; + DBUG_RETURN(0); } NdbDictionary::Event::TableEvent @@ -641,23 +656,28 @@ NdbGlobalEventBufferHandle::~NdbGlobalEventBufferHandle() void NdbGlobalEventBufferHandle::addBufferId(int bufferId) { + DBUG_ENTER("NdbGlobalEventBufferHandle::addBufferId"); + DBUG_PRINT("enter",("bufferId=%d",bufferId)); if (m_nids >= NDB_MAX_ACTIVE_EVENTS) { ndbout_c("NdbGlobalEventBufferHandle::addBufferId error in paramerer setting"); exit(-1); } m_bufferIds[m_nids] = bufferId; m_nids++; + DBUG_VOID_RETURN; } void NdbGlobalEventBufferHandle::dropBufferId(int bufferId) { + DBUG_ENTER("NdbGlobalEventBufferHandle::dropBufferId"); + DBUG_PRINT("enter",("bufferId=%d",bufferId)); for (int i = 0; i < m_nids; i++) if (m_bufferIds[i] == bufferId) { m_nids--; for (; i < m_nids; i++) m_bufferIds[i] = m_bufferIds[i+1]; - return; + DBUG_VOID_RETURN; } ndbout_c("NdbGlobalEventBufferHandle::dropBufferId %d does not exist", bufferId); @@ -676,10 +696,11 @@ NdbGlobalEventBufferHandle::drop(NdbGlobalEventBufferHandle *handle) } */ int -NdbGlobalEventBufferHandle::prepareAddSubscribeEvent(Uint32 eventId, - int& hasSubscriber) +NdbGlobalEventBufferHandle::prepareAddSubscribeEvent +(NdbEventOperationImpl *eventOp, int& hasSubscriber) { - ADD_DROP_LOCK_GUARDR(int,real_prepareAddSubscribeEvent(this, eventId, hasSubscriber)); + ADD_DROP_LOCK_GUARDR(int,real_prepareAddSubscribeEvent(this, eventOp, + hasSubscriber)); } void NdbGlobalEventBufferHandle::addSubscribeEvent @@ -841,7 +862,7 @@ NdbGlobalEventBuffer::real_init (NdbGlobalEventBufferHandle *h, // (BufItem *)NdbMem_Allocate(m_max*sizeof(BufItem)); for (int i=0; i<m_max; i++) { - m_buf[i].gId = 0; + m_buf[i].gId= 0; } } // TODO make sure we don't hit roof @@ -870,20 +891,22 @@ NdbGlobalEventBuffer::real_remove(NdbGlobalEventBufferHandle *h) exit(-1); } -int +int NdbGlobalEventBuffer::real_prepareAddSubscribeEvent -(NdbGlobalEventBufferHandle *aHandle, Uint32 eventId, int& hasSubscriber) +(NdbGlobalEventBufferHandle *aHandle, NdbEventOperationImpl *eventOp, + int& hasSubscriber) { DBUG_ENTER("NdbGlobalEventBuffer::real_prepareAddSubscribeEvent"); int i; - int bufferId = -1; + int bufferId= -1; + Uint32 eventId= eventOp->m_eventId; // add_drop_lock(); // only one thread can do add or drop at a time // Find place where eventId already set for (i=0; i<m_no; i++) { if (m_buf[i].gId == eventId) { - bufferId = i; + bufferId= i; break; } } @@ -891,56 +914,55 @@ NdbGlobalEventBuffer::real_prepareAddSubscribeEvent // find space for new bufferId for (i=0; i<m_no; i++) { if (m_buf[i].gId == 0) { - bufferId = i; // we found an empty spot - break; + bufferId= i; // we found an empty spot + goto found_bufferId; } } if (bufferId < 0 && m_no < m_max) { // room for more so get that - bufferId=m_no; - m_buf[m_no].gId = 0; + bufferId= m_no; + m_buf[m_no].gId= 0; m_no++; } else { - ndbout_c("prepareAddSubscribeEvent: Can't accept more subscribers"); - // add_drop_unlock(); + // add_drop_unlock(); DBUG_PRINT("error",("Can't accept more subscribers:" " bufferId=%d, m_no=%d, m_max=%d", bufferId, m_no, m_max)); DBUG_RETURN(-1); } } +found_bufferId: - BufItem &b = m_buf[ID(bufferId)]; + BufItem &b= m_buf[ID(bufferId)]; if (b.gId == 0) { // first subscriber needs some initialization - bufferId = NO_ID(0, bufferId); + bufferId= NO_ID(0, bufferId); - b.gId = eventId; + b.gId= eventId; + b.eventType= (Uint32)eventOp->m_eventImpl->mi_type; - if ((b.p_buf_mutex = NdbMutex_Create()) == NULL) { + if ((b.p_buf_mutex= NdbMutex_Create()) == NULL) { ndbout_c("NdbGlobalEventBuffer: NdbMutex_Create() failed"); - exit(-1); + abort(); } - b.subs = 0; - b.f = 0; - b.sz = 0; - b.max_sz = aHandle->m_bufferL; - b.data = + b.subs= 0; + b.f= 0; + b.sz= 0; + b.max_sz= aHandle->m_bufferL; + b.data= (BufItem::Data *)NdbMem_Allocate(b.max_sz*sizeof(BufItem::Data)); for (int i = 0; i < b.max_sz; i++) { - b.data[i].sdata = NULL; - b.data[i].ptr[0].p = NULL; - b.data[i].ptr[1].p = NULL; - b.data[i].ptr[2].p = NULL; + b.data[i].sdata= NULL; + b.data[i].ptr[0].p= NULL; + b.data[i].ptr[1].p= NULL; + b.data[i].ptr[2].p= NULL; } } else { -#ifdef EVENT_DEBUG - ndbout_c("NdbGlobalEventBuffer::prepareAddSubscribeEvent: TRYING handle one subscriber per event b.subs = %u", b.subs); -#endif - + DBUG_PRINT("info", + ("TRYING handle one subscriber per event b.subs=%u",b.subs)); int ni = -1; for(int i=0; i < b.subs;i++) { if (b.ps[i].theHandle == NULL) { @@ -952,7 +974,8 @@ NdbGlobalEventBuffer::real_prepareAddSubscribeEvent if (b.subs < MAX_SUBSCRIBERS_PER_EVENT) { ni = b.subs; } else { - ndbout_c("prepareAddSubscribeEvent: Can't accept more subscribers"); + DBUG_PRINT("error", + ("Can't accept more subscribers: b.subs=%d",b.subs)); // add_drop_unlock(); DBUG_RETURN(-1); } @@ -975,10 +998,8 @@ NdbGlobalEventBuffer::real_prepareAddSubscribeEvent else hasSubscriber = 0; -#ifdef EVENT_DEBUG - ndbout_c("prepareAddSubscribeEvent: handed out bufferId %d for eventId %d", - bufferId, eventId); -#endif + DBUG_PRINT("info",("handed out bufferId=%d for eventId=%d hasSubscriber=%d", + bufferId, eventId, hasSubscriber)); /* we now have a lock on the prepare so that no one can mess with this * unlock comes in unprepareAddSubscribeEvent or addSubscribeEvent @@ -989,9 +1010,13 @@ NdbGlobalEventBuffer::real_prepareAddSubscribeEvent void NdbGlobalEventBuffer::real_unprepareAddSubscribeEvent(int bufferId) { + DBUG_ENTER("NdbGlobalEventBuffer::real_unprepareAddSubscribeEvent"); BufItem &b = m_buf[ID(bufferId)]; int n = NO(bufferId); + DBUG_PRINT("enter", ("bufferId=%d,ID(bufferId)=%d,NO(bufferId)=%d", + bufferId, ID(bufferId), NO(bufferId))); + b.ps[n].theHandle = NULL; // remove subscribers from the end, @@ -1004,10 +1029,8 @@ NdbGlobalEventBuffer::real_unprepareAddSubscribeEvent(int bufferId) break; if (b.subs == 0) { -#ifdef EVENT_DEBUG - ndbout_c("unprepareAddSubscribeEvent: no more subscribers left on eventId %d", b.gId); -#endif - b.gId = 0; // We don't have any subscribers, reuse BufItem + DBUG_PRINT("info",("no more subscribers left on eventId %d", b.gId)); + b.gId= 0; // We don't have any subscribers, reuse BufItem if (b.data) { NdbMem_Free((void *)b.data); b.data = NULL; @@ -1018,12 +1041,14 @@ NdbGlobalEventBuffer::real_unprepareAddSubscribeEvent(int bufferId) } } // add_drop_unlock(); + DBUG_VOID_RETURN; } void NdbGlobalEventBuffer::real_addSubscribeEvent(int bufferId, void *ndbEventOperation) { + DBUG_ENTER("NdbGlobalEventBuffer::real_addSubscribeEvent"); BufItem &b = m_buf[ID(bufferId)]; int n = NO(bufferId); @@ -1031,9 +1056,8 @@ NdbGlobalEventBuffer::real_addSubscribeEvent(int bufferId, b.ps[n].theHandle->addBufferId(bufferId); // add_drop_unlock(); -#ifdef EVENT_DEBUG - ndbout_c("addSubscribeEvent:: added bufferId %d", bufferId); -#endif + DBUG_PRINT("info",("added bufferId %d", bufferId)); + DBUG_VOID_RETURN; } void @@ -1062,7 +1086,9 @@ NdbGlobalEventBuffer::real_prepareDropSubscribeEvent(int bufferId, else if (n == 1) hasSubscriber = 0; else + { DBUG_RETURN(-1); + } DBUG_RETURN(0); } @@ -1070,6 +1096,7 @@ NdbGlobalEventBuffer::real_prepareDropSubscribeEvent(int bufferId, void NdbGlobalEventBuffer::real_dropSubscribeEvent(int bufferId) { + DBUG_ENTER("NdbGlobalEventBuffer::real_dropSubscribeEvent"); // add_drop_lock(); // only one thread can do add-drop at a time BufItem &b = m_buf[ID(bufferId)]; @@ -1085,6 +1112,7 @@ NdbGlobalEventBuffer::real_dropSubscribeEvent(int bufferId) #ifdef EVENT_DEBUG ndbout_c("dropSubscribeEvent:: dropped bufferId %d", bufferId); #endif + DBUG_VOID_RETURN; } void @@ -1107,10 +1135,13 @@ NdbGlobalEventBuffer::real_insertDataL(int bufferId, const SubTableData * const sdata, LinearSectionPtr ptr[3]) { + DBUG_ENTER("NdbGlobalEventBuffer::real_insertDataL"); BufItem &b = m_buf[ID(bufferId)]; #ifdef EVENT_DEBUG int n = NO(bufferId); #endif + + if ( b.eventType & (1 << (Uint32)sdata->operation) ) { if (b.subs) { #ifdef EVENT_DEBUG @@ -1119,7 +1150,9 @@ NdbGlobalEventBuffer::real_insertDataL(int bufferId, // move front forward if (copy_data_alloc(sdata, ptr, b.data[b.f].sdata, b.data[b.f].ptr)) - return -1; + { + DBUG_RETURN(-1); + } for (int i=0; i < b.subs; i++) { NdbGlobalEventBuffer::BufItem::Ps &e = b.ps[i]; if (e.theHandle) { // active subscriber @@ -1127,7 +1160,7 @@ NdbGlobalEventBuffer::real_insertDataL(int bufferId, if (e.bufferempty == 0) { e.overrun++; // another item has been overwritten e.b++; // move next-to-read next since old item was overwritten - if (e.b == b.max_sz) e.b = 0; // start from beginning + if (e.b == b.max_sz) e.b= 0; // start from beginning } } e.bufferempty = 0; @@ -1147,21 +1180,35 @@ NdbGlobalEventBuffer::real_insertDataL(int bufferId, #endif } } - return 0; + else + { +#ifdef EVENT_DEBUG + ndbout_c("skipped"); +#endif + } + + DBUG_RETURN(0); } int NdbGlobalEventBuffer::hasData(int bufferId) { + DBUG_ENTER("NdbGlobalEventBuffer::hasData"); BufItem &b = m_buf[ID(bufferId)]; int n = NO(bufferId); NdbGlobalEventBuffer::BufItem::Ps &e = b.ps[n]; if(e.bufferempty) - return 0; + { + DBUG_RETURN(0); + } if (b.f <= e.b) - return b.max_sz-e.b + b.f; + { + DBUG_RETURN(b.max_sz-e.b + b.f); + } else - return b.f-e.b; + { + DBUG_RETURN(b.f-e.b); + } } int NdbGlobalEventBuffer::real_getDataL(const int bufferId, @@ -1169,6 +1216,7 @@ int NdbGlobalEventBuffer::real_getDataL(const int bufferId, LinearSectionPtr ptr[3], int *pOverrun) { + DBUG_ENTER("NdbGlobalEventBuffer::real_getDataL"); BufItem &b = m_buf[ID(bufferId)]; int n = NO(bufferId); NdbGlobalEventBuffer::BufItem::Ps &e = b.ps[n]; @@ -1179,13 +1227,17 @@ int NdbGlobalEventBuffer::real_getDataL(const int bufferId, } if (e.bufferempty) - return 0; // nothing to get + { + DBUG_RETURN(0); // nothing to get + } if (copy_data_alloc(b.data[e.b].sdata, b.data[e.b].ptr, sdata, ptr)) - return -1; + { + DBUG_RETURN(-1); + } - e.b++; if (e.b == b.max_sz) e.b = 0; // move next-to-read forward + e.b++; if (e.b == b.max_sz) e.b= 0; // move next-to-read forward if (b.f == e.b) // back has cought up with front e.bufferempty = 1; @@ -1194,7 +1246,7 @@ int NdbGlobalEventBuffer::real_getDataL(const int bufferId, ndbout_c("getting data from buffer %d with eventId %d", bufferId, b.gId); #endif - return hasData(bufferId)+1; + DBUG_RETURN(hasData(bufferId)+1); } int NdbGlobalEventBuffer::copy_data_alloc(const SubTableData * const f_sdata, @@ -1202,6 +1254,7 @@ NdbGlobalEventBuffer::copy_data_alloc(const SubTableData * const f_sdata, SubTableData * &t_sdata, LinearSectionPtr t_ptr[3]) { + DBUG_ENTER("NdbGlobalEventBuffer::copy_data_alloc"); if (t_sdata == NULL) { t_sdata = (SubTableData *)NdbMem_Allocate(sizeof(SubTableData)); } @@ -1223,28 +1276,34 @@ NdbGlobalEventBuffer::copy_data_alloc(const SubTableData * const f_sdata, } t_p.sz = f_p.sz; } - return 0; + DBUG_RETURN(0); } int NdbGlobalEventBuffer::real_wait(NdbGlobalEventBufferHandle *h, int aMillisecondNumber) { + DBUG_ENTER("NdbGlobalEventBuffer::real_wait"); // check if there are anything in any of the buffers int i; int n = 0; for (i = 0; i < h->m_nids; i++) n += hasData(h->m_bufferIds[i]); - if (n) return n; + if (n) + { + DBUG_RETURN(n); + } int r = NdbCondition_WaitTimeout(h->p_cond, ndb_global_event_buffer_mutex, aMillisecondNumber); if (r > 0) - return -1; + { + DBUG_RETURN(-1); + } n = 0; for (i = 0; i < h->m_nids; i++) n += hasData(h->m_bufferIds[i]); - return n; + DBUG_RETURN(n); } template class Vector<NdbGlobalEventBufferHandle*>; diff --git a/ndb/src/ndbapi/NdbEventOperationImpl.hpp b/ndb/src/ndbapi/NdbEventOperationImpl.hpp index fae9dda45e4..3fcbfd8fe7c 100644 --- a/ndb/src/ndbapi/NdbEventOperationImpl.hpp +++ b/ndb/src/ndbapi/NdbEventOperationImpl.hpp @@ -79,7 +79,7 @@ public: //static NdbGlobalEventBufferHandle *init(int MAX_NUMBER_ACTIVE_EVENTS); // returns bufferId 0-N if ok otherwise -1 - int prepareAddSubscribeEvent(Uint32 eventId, int& hasSubscriber); + int prepareAddSubscribeEvent(NdbEventOperationImpl *, int& hasSubscriber); void unprepareAddSubscribeEvent(int bufferId); void addSubscribeEvent(int bufferId, NdbEventOperationImpl *ndbEventOperationImpl); @@ -133,7 +133,8 @@ private: int MAX_NUMBER_ACTIVE_EVENTS); int real_prepareAddSubscribeEvent(NdbGlobalEventBufferHandle *h, - Uint32 eventId, int& hasSubscriber); + NdbEventOperationImpl *, + int& hasSubscriber); void real_unprepareAddSubscribeEvent(int bufferId); void real_addSubscribeEvent(int bufferId, void *ndbEventOperation); @@ -177,6 +178,7 @@ private: // local mutex for each event/buffer NdbMutex *p_buf_mutex; Uint32 gId; + Uint32 eventType; struct Data { SubTableData *sdata; LinearSectionPtr ptr[3]; diff --git a/ndb/src/ndbapi/NdbOperation.cpp b/ndb/src/ndbapi/NdbOperation.cpp index 58147f2654e..c9143444908 100644 --- a/ndb/src/ndbapi/NdbOperation.cpp +++ b/ndb/src/ndbapi/NdbOperation.cpp @@ -392,3 +392,9 @@ NdbOperation::getTableName() const { return m_currentTable->m_externalName.c_str(); } + +const NdbDictionary::Table* +NdbOperation::getTable() const +{ + return m_currentTable; +} diff --git a/ndb/src/ndbapi/NdbOperationSearch.cpp b/ndb/src/ndbapi/NdbOperationSearch.cpp index 6e76287eef0..06d8ddd412b 100644 --- a/ndb/src/ndbapi/NdbOperationSearch.cpp +++ b/ndb/src/ndbapi/NdbOperationSearch.cpp @@ -229,9 +229,6 @@ NdbOperation::equal_impl(const NdbColumnImpl* tAttrInfo, theNoOfTupKeyLeft = tNoKeysDef; tErrorLine++; theErrorLine = tErrorLine; - - if(tDistrKey) - handle_distribution_key((Uint64*)aValue, totalSizeInWords); if (tNoKeysDef == 0) { if (tOpType == UpdateRequest) { diff --git a/ndb/src/ndbapi/ndb_cluster_connection.cpp b/ndb/src/ndbapi/ndb_cluster_connection.cpp index 7e60c366f67..c77f8c62f98 100644 --- a/ndb/src/ndbapi/ndb_cluster_connection.cpp +++ b/ndb/src/ndbapi/ndb_cluster_connection.cpp @@ -183,6 +183,12 @@ Ndb_cluster_connection::no_db_nodes() return m_impl.m_all_nodes.size(); } +unsigned +Ndb_cluster_connection::node_id() +{ + return m_impl.m_transporter_facade->ownId(); +} + int Ndb_cluster_connection::wait_until_ready(int timeout, diff --git a/ndb/test/include/HugoCalculator.hpp b/ndb/test/include/HugoCalculator.hpp index 108af0d1358..03de46cd7ea 100644 --- a/ndb/test/include/HugoCalculator.hpp +++ b/ndb/test/include/HugoCalculator.hpp @@ -31,13 +31,6 @@ class HugoCalculator { public: HugoCalculator(const NdbDictionary::Table& tab); Int32 calcValue(int record, int attrib, int updates) const; -#if 0 - U_Int32 calcValue(int record, int attrib, int updates) const; - U_Int64 calcValue(int record, int attrib, int updates) const; - Int64 calcValue(int record, int attrib, int updates) const; - float calcValue(int record, int attrib, int updates) const; - double calcValue(int record, int attrib, int updates) const; -#endif const char* calcValue(int record, int attrib, int updates, char* buf, int len) const; int verifyRowValues(NDBT_ResultRow* const pRow) const; diff --git a/ndb/test/include/HugoOperations.hpp b/ndb/test/include/HugoOperations.hpp index d7f336a117d..38e53d765ec 100644 --- a/ndb/test/include/HugoOperations.hpp +++ b/ndb/test/include/HugoOperations.hpp @@ -29,8 +29,9 @@ public: ~HugoOperations(); int startTransaction(Ndb*); + int setTransaction(NdbTransaction*); int closeTransaction(Ndb*); - NdbConnection* getTransaction(); + NdbTransaction* getTransaction(); void refresh(); int pkInsertRecord(Ndb*, @@ -68,10 +69,13 @@ public: int attrId, int rowId, int updateId); + int equalForAttr(NdbOperation*, int attrId, int rowId); - + + int setValues(NdbOperation*, int rowId, int updateId); + int verifyUpdatesValue(int updatesValue, int _numRows = 0); int indexReadRecords(Ndb*, const char * idxName, int recordNo, diff --git a/ndb/test/include/NDBT_Test.hpp b/ndb/test/include/NDBT_Test.hpp index 53f75db723f..f9fbb6b186d 100644 --- a/ndb/test/include/NDBT_Test.hpp +++ b/ndb/test/include/NDBT_Test.hpp @@ -429,7 +429,7 @@ C##suitname():NDBT_TestSuite(#suitname){ \ pt->addTable(tableName, false); #define NDBT_TESTSUITE_END(suitname) \ - } } ; C##suitname suitname; + } } ; C##suitname suitname // Helper functions for retrieving variables from NDBT_Step #define GETNDB(ps) ((NDBT_NdbApiStep*)ps)->getNdb() diff --git a/ndb/test/ndbapi/bank/BankLoad.cpp b/ndb/test/ndbapi/bank/BankLoad.cpp index 0df9b43ae07..34947019a51 100644 --- a/ndb/test/ndbapi/bank/BankLoad.cpp +++ b/ndb/test/ndbapi/bank/BankLoad.cpp @@ -321,7 +321,7 @@ int Bank::loadGl(){ m_ndb.closeTransaction(pTrans); return NDBT_OK; -}; +} int Bank::getBalanceForAccountType(const Uint32 accountType, @@ -459,7 +459,7 @@ int Bank::loadAccountType(){ m_ndb.closeTransaction(pTrans); return NDBT_OK; -}; +} /** * Load ACCOUNT table diff --git a/ndb/test/ndbapi/testOIBasic.cpp b/ndb/test/ndbapi/testOIBasic.cpp index 0f31a30f1a7..33482bd9b11 100644 --- a/ndb/test/ndbapi/testOIBasic.cpp +++ b/ndb/test/ndbapi/testOIBasic.cpp @@ -3127,7 +3127,7 @@ pkinsert(Par par) } con.closeTransaction(); return 0; -}; +} static int pkupdate(Par par) @@ -3183,7 +3183,7 @@ pkupdate(Par par) } con.closeTransaction(); return 0; -}; +} static int pkdelete(Par par) @@ -3235,7 +3235,7 @@ pkdelete(Par par) } con.closeTransaction(); return 0; -}; +} static int pkread(Par par) @@ -3349,7 +3349,7 @@ hashindexupdate(Par par, const ITab& itab) } con.closeTransaction(); return 0; -}; +} static int hashindexdelete(Par par, const ITab& itab) @@ -3400,7 +3400,7 @@ hashindexdelete(Par par, const ITab& itab) } con.closeTransaction(); return 0; -}; +} static int hashindexread(Par par, const ITab& itab) diff --git a/ndb/test/ndbapi/testPartitioning.cpp b/ndb/test/ndbapi/testPartitioning.cpp index f9d2925a602..9d67c27354b 100644 --- a/ndb/test/ndbapi/testPartitioning.cpp +++ b/ndb/test/ndbapi/testPartitioning.cpp @@ -22,17 +22,6 @@ #define GETNDB(ps) ((NDBT_NdbApiStep*)ps)->getNdb() -static -int runLoadTable(NDBT_Context* ctx, NDBT_Step* step) -{ - int records = ctx->getNumRecords(); - HugoTransactions hugoTrans(*ctx->getTab()); - if (hugoTrans.loadTable(GETNDB(step), records) != 0){ - return NDBT_FAILED; - } - return NDBT_OK; -} - static Uint32 max_dks = 0; static @@ -238,11 +227,27 @@ run_tests(Ndb* p_ndb, HugoTransactions& hugoTrans, int records) return NDBT_FAILED; } - if(hugoTrans.scanReadRecords(p_ndb, records) != 0) - { - return NDBT_FAILED; + Uint32 abort = 23; + for(Uint32 j = 0; j<5; j++){ + Uint32 parallelism = (j == 1 ? 1 : j * 3); + ndbout_c("parallelism: %d", parallelism); + if (hugoTrans.scanReadRecords(p_ndb, records, abort, parallelism, + NdbOperation::LM_Read) != 0) + { + return NDBT_FAILED; + } + if (hugoTrans.scanReadRecords(p_ndb, records, abort, parallelism, + NdbOperation::LM_Exclusive) != 0) + { + return NDBT_FAILED; + } + if (hugoTrans.scanReadRecords(p_ndb, records, abort, parallelism, + NdbOperation::LM_CommittedRead) != 0) + { + return NDBT_FAILED; + } } - + if(hugoTrans.clearTable(p_ndb, records) != 0) { return NDBT_FAILED; @@ -297,6 +302,69 @@ run_index_dk(NDBT_Context* ctx, NDBT_Step* step) return run_tests(p_ndb, hugoTrans, records); } +static int +run_startHint(NDBT_Context* ctx, NDBT_Step* step) +{ + Ndb* p_ndb = GETNDB(step); + int records = ctx->getNumRecords(); + const NdbDictionary::Table *tab = + p_ndb->getDictionary()->getTable(ctx->getTab()->getName()); + + if(!tab) + return NDBT_OK; + + HugoTransactions hugoTrans(*tab); + if (hugoTrans.loadTable(p_ndb, records) != 0) + { + return NDBT_FAILED; + } + + NdbRestarter restarter; + if(restarter.insertErrorInAllNodes(8050) != 0) + return NDBT_FAILED; + + HugoCalculator dummy(*tab); + int result = NDBT_OK; + for(int i = 0; i<records && result == NDBT_OK; i++) + { + char buffer[8000]; + char* start= buffer + (rand() & 7); + char* pos= start; + + for(int j = 0; j<tab->getNoOfColumns(); j++) + { + if(tab->getColumn(j)->getPartitionKey()) + { + ndbout_c(tab->getColumn(j)->getName()); + int sz = tab->getColumn(j)->getSizeInBytes(); + int aligned_size = 4 * ((sz + 3) >> 2); + memset(pos, 0, aligned_size); + dummy.calcValue(i, j, 0, pos, sz); + pos += aligned_size; + } + } + // Now we have the pk + NdbTransaction* pTrans= p_ndb->startTransaction(tab, start,(pos - start)); + HugoOperations ops(*tab); + ops.setTransaction(pTrans); + if(ops.pkReadRecord(p_ndb, i, 1) != NDBT_OK) + { + result = NDBT_FAILED; + break; + } + + if(ops.execute_Commit(p_ndb) != 0) + { + result = NDBT_FAILED; + break; + } + + ops.closeTransaction(p_ndb); + } + restarter.insertErrorInAllNodes(0); + return result; +} + NDBT_TESTSUITE(testPartitioning); TESTCASE("pk_dk", @@ -332,6 +400,24 @@ TESTCASE("ordered_index_dk", INITIALIZER(run_create_pk_index_drop); INITIALIZER(run_drop_table); } +TESTCASE("startTransactionHint", + "Test startTransactionHint wo/ distribution key") +{ + TC_PROPERTY("distributionkey", (unsigned)0); + INITIALIZER(run_drop_table); + INITIALIZER(run_create_table); + INITIALIZER(run_startHint); + INITIALIZER(run_drop_table); +} +TESTCASE("startTransactionHint_dk", + "Test startTransactionHint with distribution key") +{ + TC_PROPERTY("distributionkey", (unsigned)~0); + INITIALIZER(run_drop_table); + INITIALIZER(run_create_table); + INITIALIZER(run_startHint); + INITIALIZER(run_drop_table); +} NDBT_TESTSUITE_END(testPartitioning); int main(int argc, const char** argv){ diff --git a/ndb/test/ndbapi/testScan.cpp b/ndb/test/ndbapi/testScan.cpp index 64c993a27ba..1f40a52b334 100644 --- a/ndb/test/ndbapi/testScan.cpp +++ b/ndb/test/ndbapi/testScan.cpp @@ -1065,6 +1065,44 @@ int runScanRestart(NDBT_Context* ctx, NDBT_Step* step){ } +int +runScanParallelism(NDBT_Context* ctx, NDBT_Step* step){ + int loops = ctx->getNumLoops() + 3; + int records = ctx->getNumRecords(); + int abort = ctx->getProperty("AbortProb", 15); + + Uint32 fib[] = { 1, 2 }; + Uint32 parallelism = 0; // start with 0 + int i = 0; + HugoTransactions hugoTrans(*ctx->getTab()); + while (i<loops && !ctx->isTestStopped()) { + g_info << i << ": "; + + if (hugoTrans.scanReadRecords(GETNDB(step), records, abort, parallelism, + NdbOperation::LM_Read) != 0){ + return NDBT_FAILED; + } + if (hugoTrans.scanReadRecords(GETNDB(step), records, abort, parallelism, + NdbOperation::LM_Exclusive) != 0){ + return NDBT_FAILED; + } + if (hugoTrans.scanReadRecords(GETNDB(step), records, abort, parallelism, + NdbOperation::LM_CommittedRead) != 0){ + return NDBT_FAILED; + } + if (hugoTrans.scanUpdateRecords(GETNDB(step), records, abort, parallelism) + != 0){ + return NDBT_FAILED; + } + i++; + parallelism = fib[0]; + Uint32 next = fib[0] + fib[1]; + fib[0] = fib[1]; + fib[1] = next; + } + return NDBT_OK; +} + NDBT_TESTSUITE(testScan); TESTCASE("ScanRead", "Verify scan requirement: It should be possible "\ @@ -1515,6 +1553,12 @@ TESTCASE("ScanRestart", STEP(runScanRestart); FINALIZER(runClearTable); } +TESTCASE("ScanParallelism", + "Test scan with different parallelism"){ + INITIALIZER(runLoadTable); + STEP(runScanParallelism); + FINALIZER(runClearTable); +} NDBT_TESTSUITE_END(testScan); int main(int argc, const char** argv){ diff --git a/ndb/test/run-test/16node-tests.txt b/ndb/test/run-test/16node-tests.txt new file mode 100644 index 00000000000..920448bbfd6 --- /dev/null +++ b/ndb/test/run-test/16node-tests.txt @@ -0,0 +1,733 @@ +# BASIC FUNCTIONALITY +max-time: 500 +cmd: testBasic +args: -n PkRead + +max-time: 500 +cmd: testBasic +args: -n PkUpdate + +max-time: 500 +cmd: testBasic +args: -n PkDelete + +max-time: 500 +cmd: testBasic +args: -n PkInsert + +max-time: 600 +cmd: testBasic +args: -n UpdateAndRead + +max-time: 500 +cmd: testBasic +args: -n PkReadAndLocker T6 + +max-time: 500 +cmd: testBasic +args: -n PkReadAndLocker2 T6 + +max-time: 500 +cmd: testBasic +args: -n PkReadUpdateAndLocker T6 + +max-time: 500 +cmd: testBasic +args: -n ReadWithLocksAndInserts T6 + +max-time: 500 +cmd: testBasic +args: -n PkInsertTwice T1 T6 T10 + +max-time: 1500 +cmd: testBasic +args: -n Fill T13 + +max-time: 1500 +cmd: testBasic +args: -n Fill T6 + +max-time: 500 +cmd: testBasic +args: -n NoCommitSleep T6 + +max-time: 500 +cmd: testBasic +args: -n NoCommit626 T6 + +max-time: 500 +cmd: testBasic +args: -n NoCommitAndClose T6 + +max-time: 500 +cmd: testBasic +args: -n Commit626 T6 + +max-time: 500 +cmd: testBasic +args: -n CommitTry626 T6 + +max-time: 500 +cmd: testBasic +args: -n CommitAsMuch626 T6 + +max-time: 500 +cmd: testBasic +args: -n NoCommit626 T6 + +max-time: 500 +cmd: testBasic +args: -n NoCommitRollback626 T1 T6 + +max-time: 500 +cmd: testBasic +args: -n Commit630 T1 T6 + +max-time: 500 +cmd: testBasic +args: -n CommitTry630 T1 T6 + +max-time: 500 +cmd: testBasic +args: -n CommitAsMuch630 T1 T6 + +max-time: 500 +cmd: testBasic +args: -n NoCommit630 T1 T6 + +max-time: 500 +cmd: testBasic +args: -n NoCommitRollback630 T1 T6 + +max-time: 500 +cmd: testBasic +args: -n NoCommitAndClose T1 T6 + +max-time: 500 +cmd: testBasic +args: -n RollbackUpdate T1 T6 + +max-time: 500 +cmd: testBasic +args: -n RollbackDeleteMultiple T1 T6 + +max-time: 500 +cmd: testBasic +args: -n ImplicitRollbackDelete T1 T6 + +max-time: 500 +cmd: testBasic +args: -n CommitDelete T1 T6 + +max-time: 500 +cmd: testBasic +args: -n RollbackNothing T1 T6 + +max-time: 500 +cmd: testBasicAsynch +args: -n PkInsertAsynch + +max-time: 500 +cmd: testBasicAsynch +args: -n PkReadAsynch + +max-time: 500 +cmd: testBasicAsynch +args: -n PkUpdateAsynch + +max-time: 500 +cmd: testBasicAsynch +args: -n PkDeleteAsynch + +max-time: 500 +cmd: testBasic +args: -n MassiveRollback T1 T6 T13 + +max-time: 500 +cmd: testBasic +args: -n MassiveRollback2 T1 T6 T13 + +max-time: 500 +cmd: testTimeout +args: T1 + +# SCAN TESTS +# +max-time: 500 +cmd: testScan +args: -n ScanRead16 + +max-time: 500 +cmd: testScan +args: -n ScanRead240 + +max-time: 500 +cmd: testScan +args: -n ScanReadCommitted240 + +max-time: 500 +cmd: testScan +args: -n ScanUpdate + +max-time: 500 +cmd: testScan +args: -n ScanUpdate2 T6 + +max-time: 500 +cmd: testScan +args: -n ScanDelete + +max-time: 500 +cmd: testScan +args: -n ScanDelete2 T10 + +max-time: 500 +cmd: testScan +args: -n ScanUpdateAndScanRead T6 + +max-time: 500 +cmd: testScan +args: -n ScanReadAndLocker T6 + +max-time: 500 +cmd: testScan +args: -n ScanReadAndPkRead T6 + +max-time: 500 +cmd: testScan +args: -n ScanRead488 -l 10 T6 + +max-time: 500 +cmd: testScan +args: -n ScanRead488O -l 10 T6 + +max-time: 1000 +cmd: testScan +args: -n ScanRead488_Mixed -l 10 T6 + +max-time: 500 +cmd: testScan +args: -n ScanRead488Timeout -l 10 T6 + +max-time: 600 +cmd: testScan +args: -n ScanRead40 -l 100 T2 + +max-time: 1800 +cmd: testScan +args: -n ScanRead100 -l 100 T1 + +max-time: 600 +cmd: testScan +args: -n ScanRead40 -l 100 T1 + +max-time: 1800 +cmd: testScan +args: -n ScanRead40RandomTable -l 100 T1 + +max-time: 500 +cmd: testScan +args: -n ScanWithLocksAndInserts T6 + +max-time: 500 +cmd: testScan +args: -n ScanReadAbort T6 + +max-time: 500 +cmd: testScan +args: -n ScanReadAbort15 T6 + +max-time: 500 +cmd: testScan +args: -n ScanReadAbort240 T6 + +max-time: 500 +cmd: testScan +args: -n ScanUpdateAbort16 T6 + +max-time: 3600 +cmd: testScan +args: -n ScanReadRestart T1 T6 T13 + +max-time: 500 +cmd: testScan +args: -n ScanUpdateRestart T6 + +max-time: 500 +cmd: testScan +args: -n CheckGetValue T6 + +max-time: 500 +cmd: testScan +args: -n CloseWithoutStop T6 + +max-time: 500 +cmd: testScan +args: -n NextScanWhenNoMore T6 + +max-time: 500 +cmd: testScan +args: -n ExecuteScanWithoutOpenScan T6 + +max-time: 500 +cmd: testScan +args: -n OnlyOpenScanOnce T6 + +max-time: 500 +cmd: testScan +args: -n OnlyOneOpInScanTrans T6 + +max-time: 500 +cmd: testScan +args: -n OnlyOneOpBeforeOpenScan T6 + +max-time: 500 +cmd: testScan +args: -n OnlyOneScanPerTrans T6 + +max-time: 500 +cmd: testScan +args: -n NoCloseTransaction T6 + +max-time: 500 +cmd: testScan +args: -n CheckInactivityTimeOut T6 + +max-time: 500 +cmd: testScan +args: -n CheckInactivityBeforeClose T6 + +max-time: 500 +cmd: testScan +args: -n CheckAfterTerror T6 + +max-time: 500 +cmd: testScan +args: -n ScanReadError5021 T1 + +max-time: 500 +cmd: testScan +args: -n ScanReaderror5022 T1 + +max-time: 500 +cmd: testScan +args: -n ScanReadError5023 T1 + +max-time: 500 +cmd: testScan +args: -n ScanReadError5024 T1 + +max-time: 500 +cmd: testScan +args: -n ScanReadError5025 T1 + +max-time: 500 +cmd: testScan +args: -n ScanReadError5030 T1 + +max-time: 500 +cmd: testScan +args: -n InsertDelete T1 T6 + +max-time: 500 +cmd: testScan +args: -n CheckAfterTerror T1 + +max-time: 500 +cmd: testScan +args: -n ScanReadWhileNodeIsDown T1 + +max-time: 500 +cmd: testScan +args: -n ScanRestart T1 + +max-time: 500 +cmd: testScan +args: -n ScanParallelism + +# +# DICT TESTS +max-time: 1500 +cmd: testDict +args: -n CreateAndDrop + +max-time: 1500 +cmd: testDict +args: -n CreateAndDropWithData + +max-time: 1500 +cmd: testDict +args: -n CreateAndDropDuring T6 T10 + +max-time: 1500 +cmd: testDict +args: -n CreateInvalidTables + +max-time: 1500 +cmd: testDict +args: -n CreateTableWhenDbIsFull T6 + +max-time: 1500 +cmd: testDict +args: -n CreateMaxTables T6 + +max-time: 500 +cmd: testDict +args: -n FragmentTypeSingle T1 + +max-time: 1500 +cmd: testDict +args: -n FragmentTypeAll T1 T6 T7 T8 + +max-time: 1500 +cmd: testDict +args: -n FragmentTypeAllLarge T1 T6 T7 T8 + +max-time: 1500 +cmd: testDict +args: -n TemporaryTables T1 T6 T7 T8 + +# +# TEST NDBAPI +# +max-time: 500 +cmd: testDataBuffers +args: + +# Testsuite: testNdbApi +# Number of tests: 5 +max-time: 500 +cmd: testNdbApi +args: -n MaxNdb T6 + +max-time: 500 +cmd: testNdbApi +args: -n MaxTransactions T1 T6 T7 T8 T13 + +max-time: 500 +cmd: testNdbApi +args: -n MaxOperations T1 T6 T7 T8 T13 + +max-time: 500 +cmd: testNdbApi +args: -n MaxGetValue T1 T6 T7 T8 T13 + +max-time: 500 +cmd: testNdbApi +args: -n MaxEqual + +max-time: 500 +cmd: testNdbApi +args: -n DeleteNdb T1 T6 + +max-time: 500 +cmd: testNdbApi +args: -n WaitUntilReady T1 T6 T7 T8 T13 + +max-time: 500 +cmd: testNdbApi +args: -n GetOperationNoTab T6 + +max-time: 500 +cmd: testNdbApi +args: -n NdbErrorOperation T6 + +max-time: 500 +cmd: testNdbApi +args: -n MissingOperation T6 + +max-time: 500 +cmd: testNdbApi +args: -n GetValueInUpdate T6 + +max-time: 500 +cmd: testNdbApi +args: -n UpdateWithoutKeys T6 + +max-time: 500 +cmd: testNdbApi +args: -n UpdateWithoutValues T6 + +#max-time: 500 +#cmd: testInterpreter +#args: T1 +# +max-time: 150000 +cmd: testOperations +args: + +max-time: 15000 +cmd: testTransactions +args: + +max-time: 1500 +cmd: testRestartGci +args: T6 + +max-time: 600 +cmd: testBlobs +args: + +max-time: 5000 +cmd: testOIBasic +args: + +max-time: 2500 +cmd: testBitfield +args: + +max-time: 2500 +cmd: testPartitioning +args: + +max-time: 25000 +cmd: atrt-mysql-test-run +args: --force + +# +# INDEX +# +max-time: 1500 +cmd: testIndex +args: -n CreateAll T1 T6 T13 + +#-m 7200 1: testIndex -n InsertDeleteGentle T7 +max-time: 3600 +cmd: testIndex +args: -n InsertDelete T1 T10 + +#-m 3600 1: testIndex -n CreateLoadDropGentle T7 +max-time: 3600 +cmd: testIndex +args: -n CreateLoadDrop T1 T10 + +# +# BACKUP +# +max-time: 600 +cmd: atrt-testBackup +args: -n BackupOne T1 T6 T3 I3 + +# +# +# SYSTEM RESTARTS +# +max-time: 1500 +cmd: testSystemRestart +args: -n SR3 T6 + +max-time: 1500 +cmd: testSystemRestart +args: -n SR4 T6 + +# +# NODE RESTARTS +# +max-time: 2500 +cmd: testNodeRestart +args: -n NoLoad T6 + +max-time: 2500 +cmd: testNodeRestart +args: -n MixedPkRead T6 T8 T13 + +max-time: 2500 +cmd: testNodeRestart +args: -l 1 -n MixedPkReadPkUpdate + +max-time: 2500 +cmd: testNodeRestart +args: -l 1 -n MixedReadUpdateScan + +max-time: 2500 +cmd: testNodeRestart +args: -n CommittedRead T1 + +max-time: 2500 +cmd: testNodeRestart +args: -n FullDb T6 T13 + +max-time: 2500 +cmd: testNodeRestart +args: -n RestartRandomNode T6 T13 + +max-time: 2500 +cmd: testNodeRestart +args: -n RestartRandomNodeError T6 T13 + +max-time: 2500 +cmd: testNodeRestart +args: -n RestartRandomNodeInitial T6 T13 + +max-time: 3600 +cmd: testNodeRestart +args: -l 1 -n RestartNFDuringNR T6 T13 + +max-time: 2500 +cmd: testNodeRestart +args: -n RestartMasterNodeError T6 T8 T13 + +max-time: 3600 +cmd: testNodeRestart +args: -n RestartNodeDuringLCP T6 + +max-time: 2500 +cmd: testNodeRestart +args: -n TwoNodeFailure T6 T8 T13 + +max-time: 2500 +cmd: testNodeRestart +args: -n TwoMasterNodeFailure T6 T8 T13 + +max-time: 2500 +cmd: testNodeRestart +args: -n FiftyPercentFail T6 T8 T13 + +max-time: 2500 +cmd: testNodeRestart +args: -n RestartAllNodes T6 T8 T13 + +max-time: 2500 +cmd: testNodeRestart +args: -n RestartAllNodesAbort T6 T8 T13 + +max-time: 2500 +cmd: testNodeRestart +args: -n RestartAllNodesError9999 T6 T8 T13 + +max-time: 2500 +cmd: testNodeRestart +args: -n FiftyPercentStopAndWait T6 T8 T13 + +#max-time: 500 +#cmd: testNodeRestart +#args: -n StopOnError T1 +# +# +max-time: 2500 +cmd: testIndex +args: -n NFNR1 T6 T13 + +max-time: 2500 +cmd: testIndex +args: -n NFNR2 T6 T13 + +max-time: 2500 +cmd: testIndex +args: -n NFNR3 T6 T13 + +max-time: 2500 +cmd: testIndex +args: -n BuildDuring T6 + +max-time: 2500 +cmd: testIndex +args: -l 2 -n SR1 T6 T13 + +max-time: 2500 +cmd: testIndex +args: -n NFNR1_O T6 T13 + +max-time: 2500 +cmd: testIndex +args: -n NFNR2_O T6 T13 + +max-time: 2500 +cmd: testIndex +args: -n NFNR3_O T6 T13 + +max-time: 2500 +cmd: testIndex +args: -n BuildDuring_O T6 + +max-time: 2500 +cmd: testIndex +args: -l 2 -n SR1_O T6 T13 + +max-time: 500 +cmd: testIndex +args: -n MixedTransaction T1 + +max-time: 2500 +cmd: testDict +args: -n NF1 T1 T6 T13 + +# +max-time: 1500 +cmd: testSystemRestart +args: -l 1 -n SR6 T1 + +max-time: 1500 +cmd: testSystemRestart +args: -l 1 -n SR7 T1 + +max-time: 1500 +cmd: testSystemRestart +args: -l 1 -n SR8 T1 + +max-time: 1500 +cmd: testSystemRestart +args: -l 1 -n SR9 T1 + +# +max-time: 2500 +cmd: test_event +args: -n BasicEventOperation T1 T6 + +# +# +# SYSTEM RESTARTS +# +max-time: 1500 +cmd: testSystemRestart +args: -n SR1 T1 + +max-time: 1500 +cmd: testSystemRestart +args: -n SR1 T6 + +max-time: 1500 +cmd: testSystemRestart +args: -n SR1 T7 + +max-time: 1500 +cmd: testSystemRestart +args: -n SR1 T8 + +max-time: 1500 +cmd: testSystemRestart +args: -n SR2 T1 + +max-time: 1500 +cmd: testSystemRestart +args: -n SR2 T6 + +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 + +# OLD FLEX +max-time: 500 +cmd: flexBench +args: -c 25 -t 10 + +max-time: 500 +cmd: flexHammer +args: -r 5 -t 32 + diff --git a/ndb/test/run-test/atrt-mysql-test-run b/ndb/test/run-test/atrt-mysql-test-run index dd7b709bd06..c30a4defc7f 100755 --- a/ndb/test/run-test/atrt-mysql-test-run +++ b/ndb/test/run-test/atrt-mysql-test-run @@ -5,8 +5,8 @@ p=`pwd` cd $MYSQL_BASE_DIR/mysql-test ./mysql-test-run --with-ndbcluster --ndb-connectstring=$NDB_CONNECTSTRING $* | tee $p/output.txt -f=`grep -c fail $p/output.txt` -o=`grep -c pass $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 diff --git a/ndb/test/run-test/daily-basic-tests.txt b/ndb/test/run-test/daily-basic-tests.txt index 559ea037c1f..ae195cc0c0c 100644 --- a/ndb/test/run-test/daily-basic-tests.txt +++ b/ndb/test/run-test/daily-basic-tests.txt @@ -345,6 +345,10 @@ max-time: 500 cmd: testScan args: -n ScanRestart T1 +max-time: 500 +cmd: testScan +args: -n ScanParallelism + # # DICT TESTS max-time: 1500 diff --git a/ndb/test/src/CpcClient.cpp b/ndb/test/src/CpcClient.cpp index 2ef23528360..1d1b4fcb977 100644 --- a/ndb/test/src/CpcClient.cpp +++ b/ndb/test/src/CpcClient.cpp @@ -30,7 +30,7 @@ 0, 0, \ 0, \ (desc), \ - (void *)(value) } + (value) } #define CPC_ARG(name, type, opt, desc) \ { (name), \ @@ -351,17 +351,12 @@ SimpleCpcClient::define_process(Process & p, Properties& reply){ int SimpleCpcClient::list_processes(Vector<Process> &procs, Properties& reply) { - enum Proclist { - Proclist_Start, - Proclist_End, - Proclist_Entry - }; + int start, end, entry; const ParserRow_t list_reply[] = { - CPC_CMD("start processes", Proclist_Start, ""), - - CPC_CMD("end processes", Proclist_End, ""), + CPC_CMD("start processes", &start, ""), + CPC_CMD("end processes", &end, ""), - CPC_CMD("process", Proclist_Entry, ""), + CPC_CMD("process", &entry, ""), CPC_ARG("id", Int, Mandatory, "Id of process."), CPC_ARG("name", String, Mandatory, "Name of process"), CPC_ARG("group", String, Mandatory, "Group of process"), @@ -390,26 +385,29 @@ SimpleCpcClient::list_processes(Vector<Process> &procs, Properties& reply) { bool done = false; while(!done) { const Properties *proc; - enum Proclist p; - cpc_recv(list_reply, &proc, (void **)&p); + void *p; + cpc_recv(list_reply, &proc, &p); - switch(p) { - case Proclist_Start: + if(p == &start) + { /* do nothing */ - break; - case Proclist_End: + } + else if(p == &end) + { done = true; - break; - case Proclist_Entry: + } + else if(p == &entry) + { if(proc != NULL){ Process p; convert(* proc, p); procs.push_back(p); } - break; - default: - /* ignore */ - break; + } + else + { + ndbout_c("internal error: %d", __LINE__); + return -1; } } return 0; diff --git a/ndb/test/src/HugoCalculator.cpp b/ndb/test/src/HugoCalculator.cpp index 20bcc445541..8493388efbd 100644 --- a/ndb/test/src/HugoCalculator.cpp +++ b/ndb/test/src/HugoCalculator.cpp @@ -16,6 +16,7 @@ #include "HugoCalculator.hpp" #include <NDBT.hpp> +#include <Base64.hpp> /* ************************************************************* * HugoCalculator @@ -52,29 +53,18 @@ HugoCalculator::HugoCalculator(const NdbDictionary::Table& tab) : m_tab(tab) { #endif // Check that idCol is not conflicting with updatesCol assert(m_idCol != m_updatesCol && m_idCol != -1 && m_updatesCol != -1); -}; +} Int32 HugoCalculator::calcValue(int record, int attrib, int updates) const { - const NdbDictionary::Column* attr = m_tab.getColumn(attrib); - // If this is the "id" column - if (attrib == m_idCol) - return record; - - // If this is the update column - if (attrib == m_updatesCol) - return updates; - - - Int32 val; - if (attr->getPrimaryKey()) - val = record + attrib; - else - val = record + attrib + updates; - return val; -}; + + Int32 i; + calcValue(record, attrib, updates, (char*)&i, sizeof(i)); + + return i; +} #if 0 HugoCalculator::U_Int32 calcValue(int record, int attrib, int updates) const; HugoCalculator::U_Int64 calcValue(int record, int attrib, int updates) const; @@ -82,62 +72,108 @@ HugoCalculator::Int64 calcValue(int record, int attrib, int updates) const; HugoCalculator::float calcValue(int record, int attrib, int updates) const; HugoCalculator::double calcValue(int record, int attrib, int updates) const; #endif + const char* HugoCalculator::calcValue(int record, int attrib, int updates, char* buf, int len) const { - const char a[26] = {"UAWBORCTDPEFQGNYHISJMKXLZ"}; + unsigned seed; const NdbDictionary::Column* attr = m_tab.getColumn(attrib); - int val = calcValue(record, attrib, updates); - - if (attr->getPrimaryKey()){ - // Create a string where val is printed as chars in the beginning - // of the string, then fill with other chars - // The string length is set to the same size as the attribute - BaseString::snprintf(buf, len, "%d", val); - for(int i=strlen(buf); i < len; i++) - buf[i] = a[((val^i)%25)]; - } else{ - - // Fill buf with some pattern so that we can detect - // anomalies in the area that we don't fill with chars - int i; - for (i = 0; i<len; i++) - buf[i] = ((i+2) % 255); + Uint32 val; + do + { + if (attrib == m_idCol) + { + *((Uint32*)buf)= record; + return buf; + } - // Calculate length of the string to create. We want the string - // length to be varied between max and min of this attribute. - Uint32 org = len; - - if(attr->getType() == NdbDictionary::Column::Varchar) - len = val % (len + 1); - else - if((val % (len + 1)) == 0) - len = 0; + // If this is the update column + if (attrib == m_updatesCol) + { + *((Uint32*)buf)= updates; + return buf; + } - // If len == 0 return NULL if this is a nullable attribute - if (len == 0){ - if(attr->getNullable() == true) - return NULL; - else - len++; + if (attr->getPrimaryKey()) + { + seed = record + attrib; } - for(i=0; i < len; i++) - buf[i] = a[((val^i)%25)]; - buf[len] = 0; - - if(attr->getType() == NdbDictionary::Column::Bit) + else { - Uint32 bits= attr->getLength(); - Uint32 pos = bits >> 5; - Uint32 size = bits & 31; - ((Uint32*)buf)[pos] &= ((1 << size) - 1); + seed = record + attrib + updates; } + } while (0); + val = rand_r(&seed); + + if(attr->getNullable() && (((val >> 16) & 255) > 220)) + return NULL; + + memcpy(buf, &val, (len > 4 ? 4 : len)); + int pos= 4; + while(pos + 4 < len) + { + val= rand_r(&seed); + memcpy(buf+pos, &val, 4); + pos++; + } + + if(pos < len) + { + val= rand_r(&seed); + memcpy(buf+pos, &val, (len - pos)); } + + switch(attr->getType()){ + 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::Bigint: + case NdbDictionary::Column::Bigunsigned: + case NdbDictionary::Column::Float: + case NdbDictionary::Column::Double: + case NdbDictionary::Column::Decimal: + case NdbDictionary::Column::Binary: + case NdbDictionary::Column::Datetime: + case NdbDictionary::Column::Time: + case NdbDictionary::Column::Date: + break; + case NdbDictionary::Column::Bit: + { + Uint32 bits= attr->getLength(); + Uint32 tmp = bits >> 5; + Uint32 size = bits & 31; + ((Uint32*)buf)[tmp] &= ((1 << size) - 1); + break; + } + case NdbDictionary::Column::Varbinary: + case NdbDictionary::Column::Varchar: + case NdbDictionary::Column::Text: + case NdbDictionary::Column::Char: + case NdbDictionary::Column::Longvarchar: + case NdbDictionary::Column::Longvarbinary: + { + BaseString tmp; + base64_encode(buf, len, tmp); + memcpy(buf, tmp.c_str(), len); + break; + } + case NdbDictionary::Column::Blob: + case NdbDictionary::Column::Undefined: + abort(); + break; + } + + return buf; -}; +} int HugoCalculator::verifyRowValues(NDBT_ResultRow* const pRow) const{ @@ -150,94 +186,40 @@ HugoCalculator::verifyRowValues(NDBT_ResultRow* const pRow) const{ // Check the values of each column for (int i = 0; i<m_tab.getNoOfColumns(); i++){ if (i != m_updatesCol && id != m_idCol) { - const NdbDictionary::Column* attr = m_tab.getColumn(i); - Uint32 len = attr->getLength(); - switch (attr->getType()){ - case NdbDictionary::Column::Bit: - len = 4 * ((len + 31) >> 5); - case NdbDictionary::Column::Char: - case NdbDictionary::Column::Varchar: - case NdbDictionary::Column::Binary: - case NdbDictionary::Column::Varbinary:{ - char* buf = new char[len+1]; - const char* res = calcValue(id, i, updates, buf, len); - if (res == NULL){ - if (!pRow->attributeStore(i)->isNULL()){ - g_err << "|- NULL ERROR: expected a NULL but the column was not null" << endl; - g_err << "|- The row: \"" << (*pRow) << "\"" << endl; - result = -1; - } - } else{ - if (memcmp(res, pRow->attributeStore(i)->aRef(), len) != 0){ - // if (memcmp(res, pRow->attributeStore(i)->aRef(), pRow->attributeStore(i)->getLength()) != 0){ - g_err << "Column: " << attr->getName() << endl; - const char* buf2 = pRow->attributeStore(i)->aRef(); - for (Uint32 j = 0; j < len; j++) + Uint32 len = attr->getSizeInBytes(); + char buf[8000]; + const char* res = calcValue(id, i, updates, buf, len); + if (res == NULL){ + if (!pRow->attributeStore(i)->isNULL()){ + g_err << "|- NULL ERROR: expected a NULL but the column was not null" << endl; + g_err << "|- The row: \"" << (*pRow) << "\"" << endl; + result = -1; + } + } else{ + if (memcmp(res, pRow->attributeStore(i)->aRef(), len) != 0){ + g_err << "Column: " << attr->getName() << endl; + const char* buf2 = pRow->attributeStore(i)->aRef(); + for (Uint32 j = 0; j < len; j++) + { + g_err << j << ":" << hex << (Uint32)(Uint8)buf[j] << "[" << hex << (Uint32)(Uint8)buf2[j] << "]"; + if (buf[j] != buf2[j]) { - g_err << j << ":" << hex << (int)buf[j] << "[" << hex << (int)buf2[j] << "]"; - if (buf[j] != buf2[j]) - { - g_err << "==>Match failed!"; - } - g_err << endl; + g_err << "==>Match failed!"; } g_err << endl; - g_err << "|- Invalid data found in attribute " << i << ": \"" - << pRow->attributeStore(i)->aRef() - << "\" != \"" << res << "\"" << endl - << "Length of expected=" << (unsigned)strlen(res) << endl - << "Lenght of read=" - << (unsigned)strlen(pRow->attributeStore(i)->aRef()) << endl; - g_err << "|- The row: \"" << (* pRow) << "\"" << endl; - result = -1; } - } - delete []buf; - } - break; - case NdbDictionary::Column::Int: - case NdbDictionary::Column::Unsigned:{ - Int32 cval = calcValue(id, i, updates); - Int32 val = pRow->attributeStore(i)->int32_value(); - if (val != cval){ - g_err << "|- Invalid data found: \"" << val << "\" != \"" - << cval << "\"" << endl; - g_err << "|- The row: \"" << (* pRow) << "\"" << endl; - result = -1; - } - break; - } - case NdbDictionary::Column::Bigint: - case NdbDictionary::Column::Bigunsigned:{ - Uint64 cval = calcValue(id, i, updates); - Uint64 val = pRow->attributeStore(i)->u_64_value(); - if (val != cval){ - g_err << "|- Invalid data found: \"" << val << "\" != \"" - << cval << "\"" - << endl; + g_err << endl; + g_err << "|- Invalid data found in attribute " << i << ": \"" + << pRow->attributeStore(i)->aRef() + << "\" != \"" << res << "\"" << endl + << "Length of expected=" << (unsigned)strlen(res) << endl + << "Lenght of read=" + << (unsigned)strlen(pRow->attributeStore(i)->aRef()) << endl; g_err << "|- The row: \"" << (* pRow) << "\"" << endl; result = -1; } } - break; - case NdbDictionary::Column::Float:{ - float cval = calcValue(id, i, updates); - float val = pRow->attributeStore(i)->float_value(); - if (val != cval){ - g_err << "|- Invalid data found: \"" << val << "\" != \"" - << cval << "\"" << endl; - g_err << "|- The row: \"" << (* pRow) << "\"" << endl; - result = -1; - } - } - break; - case NdbDictionary::Column::Undefined: - default: - assert(0); - result = -1; - break; - } } } return result; diff --git a/ndb/test/src/HugoOperations.cpp b/ndb/test/src/HugoOperations.cpp index f670591fe9c..bdb4013600a 100644 --- a/ndb/test/src/HugoOperations.cpp +++ b/ndb/test/src/HugoOperations.cpp @@ -32,6 +32,19 @@ int HugoOperations::startTransaction(Ndb* pNdb){ return NDBT_OK; } +int HugoOperations::setTransaction(NdbTransaction* new_trans){ + + if (pTrans != NULL){ + ndbout << "HugoOperations::startTransaction, pTrans != NULL" << endl; + return NDBT_FAILED; + } + pTrans = new_trans; + if (pTrans == NULL) { + return NDBT_FAILED; + } + return NDBT_OK; +} + int HugoOperations::closeTransaction(Ndb* pNdb){ if (pTrans != NULL){ @@ -145,26 +158,37 @@ int HugoOperations::pkUpdateRecord(Ndb* pNdb, return NDBT_FAILED; } - // Define primary keys - for(a = 0; a<tab.getNoOfColumns(); a++){ - if (tab.getColumn(a)->getPrimaryKey() == true){ - if(equalForAttr(pOp, a, r+recordNo) != 0){ - ERR(pTrans->getNdbError()); - return NDBT_FAILED; - } + if(setValues(pOp, r+recordNo, updatesValue) != NDBT_OK) + { + return NDBT_FAILED; + } + } + return NDBT_OK; +} + +int +HugoOperations::setValues(NdbOperation* pOp, int rowId, int updateId) +{ + // Define primary keys + int a; + for(a = 0; a<tab.getNoOfColumns(); a++){ + if (tab.getColumn(a)->getPrimaryKey() == true){ + if(equalForAttr(pOp, a, rowId) != 0){ + ERR(pTrans->getNdbError()); + return NDBT_FAILED; } } - - // Define attributes to update - for(a = 0; a<tab.getNoOfColumns(); a++){ - if (tab.getColumn(a)->getPrimaryKey() == false){ - if(setValueForAttr(pOp, a, recordNo+r, updatesValue ) != 0){ - ERR(pTrans->getNdbError()); - return NDBT_FAILED; - } + } + + for(a = 0; a<tab.getNoOfColumns(); a++){ + if (tab.getColumn(a)->getPrimaryKey() == false){ + if(setValueForAttr(pOp, a, rowId, updateId ) != 0){ + ERR(pTrans->getNdbError()); + return NDBT_FAILED; } - } + } } + return NDBT_OK; } @@ -187,25 +211,10 @@ int HugoOperations::pkInsertRecord(Ndb* pNdb, return NDBT_FAILED; } - // Define primary keys - for(a = 0; a<tab.getNoOfColumns(); a++){ - if (tab.getColumn(a)->getPrimaryKey() == true){ - if(equalForAttr(pOp, a, r+recordNo) != 0){ - ERR(pTrans->getNdbError()); - return NDBT_FAILED; - } - } + if(setValues(pOp, r+recordNo, updatesValue) != NDBT_OK) + { + return NDBT_FAILED; } - - // Define attributes to update - for(a = 0; a<tab.getNoOfColumns(); a++){ - if (tab.getColumn(a)->getPrimaryKey() == false){ - if(setValueForAttr(pOp, a, recordNo+r, updatesValue ) != 0){ - ERR(pTrans->getNdbError()); - return NDBT_FAILED; - } - } - } } return NDBT_OK; } @@ -373,38 +382,11 @@ int HugoOperations::equalForAttr(NdbOperation* pOp, return NDBT_FAILED; } - int len = attr->getLength(); - switch (attr->getType()){ - case NdbDictionary::Column::Bit: - len = 4 * ((len + 31) >> 5); - case NdbDictionary::Column::Char: - case NdbDictionary::Column::Varchar: - case NdbDictionary::Column::Binary: - case NdbDictionary::Column::Varbinary:{ - char buf[8000]; - memset(buf, 0, sizeof(buf)); - check = pOp->equal( attr->getName(), - calc.calcValue(rowId, attrId, 0, buf, len)); - break; - } - case NdbDictionary::Column::Int: - check = pOp->equal( attr->getName(), (Int32)calc.calcValue(rowId, attrId, 0)); - break; - case NdbDictionary::Column::Unsigned: - check = pOp->equal( attr->getName(), (Uint32)calc.calcValue(rowId, attrId, 0)); - break; - case NdbDictionary::Column::Bigint: - check = pOp->equal( attr->getName(), (Int64)calc.calcValue(rowId, attrId, 0)); - break; - case NdbDictionary::Column::Bigunsigned: - check = pOp->equal( attr->getName(), (Uint64)calc.calcValue(rowId, attrId, 0)); - break; - case NdbDictionary::Column::Float: - g_info << "Float not allowed as PK value" << endl; - check = -1; - break; - } - return check; + int len = attr->getSizeInBytes(); + char buf[8000]; + memset(buf, 0, sizeof(buf)); + return pOp->equal( attr->getName(), + calc.calcValue(rowId, attrId, 0, buf, len)); } int HugoOperations::setValueForAttr(NdbOperation* pOp, @@ -414,47 +396,11 @@ int HugoOperations::setValueForAttr(NdbOperation* pOp, int check = -1; const NdbDictionary::Column* attr = tab.getColumn(attrId); - int len = attr->getLength(); - switch (attr->getType()){ - case NdbDictionary::Column::Bit: - len = 4 * ((len + 31) >> 5); - case NdbDictionary::Column::Char: - case NdbDictionary::Column::Varchar: - case NdbDictionary::Column::Binary: - case NdbDictionary::Column::Varbinary:{ - char buf[8000]; - check = pOp->setValue( attr->getName(), - calc.calcValue(rowId, attrId, updateId, buf, len)); - break; - } - case NdbDictionary::Column::Int:{ - Int32 val = calc.calcValue(rowId, attrId, updateId); - check = pOp->setValue( attr->getName(), val); - } - break; - case NdbDictionary::Column::Bigint:{ - Int64 val = calc.calcValue(rowId, attrId, updateId); - check = pOp->setValue( attr->getName(), - val); - } - break; - case NdbDictionary::Column::Unsigned:{ - Uint32 val = calc.calcValue(rowId, attrId, updateId); - check = pOp->setValue( attr->getName(), val); - } - break; - case NdbDictionary::Column::Bigunsigned:{ - Uint64 val = calc.calcValue(rowId, attrId, updateId); - check = pOp->setValue( attr->getName(), - val); - } - break; - case NdbDictionary::Column::Float: - check = pOp->setValue( attr->getName(), - (float)calc.calcValue(rowId, attrId, updateId)); - break; - } - return check; + int len = attr->getSizeInBytes(); + char buf[8000]; + memset(buf, 0, sizeof(buf)); + return pOp->setValue( attr->getName(), + calc.calcValue(rowId, attrId, updateId, buf, len)); } int @@ -470,7 +416,7 @@ HugoOperations::verifyUpdatesValue(int updatesValue, int _numRows){ result = NDBT_FAILED; continue; } - + if(calc.getUpdatesValue(rows[i]) != updatesValue){ result = NDBT_FAILED; g_err << "Invalid updates value for row " << i << endl @@ -480,7 +426,7 @@ HugoOperations::verifyUpdatesValue(int updatesValue, int _numRows){ continue; } } - + if(_numRows == 0){ g_err << "No rows -> Invalid updates value" << endl; return NDBT_FAILED; diff --git a/ndb/test/src/HugoTransactions.cpp b/ndb/test/src/HugoTransactions.cpp index b76ac088793..0515c0a99f8 100644 --- a/ndb/test/src/HugoTransactions.cpp +++ b/ndb/test/src/HugoTransactions.cpp @@ -72,7 +72,7 @@ HugoTransactions::scanReadRecords(Ndb* pNdb, return NDBT_FAILED; } - if( pOp ->readTuples(lm) ) { + if( pOp ->readTuples(lm, 0, parallelism) ) { ERR(pTrans->getNdbError()); pNdb->closeTransaction(pTrans); return NDBT_FAILED; @@ -775,7 +775,9 @@ HugoTransactions::createEvent(Ndb* pNdb){ NdbDictionary::Dictionary *myDict = pNdb->getDictionary(); if (!myDict) { - printf("Event Creation failedDictionary not found"); + g_err << "Dictionary not found " + << pNdb->getNdbError().code << " " + << pNdb->getNdbError().message << endl; return NDBT_FAILED; } @@ -796,21 +798,33 @@ HugoTransactions::createEvent(Ndb* pNdb){ if (res == 0) myEvent.print(); - else { - g_info << "Event creation failed\n"; - g_info << "trying drop Event, maybe event exists\n"; + else if (myDict->getNdbError().classification == + NdbError::SchemaObjectExists) + { + g_info << "Event creation failed event exists\n"; res = myDict->dropEvent(eventName); if (res) { - g_err << "failed to drop event\n"; + g_err << "Failed to drop event: " + << myDict->getNdbError().code << " : " + << myDict->getNdbError().message << endl; return NDBT_FAILED; } // try again res = myDict->createEvent(myEvent); // Add event to database if (res) { - g_err << "failed to create event\n"; + g_err << "Failed to create event (1): " + << myDict->getNdbError().code << " : " + << myDict->getNdbError().message << endl; return NDBT_FAILED; } } + else + { + g_err << "Failed to create event (2): " + << myDict->getNdbError().code << " : " + << myDict->getNdbError().message << endl; + return NDBT_FAILED; + } return NDBT_OK; } diff --git a/ndb/test/src/NDBT_Test.cpp b/ndb/test/src/NDBT_Test.cpp index 45ee172811a..0e45572ca3b 100644 --- a/ndb/test/src/NDBT_Test.cpp +++ b/ndb/test/src/NDBT_Test.cpp @@ -617,8 +617,7 @@ int NDBT_TestCase::execute(NDBT_Context* ctx){ << endl; } return res; -}; - +} void NDBT_TestCase::startTimer(NDBT_Context* ctx){ timer.doStart(); diff --git a/ndb/test/src/NdbBackup.cpp b/ndb/test/src/NdbBackup.cpp index 5e22468692e..bc5baeae4b5 100644 --- a/ndb/test/src/NdbBackup.cpp +++ b/ndb/test/src/NdbBackup.cpp @@ -336,7 +336,7 @@ NdbBackup::NF(NdbRestarter& _restarter, int *NFDuringBackup_codes, const int sz, } return NDBT_OK; -}; +} int FailS_codes[] = { diff --git a/ndb/test/src/NdbRestarts.cpp b/ndb/test/src/NdbRestarts.cpp index 607e48c4126..c0f31af84ce 100644 --- a/ndb/test/src/NdbRestarts.cpp +++ b/ndb/test/src/NdbRestarts.cpp @@ -213,7 +213,7 @@ NdbRestarts::NdbRestart::NdbRestart(const char* _name, m_restartFunc = _func; m_numRequiredNodes = _requiredNodes; // m_arg1 = arg1; -}; +} int NdbRestarts::getNumRestarts(){ @@ -367,7 +367,7 @@ int restartRandomNodeGraceful(NdbRestarter& _restarter, "Could not restart node "<<nodeId); return NDBT_OK; -}; +} int restartRandomNodeAbort(NdbRestarter& _restarter, const NdbRestarts::NdbRestart* _restart){ @@ -382,7 +382,7 @@ int restartRandomNodeAbort(NdbRestarter& _restarter, "Could not restart node "<<nodeId); return NDBT_OK; -}; +} int restartRandomNodeError(NdbRestarter& _restarter, const NdbRestarts::NdbRestart* _restart){ @@ -397,7 +397,7 @@ int restartRandomNodeError(NdbRestarter& _restarter, "Could not restart node "<<nodeId); return NDBT_OK; -}; +} int restartMasterNodeError(NdbRestarter& _restarter, const NdbRestarts::NdbRestart* _restart){ @@ -410,7 +410,7 @@ int restartMasterNodeError(NdbRestarter& _restarter, "Could not restart node "<<nodeId); return NDBT_OK; -}; +} int restartRandomNodeInitial(NdbRestarter& _restarter, const NdbRestarts::NdbRestart* _restart){ @@ -425,7 +425,7 @@ int restartRandomNodeInitial(NdbRestarter& _restarter, "Could not restart node "<<nodeId); return NDBT_OK; -}; +} int twoNodeFailure(NdbRestarter& _restarter, const NdbRestarts::NdbRestart* _restart){ @@ -453,7 +453,7 @@ int twoNodeFailure(NdbRestarter& _restarter, "Could not restart node "<< nodeId); return NDBT_OK; -}; +} int twoMasterNodeFailure(NdbRestarter& _restarter, const NdbRestarts::NdbRestart* _restart){ @@ -478,7 +478,7 @@ int twoMasterNodeFailure(NdbRestarter& _restarter, "Could not restart node "<< nodeId); return NDBT_OK; -}; +} int get50PercentOfNodes(NdbRestarter& restarter, int * _nodes){ @@ -519,7 +519,7 @@ int fiftyPercentFail(NdbRestarter& _restarter, "Could not start all nodes"); return NDBT_OK; -}; +} int restartAllNodesGracfeul(NdbRestarter& _restarter, @@ -533,7 +533,7 @@ int restartAllNodesGracfeul(NdbRestarter& _restarter, return NDBT_OK; -}; +} int restartAllNodesAbort(NdbRestarter& _restarter, const NdbRestarts::NdbRestart* _restart){ @@ -545,7 +545,7 @@ int restartAllNodesAbort(NdbRestarter& _restarter, "Could not restart all nodes"); return NDBT_OK; -}; +} int restartAllNodesError9999(NdbRestarter& _restarter, const NdbRestarts::NdbRestart* _restart){ @@ -557,7 +557,7 @@ int restartAllNodesError9999(NdbRestarter& _restarter, "Could not restart all nodes "); return NDBT_OK; -}; +} int fiftyPercentStopAndWait(NdbRestarter& _restarter, const NdbRestarts::NdbRestart* _restart){ @@ -590,7 +590,7 @@ int fiftyPercentStopAndWait(NdbRestarter& _restarter, g_info << _restart->m_name << endl; return NDBT_OK; -}; +} int NFDuringNR_codes[] = { @@ -713,7 +713,7 @@ int restartNFDuringNR(NdbRestarter& _restarter, } return NDBT_OK; -}; +} int NRDuringLCP_Master_codes[] = { @@ -864,7 +864,7 @@ int stopOnError(NdbRestarter& _restarter, } while (false); return NDBT_OK; -}; +} int getRandomNodeId(NdbRestarter& _restarter) { myRandom48Init(NdbTick_CurrentMillisecond()); |