diff options
author | unknown <tulin@dl145b.mysql.com> | 2005-06-08 17:12:09 +0200 |
---|---|---|
committer | unknown <tulin@dl145b.mysql.com> | 2005-06-08 17:12:09 +0200 |
commit | 97a3ff8e66475fcd18413e99b851328f62c4dd67 (patch) | |
tree | 53320dc04d2342b7dc043b456fc11aa8789f5495 | |
parent | ad34f7db24c6d1397336edf56ea39f360d414efb (diff) | |
parent | 86c4e1d2d9a84e4e04a543de7bd6d219e4dbf1de (diff) | |
download | mariadb-git-97a3ff8e66475fcd18413e99b851328f62c4dd67.tar.gz |
Merge tulin@bk-internal.mysql.com:/home/bk/mysql-5.0-ndb
into dl145b.mysql.com:/home/ndbdev/tomas/mysql-5.1
libmysqld/Makefile.am:
Auto merged
mysql-test/mysql-test-run.sh:
Auto merged
sql/field.cc:
Auto merged
sql/ha_ndbcluster.cc:
Auto merged
sql/sql_select.cc:
Auto merged
storage/ndb/include/kernel/AttributeList.hpp:
Auto merged
storage/ndb/include/ndbapi/Ndb.hpp:
Auto merged
storage/ndb/include/transporter/TransporterDefinitions.hpp:
Auto merged
storage/ndb/include/util/SimpleProperties.hpp:
Auto merged
storage/ndb/src/common/transporter/SCI_Transporter.cpp:
Auto merged
storage/ndb/src/common/util/SimpleProperties.cpp:
Auto merged
storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp:
Auto merged
storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp:
Auto merged
storage/ndb/src/ndbapi/DictCache.cpp:
Auto merged
storage/ndb/src/ndbapi/DictCache.hpp:
Auto merged
storage/ndb/src/ndbapi/Ndb.cpp:
Auto merged
storage/ndb/src/ndbapi/NdbBlob.cpp:
Auto merged
storage/ndb/src/ndbapi/NdbDictionary.cpp:
Auto merged
storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp:
Auto merged
storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp:
Auto merged
storage/ndb/src/ndbapi/NdbImpl.hpp:
Auto merged
storage/ndb/src/ndbapi/NdbLinHash.hpp:
Auto merged
storage/ndb/src/ndbapi/NdbTransaction.cpp:
Auto merged
storage/ndb/test/ndbapi/testBlobs.cpp:
Auto merged
storage/ndb/test/ndbapi/testDict.cpp:
Auto merged
storage/ndb/test/ndbapi/testNodeRestart.cpp:
Auto merged
storage/ndb/test/ndbapi/testOIBasic.cpp:
Auto merged
storage/ndb/tools/restore/Restore.hpp:
Auto merged
storage/ndb/src/kernel/blocks/backup/Backup.cpp:
Auto merged
storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp:
Auto merged
storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp:
Auto merged
storage/ndb/test/ndbapi/testNdbApi.cpp:
Auto merged
storage/ndb/test/run-test/daily-basic-tests.txt:
Auto merged
storage/ndb/tools/restore/Restore.cpp:
Auto merged
storage/ndb/tools/restore/consumer_restore.cpp:
Auto merged
BitKeeper/etc/logging_ok:
auto-union
configure.in:
Auto merged
sql/sql_parse.cc:
Auto merged
38 files changed, 1039 insertions, 537 deletions
diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index a5e3f7977ee..3cd1fb6f996 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -70,6 +70,7 @@ install-data-local: $(DESTDIR)$(testdir)/lib $(INSTALL_DATA) $(srcdir)/README $(DESTDIR)$(testdir) $(INSTALL_DATA) $(srcdir)/t/*.test $(DESTDIR)$(testdir)/t + $(INSTALL_DATA) $(srcdir)/t/*.sql $(DESTDIR)$(testdir)/t -$(INSTALL_DATA) $(srcdir)/t/*.disabled $(DESTDIR)$(testdir)/t $(INSTALL_DATA) $(srcdir)/t/*.opt $(DESTDIR)$(testdir)/t $(INSTALL_DATA) $(srcdir)/t/*.sh $(DESTDIR)$(testdir)/t diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result index 0798a034c3e..e4889289c18 100644 --- a/mysql-test/r/func_math.result +++ b/mysql-test/r/func_math.result @@ -130,3 +130,16 @@ Warnings: Note 1003 select degrees(pi()) AS `degrees(pi())`,radians(360) AS `radians(360)` select rand(rand); ERROR 42S22: Unknown column 'rand' in 'field list' +create table t1 (col1 int, col2 decimal(60,30)); +insert into t1 values(1,1234567890.12345); +select format(col2,7) from t1; +format(col2,7) +1,234,567,890.1234500 +select format(col2,8) from t1; +format(col2,8) +1,234,567,890.12345000 +insert into t1 values(7,1234567890123456.12345); +select format(col2,6) from t1 where col1=7; +format(col2,6) +1,234,567,890,123,456.123450 +drop table t1; diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result index ab57caacc0f..93467d1d7da 100644 --- a/mysql-test/r/type_decimal.result +++ b/mysql-test/r/type_decimal.result @@ -414,8 +414,8 @@ Warning 1264 Out of range value adjusted for column 'a' at row 2 Warning 1264 Out of range value adjusted for column 'a' at row 7 select * from t1; a -9999999999 -9999999999 +0 +0 1 1 1 @@ -430,8 +430,8 @@ Warning 1264 Out of range value adjusted for column 'a' at row 2 Warning 1264 Out of range value adjusted for column 'a' at row 7 select * from t1; a -9999999999 -9999999999 +0000000000 +0000000000 0000000001 0000000001 0000000001 @@ -446,8 +446,8 @@ Warning 1264 Out of range value adjusted for column 'a' at row 2 Warning 1264 Out of range value adjusted for column 'a' at row 7 select * from t1; a -9999999999 -9999999999 +0000000000 +0000000000 0000000001 0000000001 0000000001 diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result index f03f2f5a862..09fbc6b8143 100644 --- a/mysql-test/r/type_newdecimal.result +++ b/mysql-test/r/type_newdecimal.result @@ -119,7 +119,7 @@ a 99.99 99.99 99.99 -99.99 +0.00 0.00 0.00 0.00 @@ -891,3 +891,21 @@ NULL select abs(NULL); abs(NULL) NULL +set @@sql_mode='traditional'; +create table t1( d1 decimal(18) unsigned, d2 decimal(20) unsigned, d3 decimal (22) unsigned); +insert into t1 values(1,-1,-1); +ERROR 22003: Out of range value adjusted for column 'd2' at row 1 +drop table t1; +set @@div_precision_increment=15; +create table t1 (col1 int, col2 decimal(30,25), col3 numeric(30,25)); +insert into t1 values (1,0.0123456789012345678912345,0.0123456789012345678912345); +select col2/9999999999 from t1 where col1=1; +col2/9999999999 +0.000000000001234567890246913578 +select 9999999999/col2 from t1 where col1=1; +9999999999/col2 +810000007209.000065537105051 +select 77777777/7777777; +77777777/7777777 +10.000000900000090 +drop table t1; diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index 0eac72782a8..b21f38052b6 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -67,3 +67,15 @@ explain extended select degrees(pi()),radians(360); --error 1054 select rand(rand); + +# +# Bug #8459 (FORMAT returns incorrect result) +# +create table t1 (col1 int, col2 decimal(60,30)); +insert into t1 values(1,1234567890.12345); +select format(col2,7) from t1; +select format(col2,8) from t1; +insert into t1 values(7,1234567890123456.12345); +select format(col2,6) from t1 where col1=7; +drop table t1; + diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test index 0f7d20ed977..6bff6c22abc 100644 --- a/mysql-test/t/type_newdecimal.test +++ b/mysql-test/t/type_newdecimal.test @@ -925,3 +925,24 @@ DROP TABLE t1; select abs(10/0); select abs(NULL); + +# +# Bug #9894 (negative to unsigned column) +# +set @@sql_mode='traditional'; +create table t1( d1 decimal(18) unsigned, d2 decimal(20) unsigned, d3 decimal (22) unsigned); +--error 1264 +insert into t1 values(1,-1,-1); +drop table t1; + +# +# Bug #8425 (insufficient precision of the division) +# +set @@div_precision_increment=15; +create table t1 (col1 int, col2 decimal(30,25), col3 numeric(30,25)); +insert into t1 values (1,0.0123456789012345678912345,0.0123456789012345678912345); +select col2/9999999999 from t1 where col1=1; +select 9999999999/col2 from t1 where col1=1; +select 77777777/7777777; +drop table t1; + diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index 064c5e63f40..74734f4dd5f 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -226,7 +226,7 @@ $CP mysql-test/std_data/*.dat mysql-test/std_data/*.frm \ mysql-test/std_data/des_key_file mysql-test/std_data/*.*001 \ $BASE/mysql-test/std_data $CP mysql-test/t/*.test mysql-test/t/*.disabled mysql-test/t/*.opt \ - mysql-test/t/*.slave-mi mysql-test/t/*.sh $BASE/mysql-test/t + mysql-test/t/*.slave-mi mysql-test/t/*.sh mysql-test/t/*.sql $BASE/mysql-test/t $CP mysql-test/r/*.result mysql-test/r/*.require \ $BASE/mysql-test/r diff --git a/sql/field.cc b/sql/field.cc index 78b08fa3cd9..daa28887ee9 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2447,7 +2447,7 @@ int Field_new_decimal::store(longlong nr) int err; if ((err= int2my_decimal(E_DEC_FATAL_ERROR & ~E_DEC_OVERFLOW, - nr, unsigned_flag, &decimal_value))) + nr, false, &decimal_value))) { if (check_overflow(err)) set_value_on_overflow(&decimal_value, decimal_value.sign()); diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index f823dc97356..ab278f0fa7f 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -4611,7 +4611,7 @@ int ndbcluster_find_files(THD *thd,const char *db,const char *path, List_iterator_fast<char> it2(create_list); while ((file_name=it2++)) { - DBUG_PRINT("info", ("Table %s need discovery", name)); + DBUG_PRINT("info", ("Table %s need discovery", file_name)); if (ha_create_table_from_engine(thd, db, file_name, TRUE) == 0) files->push_back(thd->strdup(file_name)); } diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index d3327a0e41f..539bed58e66 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1668,22 +1668,36 @@ Item_func_format::Item_func_format(Item *org,int dec) :Item_str_func(org) String *Item_func_format::val_str(String *str) { - DBUG_ASSERT(fixed == 1); - double nr= args[0]->val_real(); - uint32 length,str_length,dec; + uint32 length, str_length ,dec; int diff; - if ((null_value=args[0]->null_value)) - return 0; /* purecov: inspected */ - nr= my_double_round(nr, decimals, FALSE); + DBUG_ASSERT(fixed == 1); dec= decimals ? decimals+1 : 0; - /* Here default_charset() is right as this is not an automatic conversion */ - str->set(nr,decimals, default_charset()); - if (isnan(nr)) - return str; - str_length=str->length(); - if (nr < 0) - str_length--; // Don't count sign + if (args[0]->result_type() == DECIMAL_RESULT || + args[0]->result_type() == INT_RESULT) + { + my_decimal dec_val, rnd_dec, *res; + res= args[0]->val_decimal(&dec_val); + my_decimal_round(E_DEC_FATAL_ERROR, res, decimals, false, &rnd_dec); + my_decimal2string(E_DEC_FATAL_ERROR, &rnd_dec, 0, 0, 0, str); + str_length= str->length(); + if (rnd_dec.sign()) + str_length--; + } + else + { + double nr= args[0]->val_real(); + if ((null_value=args[0]->null_value)) + return 0; /* purecov: inspected */ + nr= my_double_round(nr, decimals, FALSE); + /* Here default_charset() is right as this is not an automatic conversion */ + str->set(nr,decimals, default_charset()); + if (isnan(nr)) + return str; + str_length=str->length(); + if (nr < 0) + str_length--; // Don't count sign + } /* We need this test to handle 'nan' values */ if (str_length >= dec+4) { diff --git a/storage/ndb/include/kernel/AttributeList.hpp b/storage/ndb/include/kernel/AttributeList.hpp index 7c6f71df3d2..70b178c6c79 100644 --- a/storage/ndb/include/kernel/AttributeList.hpp +++ b/storage/ndb/include/kernel/AttributeList.hpp @@ -17,6 +17,8 @@ #ifndef ATTRIBUTE_LIST_HPP #define ATTRIBUTE_LIST_HPP +#include "ndb_limits.h" + /** * Masks and lists used by index and trigger. Must be plain old Uint32 data. * XXX depends on other headers XXX move to some common file diff --git a/storage/ndb/include/ndbapi/Ndb.hpp b/storage/ndb/include/ndbapi/Ndb.hpp index a36cdc2b475..cefe6477cdd 100644 --- a/storage/ndb/include/ndbapi/Ndb.hpp +++ b/storage/ndb/include/ndbapi/Ndb.hpp @@ -1583,15 +1583,17 @@ private: void abortTransactionsAfterNodeFailure(Uint16 aNodeId); static - const char * externalizeTableName(const char * internalTableName, bool fullyQualifiedNames); + const char * externalizeTableName(const char * internalTableName, + bool fullyQualifiedNames); const char * externalizeTableName(const char * internalTableName); - const char * internalizeTableName(const char * externalTableName); + const BaseString internalize_table_name(const char * external_name) const; static - const char * externalizeIndexName(const char * internalIndexName, bool fullyQualifiedNames); + const char * externalizeIndexName(const char * internalIndexName, + bool fullyQualifiedNames); const char * externalizeIndexName(const char * internalIndexName); - const char * internalizeIndexName(const NdbTableImpl * table, - const char * externalIndexName); + const BaseString internalize_index_name(const NdbTableImpl * table, + const char * external_name) const; static const BaseString getDatabaseFromInternalName(const char * internalName); diff --git a/storage/ndb/include/transporter/TransporterDefinitions.hpp b/storage/ndb/include/transporter/TransporterDefinitions.hpp index 43af6749a85..18d1ec76a3c 100644 --- a/storage/ndb/include/transporter/TransporterDefinitions.hpp +++ b/storage/ndb/include/transporter/TransporterDefinitions.hpp @@ -45,9 +45,8 @@ enum SendStatus { * Protocol6 Header + * (optional signal id) + (optional checksum) + (signal data) */ -const Uint32 MAX_SECTION_SIZE= 4096; //const Uint32 MAX_MESSAGE_SIZE = (12+4+4+(4*25)); -const Uint32 MAX_MESSAGE_SIZE = (12+4+4+(4*25)+(3*4)+4*MAX_SECTION_SIZE); +const Uint32 MAX_MESSAGE_SIZE = (12+4+4+(4*25)+(3*4)+4*4096); /** * TransporterConfiguration diff --git a/storage/ndb/include/util/SimpleProperties.hpp b/storage/ndb/include/util/SimpleProperties.hpp index 356f3406f38..438426fb62b 100644 --- a/storage/ndb/include/util/SimpleProperties.hpp +++ b/storage/ndb/include/util/SimpleProperties.hpp @@ -172,6 +172,8 @@ public: virtual bool reset() = 0; virtual bool putWord(Uint32 val) = 0; virtual bool putWords(const Uint32 * src, Uint32 len) = 0; + private: + bool add(const char* value, int len); }; }; @@ -211,7 +213,7 @@ private: }; /** - * Writer for linear memory + * Writer for UtilBuffer */ class UtilBufferWriter : public SimpleProperties::Writer { public: diff --git a/storage/ndb/src/common/transporter/SCI_Transporter.cpp b/storage/ndb/src/common/transporter/SCI_Transporter.cpp index c96f84a4f4f..1fe276249e5 100644 --- a/storage/ndb/src/common/transporter/SCI_Transporter.cpp +++ b/storage/ndb/src/common/transporter/SCI_Transporter.cpp @@ -48,7 +48,7 @@ SCI_Transporter::SCI_Transporter(TransporterRegistry &t_reg, Uint32 reportFreq) : Transporter(t_reg, tt_SCI_TRANSPORTER, lHostName, rHostName, r_port, isMgmConnection, _localNodeId, - _remoteNodeId, serverNodeID, 0, false, chksm, signalId) + _remoteNodeId, serverNodeId, 0, false, chksm, signalId) { DBUG_ENTER("SCI_Transporter::SCI_Transporter"); m_PacketSize = (packetSize + 3)/4 ; diff --git a/storage/ndb/src/common/util/SimpleProperties.cpp b/storage/ndb/src/common/util/SimpleProperties.cpp index 00c440fcb4e..c25aaea491a 100644 --- a/storage/ndb/src/common/util/SimpleProperties.cpp +++ b/storage/ndb/src/common/util/SimpleProperties.cpp @@ -37,6 +37,28 @@ SimpleProperties::Writer::add(Uint16 key, Uint32 value){ } bool +SimpleProperties::Writer::add(const char * value, int len){ + const Uint32 valLen = (len + 3) / 4; + + if ((len % 4) == 0) + return putWords((Uint32*)value, valLen); + + const Uint32 putLen= valLen - 1; + if (!putWords((Uint32*)value, putLen)) + return false; + + // Special handling of last bytes + union { + Uint32 lastWord; + char lastBytes[4]; + }; + memcpy(lastBytes, + value + putLen*4, + len - putLen*4); + return putWord(lastWord); +} + +bool SimpleProperties::Writer::add(Uint16 key, const char * value){ Uint32 head = StringValue; head <<= 16; @@ -46,9 +68,9 @@ SimpleProperties::Writer::add(Uint16 key, const char * value){ Uint32 strLen = strlen(value) + 1; // Including NULL-byte if(!putWord(htonl(strLen))) return false; - - const Uint32 valLen = (strLen + 3) / 4; - return putWords((Uint32*)value, valLen); + + return add(value, (int)strLen); + } bool @@ -60,9 +82,8 @@ SimpleProperties::Writer::add(Uint16 key, const void* value, int len){ return false; if(!putWord(htonl(len))) return false; - - const Uint32 valLen = (len + 3) / 4; - return putWords((Uint32*)value, valLen); + + return add((const char*)value, len); } SimpleProperties::Reader::Reader(){ @@ -392,6 +413,7 @@ UtilBufferWriter::putWords(const Uint32 * src, Uint32 len){ return (m_buf.append(src, 4 * len) == 0); } + Uint32 UtilBufferWriter::getWordsUsed() const { return m_buf.length() / 4;} diff --git a/storage/ndb/src/kernel/blocks/backup/Backup.cpp b/storage/ndb/src/kernel/blocks/backup/Backup.cpp index fdff2702bec..327fcc33aff 100644 --- a/storage/ndb/src/kernel/blocks/backup/Backup.cpp +++ b/storage/ndb/src/kernel/blocks/backup/Backup.cpp @@ -1676,13 +1676,30 @@ Backup::execWAIT_GCP_CONF(Signal* signal){ ptr.p->masterData.sendCounter= 0; ptr.p->masterData.gsn = GSN_BACKUP_FRAGMENT_REQ; nextFragment(signal, ptr); + return; } else { jam(); - CRASH_INSERTION((10009)); - ptr.p->stopGCP = gcp; - sendDropTrig(signal, ptr); // regular dropping of triggers - }//if + if(gcp >= ptr.p->startGCP + 3) + { + CRASH_INSERTION((10009)); + ptr.p->stopGCP = gcp; + sendDropTrig(signal, ptr); // regular dropping of triggers + return; + }//if + + /** + * Make sure that we got entire stopGCP + */ + WaitGCPReq * req = (WaitGCPReq*)signal->getDataPtrSend(); + req->senderRef = reference(); + req->senderData = ptr.i; + req->requestType = WaitGCPReq::CompleteForceStart; + sendSignal(DBDIH_REF, GSN_WAIT_GCP_REQ, signal, + WaitGCPReq::SignalLength,JBB); + return; + } } + /***************************************************************************** * * Master functionallity - Backup fragment diff --git a/storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp b/storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp index 0054b935cdb..24f9715c8b4 100644 --- a/storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp +++ b/storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp @@ -1668,7 +1668,7 @@ void Dbacc::initOpRec(Signal* signal) void Dbacc::sendAcckeyconf(Signal* signal) { signal->theData[0] = operationRecPtr.p->userptr; - signal->theData[1] = operationRecPtr.p->insertIsDone; + signal->theData[1] = operationRecPtr.p->operation; signal->theData[2] = operationRecPtr.p->fid; signal->theData[3] = operationRecPtr.p->localdata[0]; signal->theData[4] = operationRecPtr.p->localdata[1]; @@ -1754,6 +1754,11 @@ void Dbacc::execACCKEYREQ(Signal* signal) case ZWRITE: case ZSCAN_OP: if (!tgeLocked){ + if(operationRecPtr.p->operation == ZWRITE) + { + jam(); + operationRecPtr.p->operation = ZUPDATE; + } sendAcckeyconf(signal); if (operationRecPtr.p->dirtyRead == ZFALSE) { /*---------------------------------------------------------------*/ @@ -2279,6 +2284,12 @@ Uint32 Dbacc::placeWriteInLockQueue(Signal* signal) return ZWRITE_ERROR; }//if + if(operationRecPtr.p->operation == ZWRITE) + { + operationRecPtr.p->operation = + (mlpqOperPtr.p->operation == ZDELETE) ? ZINSERT : ZUPDATE; + } + operationRecPtr.p->localdata[0] = queOperPtr.p->localdata[0]; operationRecPtr.p->localdata[1] = queOperPtr.p->localdata[1]; operationRecPtr.p->prevParallelQue = mlpqOperPtr.i; diff --git a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp index 03309f3ac67..2a661104347 100644 --- a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp +++ b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp @@ -6458,6 +6458,7 @@ void Dbdih::execDIADDTABREQ(Signal* signal) ndbrequire(noReplicas == cnoReplicas); // Only allowed if (ERROR_INSERTED(7173)) { + CLEAR_ERROR_INSERT_VALUE; addtabrefuseLab(signal, connectPtr, ZREPLERROR1); return; } diff --git a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp index 138a2526804..725ea04c148 100644 --- a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp +++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp @@ -3905,20 +3905,21 @@ void Dblqh::execACCKEYCONF(Signal* signal) * EITHER TO THE TC BLOCK OR DIRECTLY TO THE APPLICATION. THE SCHEMA VERSION * IS NEEDED SINCE TWO SCHEMA VERSIONS CAN BE ACTIVE SIMULTANEOUSLY ON A * TABLE. - * ------------------------------------------------------------------------ */ - if (regTcPtr->operation == ZWRITE) { - if (signal->theData[1] > 0) { - /* -------------------------------------------------------------------- - * ACC did perform an insert and thus we should indicate that the WRITE - * is an INSERT otherwise it is an UPDATE. - * -------------------------------------------------------------------- */ - jam(); - regTcPtr->operation = ZINSERT; - } else { - jam(); - tcConnectptr.p->operation = ZUPDATE; - }//if + * ----------------------------------------------------------------------- */ + if (regTcPtr->operation == ZWRITE) + { + Uint32 op= signal->theData[1]; + if(likely(op == ZINSERT || op == ZUPDATE)) + { + regTcPtr->operation = op; + } + else + { + warningEvent("Convering %d to ZUPDATE", op); + regTcPtr->operation = ZUPDATE; + } }//if + ndbrequire(localKeyFlag == 1); localKey2 = localKey1 & MAX_TUPLES_PER_PAGE; localKey1 = localKey1 >> MAX_TUPLES_BITS; diff --git a/storage/ndb/src/ndbapi/DictCache.cpp b/storage/ndb/src/ndbapi/DictCache.cpp index ccc45a04824..3d14df908a0 100644 --- a/storage/ndb/src/ndbapi/DictCache.cpp +++ b/storage/ndb/src/ndbapi/DictCache.cpp @@ -80,11 +80,14 @@ LocalDictCache::drop(const char * name){ * Global cache */ GlobalDictCache::GlobalDictCache(){ + DBUG_ENTER("GlobalDictCache::GlobalDictCache"); m_tableHash.createHashTable(); m_waitForTableCondition = NdbCondition_Create(); + DBUG_VOID_RETURN; } GlobalDictCache::~GlobalDictCache(){ + DBUG_ENTER("GlobalDictCache::~GlobalDictCache"); NdbElement_t<Vector<TableVersion> > * curr = m_tableHash.getNext(0); while(curr != 0){ Vector<TableVersion> * vers = curr->theData; @@ -94,20 +97,52 @@ GlobalDictCache::~GlobalDictCache(){ delete (* vers)[i].m_impl; } delete curr->theData; + curr->theData= NULL; curr = m_tableHash.getNext(curr); } - m_tableHash.releaseHashTable(); NdbCondition_Destroy(m_waitForTableCondition); + DBUG_VOID_RETURN; } -#include <NdbOut.hpp> +void GlobalDictCache::printCache() +{ + DBUG_ENTER("GlobalDictCache::printCache"); + NdbElement_t<Vector<TableVersion> > * curr = m_tableHash.getNext(0); + while(curr != 0){ + DBUG_PRINT("curr", ("len: %d, hash: %d, lk: %d, str: %s", + curr->len, curr->hash, curr->localkey1, curr->str)); + if (curr->theData){ + Vector<TableVersion> * vers = curr->theData; + const unsigned sz = vers->size(); + for(unsigned i = 0; i<sz ; i++){ + TableVersion tv= (*vers)[i]; + DBUG_PRINT(" ", ("vers[%d]: ver: %d, refCount: %d, status: %d", + sz, tv.m_version, tv.m_refCount, tv.m_status)); + if(tv.m_impl != 0) + { + DBUG_PRINT(" ", ("m_impl: internalname: %s", + tv.m_impl->m_internalName.c_str())); + } + } + } + else + { + DBUG_PRINT(" ", ("NULL")); + } + curr = m_tableHash.getNext(curr); + } + DBUG_VOID_RETURN; +} -NdbTableImpl * +NdbTableImpl * GlobalDictCache::get(const char * name) { + DBUG_ENTER("GlobalDictCache::get"); + DBUG_PRINT("enter", ("name: %s", name)); + const Uint32 len = strlen(name); - Vector<TableVersion> * versions = 0; + Vector<TableVersion> * versions = 0; versions = m_tableHash.getData(name, len); if(versions == 0){ versions = new Vector<TableVersion>(2); @@ -122,7 +157,7 @@ GlobalDictCache::get(const char * name) switch(ver->m_status){ case OK: ver->m_refCount++; - return ver->m_impl; + DBUG_RETURN(ver->m_impl); case DROPPED: retreive = true; // Break loop break; @@ -141,24 +176,28 @@ GlobalDictCache::get(const char * name) tmp.m_status = RETREIVING; tmp.m_refCount = 1; // The one retreiving it versions->push_back(tmp); - return 0; + DBUG_RETURN(0); } NdbTableImpl * GlobalDictCache::put(const char * name, NdbTableImpl * tab) { + DBUG_ENTER("GlobalDictCache::put"); + DBUG_PRINT("enter", ("name: %s, internal_name: %s", + name, tab ? tab->m_internalName.c_str() : "tab NULL")); + const Uint32 len = strlen(name); Vector<TableVersion> * vers = m_tableHash.getData(name, len); if(vers == 0){ // Should always tried to retreive it first - // and then there should be a record + // and thus there should be a record abort(); } const Uint32 sz = vers->size(); if(sz == 0){ // Should always tried to retreive it first - // and then there should be a record + // and thus there should be a record abort(); } @@ -171,7 +210,7 @@ GlobalDictCache::put(const char * name, NdbTableImpl * tab) } if(tab == 0){ - // No table found in db + DBUG_PRINT("info", ("No table found in db")); vers->erase(sz - 1); } else { ver.m_impl = tab; @@ -180,74 +219,84 @@ GlobalDictCache::put(const char * name, NdbTableImpl * tab) } NdbCondition_Broadcast(m_waitForTableCondition); - return tab; + DBUG_RETURN(tab); } void GlobalDictCache::drop(NdbTableImpl * tab) { + DBUG_ENTER("GlobalDictCache::drop"); + DBUG_PRINT("enter", ("internal_name: %s", tab->m_internalName.c_str())); + unsigned i; const Uint32 len = strlen(tab->m_internalName.c_str()); Vector<TableVersion> * vers = m_tableHash.getData(tab->m_internalName.c_str(), len); if(vers == 0){ // Should always tried to retreive it first - // and then there should be a record + // and thus there should be a record abort(); } const Uint32 sz = vers->size(); if(sz == 0){ // Should always tried to retreive it first - // and then there should be a record + // and thus there should be a record abort(); } - + for(i = 0; i < sz; i++){ TableVersion & ver = (* vers)[i]; if(ver.m_impl == tab){ - if(ver.m_refCount == 0 || ver.m_status == RETREIVING || + if(ver.m_refCount == 0 || ver.m_status == RETREIVING || ver.m_version != tab->m_version){ - ndbout_c("Dropping with refCount=%d status=%d impl=%p", - ver.m_refCount, ver.m_status, ver.m_impl); + DBUG_PRINT("info", ("Dropping with refCount=%d status=%d impl=%p", + ver.m_refCount, ver.m_status, ver.m_impl)); break; } - + DBUG_PRINT("info", ("Found table to drop, i: %d, name: %s", + i, ver.m_impl->m_internalName.c_str())); ver.m_refCount--; ver.m_status = DROPPED; if(ver.m_refCount == 0){ + DBUG_PRINT("info", ("refCount is zero, deleting m_impl")) delete ver.m_impl; vers->erase(i); } - return; + DBUG_VOID_RETURN; } } - + for(i = 0; i<sz; i++){ TableVersion & ver = (* vers)[i]; - ndbout_c("%d: version: %d refCount: %d status: %d impl: %p", - i, ver.m_version, ver.m_refCount, ver.m_status, ver.m_impl); + DBUG_PRINT("info", ("%d: version: %d refCount: %d status: %d impl: %p", + i, ver.m_version, ver.m_refCount, + ver.m_status, ver.m_impl)); } abort(); } void -GlobalDictCache::release(NdbTableImpl * tab){ +GlobalDictCache::release(NdbTableImpl * tab) +{ + DBUG_ENTER("GlobalDictCache::release"); + DBUG_PRINT("enter", ("internal_name: %s", tab->m_internalName.c_str())); + unsigned i; const Uint32 len = strlen(tab->m_internalName.c_str()); Vector<TableVersion> * vers = m_tableHash.getData(tab->m_internalName.c_str(), len); if(vers == 0){ // Should always tried to retreive it first - // and then there should be a record + // and thus there should be a record abort(); } const Uint32 sz = vers->size(); if(sz == 0){ // Should always tried to retreive it first - // and then there should be a record + // and thus there should be a record abort(); } @@ -256,20 +305,21 @@ GlobalDictCache::release(NdbTableImpl * tab){ if(ver.m_impl == tab){ if(ver.m_refCount == 0 || ver.m_status == RETREIVING || ver.m_version != tab->m_version){ - ndbout_c("Releasing with refCount=%d status=%d impl=%p", - ver.m_refCount, ver.m_status, ver.m_impl); + DBUG_PRINT("info", ("Releasing with refCount=%d status=%d impl=%p", + ver.m_refCount, ver.m_status, ver.m_impl)); break; } ver.m_refCount--; - return; + DBUG_VOID_RETURN; } } for(i = 0; i<sz; i++){ TableVersion & ver = (* vers)[i]; - ndbout_c("%d: version: %d refCount: %d status: %d impl: %p", - i, ver.m_version, ver.m_refCount, ver.m_status, ver.m_impl); + DBUG_PRINT("info", ("%d: version: %d refCount: %d status: %d impl: %p", + i, ver.m_version, ver.m_refCount, + ver.m_status, ver.m_impl)); } abort(); diff --git a/storage/ndb/src/ndbapi/DictCache.hpp b/storage/ndb/src/ndbapi/DictCache.hpp index ca31c345396..d9bf810a685 100644 --- a/storage/ndb/src/ndbapi/DictCache.hpp +++ b/storage/ndb/src/ndbapi/DictCache.hpp @@ -76,6 +76,8 @@ public: }; private: + void printCache(); + struct TableVersion { Uint32 m_version; Uint32 m_refCount; diff --git a/storage/ndb/src/ndbapi/Ndb.cpp b/storage/ndb/src/ndbapi/Ndb.cpp index c48e70f1d51..9bf5be259c6 100644 --- a/storage/ndb/src/ndbapi/Ndb.cpp +++ b/storage/ndb/src/ndbapi/Ndb.cpp @@ -751,16 +751,14 @@ Remark: Returns a new TupleId to the application. The TupleId comes from SYSTAB_0 where SYSKEY_0 = TableId. It is initialized to (TableId << 48) + 1 in NdbcntrMain.cpp. ****************************************************************************/ -#define DEBUG_TRACE(msg) \ -// ndbout << __FILE__ << " line: " << __LINE__ << " msg: " << msg << endl - Uint64 Ndb::getAutoIncrementValue(const char* aTableName, Uint32 cacheSize) { DBUG_ENTER("getAutoIncrementValue"); - const char * internalTableName = internalizeTableName(aTableName); + BaseString internal_tabname(internalize_table_name(aTableName)); + Ndb_local_table_info *info= - theDictionary->get_local_table_info(internalTableName, false); + theDictionary->get_local_table_info(internal_tabname, false); if (info == 0) DBUG_RETURN(~(Uint64)0); const NdbTableImpl *table= info->m_table_impl; @@ -812,7 +810,7 @@ Ndb::getTupleIdFromNdb(Uint32 aTableId, Uint32 cacheSize) Uint64 Ndb::readAutoIncrementValue(const char* aTableName) { - DBUG_ENTER("readtAutoIncrementValue"); + DBUG_ENTER("readAutoIncrementValue"); const NdbTableImpl* table = theDictionary->getTable(aTableName); if (table == 0) { theError= theDictionary->getNdbError(); @@ -826,7 +824,7 @@ Ndb::readAutoIncrementValue(const char* aTableName) Uint64 Ndb::readAutoIncrementValue(const NdbDictionary::Table * aTable) { - DBUG_ENTER("readtAutoIncrementValue"); + DBUG_ENTER("readAutoIncrementValue"); if (aTable == 0) DBUG_RETURN(~(Uint64)0); const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable); @@ -848,62 +846,63 @@ Ndb::readTupleIdFromNdb(Uint32 aTableId) bool Ndb::setAutoIncrementValue(const char* aTableName, Uint64 val, bool increase) { - DEBUG_TRACE("setAutoIncrementValue " << val); - const char * internalTableName= internalizeTableName(aTableName); + DBUG_ENTER("setAutoIncrementValue"); + BaseString internal_tabname(internalize_table_name(aTableName)); + Ndb_local_table_info *info= - theDictionary->get_local_table_info(internalTableName, false); + theDictionary->get_local_table_info(internal_tabname, false); if (info == 0) { theError= theDictionary->getNdbError(); - return false; + DBUG_RETURN(false); } const NdbTableImpl* table= info->m_table_impl; - return setTupleIdInNdb(table->m_tableId, val, increase); + DBUG_RETURN(setTupleIdInNdb(table->m_tableId, val, increase)); } bool Ndb::setAutoIncrementValue(const NdbDictionary::Table * aTable, Uint64 val, bool increase) { - DEBUG_TRACE("setAutoIncrementValue " << val); + DBUG_ENTER("setAutoIncrementValue"); if (aTable == 0) - return ~(Uint64)0; + DBUG_RETURN(~(Uint64)0); const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable); - return setTupleIdInNdb(table->m_tableId, val, increase); + DBUG_RETURN(setTupleIdInNdb(table->m_tableId, val, increase)); } -bool +bool Ndb::setTupleIdInNdb(const char* aTableName, Uint64 val, bool increase ) { - DEBUG_TRACE("setTupleIdInNdb"); + DBUG_ENTER("setTupleIdInNdb(const char*, ...)"); const NdbTableImpl* table = theDictionary->getTable(aTableName); if (table == 0) { theError= theDictionary->getNdbError(); - return false; + DBUG_RETURN(false); } - return setTupleIdInNdb(table->m_tableId, val, increase); + DBUG_RETURN(setTupleIdInNdb(table->m_tableId, val, increase)); } bool Ndb::setTupleIdInNdb(Uint32 aTableId, Uint64 val, bool increase ) { - DEBUG_TRACE("setTupleIdInNdb"); + DBUG_ENTER("setTupleIdInNdb(Uint32, ...)"); if (increase) { if (theFirstTupleId[aTableId] != theLastTupleId[aTableId]) { // We have a cache sequence if (val <= theFirstTupleId[aTableId]+1) - return false; + DBUG_RETURN(false); if (val <= theLastTupleId[aTableId]) { theFirstTupleId[aTableId] = val - 1; - return true; + DBUG_RETURN(true); } // else continue; - } - return (opTupleIdOnNdb(aTableId, val, 2) == val); + } + DBUG_RETURN((opTupleIdOnNdb(aTableId, val, 2) == val)); } else - return (opTupleIdOnNdb(aTableId, val, 1) == val); + DBUG_RETURN((opTupleIdOnNdb(aTableId, val, 1) == val)); } Uint64 @@ -1143,25 +1142,63 @@ Ndb::externalizeIndexName(const char * internalIndexName) return externalizeIndexName(internalIndexName, usingFullyQualifiedNames()); } -const char * -Ndb::internalizeTableName(const char * externalTableName) + +const BaseString +Ndb::internalize_table_name(const char *external_name) const { + BaseString ret; + DBUG_ENTER("internalize_table_name"); + DBUG_PRINT("enter", ("external_name: %s", external_name)); + if (fullyQualifiedNames) - return theImpl->internalize_table_name(externalTableName); + { + /* Internal table name format <db>/<schema>/<table> + <db>/<schema> is already available in m_prefix + so just concat the two strings + */ + ret.assfmt("%s%s", + theImpl->m_prefix.c_str(), + external_name); + } else - return externalTableName; + ret.assign(external_name); + + DBUG_PRINT("exit", ("internal_name: %s", ret.c_str())); + DBUG_RETURN(ret); } - -const char * -Ndb::internalizeIndexName(const NdbTableImpl * table, - const char * externalIndexName) + + +const BaseString +Ndb::internalize_index_name(const NdbTableImpl * table, + const char * external_name) const { + BaseString ret; + DBUG_ENTER("internalize_index_name"); + DBUG_PRINT("enter", ("external_name: %s, table_id: %d", + external_name, table ? table->m_tableId : ~0)); + if (!table) + { + DBUG_PRINT("error", ("!table")); + return ret; + } + if (fullyQualifiedNames) - return theImpl->internalize_index_name(table, externalIndexName); + { + /* Internal index name format <db>/<schema>/<tabid>/<table> */ + ret.assfmt("%s%d%c%s", + theImpl->m_prefix.c_str(), + table->m_tableId, + table_name_separator, + external_name); + } else - return externalIndexName; + ret.assign(external_name); + + DBUG_PRINT("exit", ("internal_name: %s", ret.c_str())); + DBUG_RETURN(ret); } + const BaseString Ndb::getDatabaseFromInternalName(const char * internalName) { diff --git a/storage/ndb/src/ndbapi/NdbBlob.cpp b/storage/ndb/src/ndbapi/NdbBlob.cpp index 0638f6e4c51..d06d6b4ef4d 100644 --- a/storage/ndb/src/ndbapi/NdbBlob.cpp +++ b/storage/ndb/src/ndbapi/NdbBlob.cpp @@ -24,34 +24,6 @@ #include "NdbBlobImpl.hpp" #include <NdbScanOperation.hpp> -#ifdef NDB_BLOB_DEBUG -#define DBG(x) \ - do { \ - static const char* p = getenv("NDB_BLOB_DEBUG"); \ - if (p == 0 || *p == 0 || *p == '0') break; \ - static char* prefix = "BLOB"; \ - const char* cname = theColumn == NULL ? "-" : theColumn->m_name.c_str(); \ - ndbout << prefix << " " << hex << (void*)this << " " << cname; \ - ndbout << " " << dec << __LINE__ << " " << x << " " << *this << endl; \ - } while (0) - -static char* -ndb_blob_debug(const Uint32* data, unsigned size) -{ - static char buf[200]; // MT irrelevant - buf[0] = 0; - for (unsigned i = 0; i < size; i++) { - unsigned n = strlen(buf); - if (n + 10 < sizeof(buf)) - sprintf(buf + n, "%*s%08x", i != 0, "", data[i]); - } - return buf; -} - -#else -#define DBG(x) -#endif - /* * Reading index table directly (as a table) is faster but there are * bugs or limitations. Keep the code and make possible to choose. @@ -63,8 +35,10 @@ static const bool g_ndb_blob_ok_to_read_index_table = false; inline void NdbBlob::setState(State newState) { - DBG("setState " << newState); + DBUG_ENTER("NdbBlob::setState"); + DBUG_PRINT("info", ("this=%p newState=%u", this, newState)); theState = newState; + DBUG_VOID_RETURN; } // define blob table @@ -319,9 +293,9 @@ NdbBlob::getDistKey(Uint32 part) int NdbBlob::getTableKeyValue(NdbOperation* anOp) { + DBUG_ENTER("NdbBlob::getTableKeyValue"); Uint32* data = (Uint32*)theKeyBuf.data; unsigned pos = 0; - DBG("getTableKeyValue"); for (unsigned i = 0; i < theTable->m_columns.size(); i++) { NdbColumnImpl* c = theTable->m_columns[i]; assert(c != NULL); @@ -329,7 +303,7 @@ NdbBlob::getTableKeyValue(NdbOperation* anOp) unsigned len = c->m_attrSize * c->m_arraySize; if (anOp->getValue_impl(c, (char*)&data[pos]) == NULL) { setErrorCode(anOp); - return -1; + DBUG_RETURN(-1); } // odd bytes receive no data and must be zeroed while (len % 4 != 0) { @@ -340,14 +314,15 @@ NdbBlob::getTableKeyValue(NdbOperation* anOp) } } assert(pos == theKeyBuf.size / 4); - return 0; + DBUG_RETURN(0); } int NdbBlob::setTableKeyValue(NdbOperation* anOp) { + DBUG_ENTER("NdbBlob::setTableKeyValue"); + DBUG_DUMP("info", theKeyBuf.data, 4 * theTable->m_keyLenInWords); const Uint32* data = (const Uint32*)theKeyBuf.data; - DBG("setTableKeyValue key=" << ndb_blob_debug(data, theTable->m_keyLenInWords)); const unsigned columns = theTable->m_columns.size(); unsigned pos = 0; for (unsigned i = 0; i < columns; i++) { @@ -357,20 +332,21 @@ NdbBlob::setTableKeyValue(NdbOperation* anOp) unsigned len = c->m_attrSize * c->m_arraySize; if (anOp->equal_impl(c, (const char*)&data[pos], len) == -1) { setErrorCode(anOp); - return -1; + DBUG_RETURN(-1); } pos += (len + 3) / 4; } } assert(pos == theKeyBuf.size / 4); - return 0; + DBUG_RETURN(0); } int NdbBlob::setAccessKeyValue(NdbOperation* anOp) { + DBUG_ENTER("NdbBlob::setAccessKeyValue"); + DBUG_DUMP("info", theAccessKeyBuf.data, 4 * theAccessTable->m_keyLenInWords); const Uint32* data = (const Uint32*)theAccessKeyBuf.data; - DBG("setAccessKeyValue key=" << ndb_blob_debug(data, theAccessTable->m_keyLenInWords)); const unsigned columns = theAccessTable->m_columns.size(); unsigned pos = 0; for (unsigned i = 0; i < columns; i++) { @@ -380,57 +356,60 @@ NdbBlob::setAccessKeyValue(NdbOperation* anOp) unsigned len = c->m_attrSize * c->m_arraySize; if (anOp->equal_impl(c, (const char*)&data[pos], len) == -1) { setErrorCode(anOp); - return -1; + DBUG_RETURN(-1); } pos += (len + 3) / 4; } } assert(pos == theAccessKeyBuf.size / 4); - return 0; + DBUG_RETURN(0); } int NdbBlob::setPartKeyValue(NdbOperation* anOp, Uint32 part) { + DBUG_ENTER("NdbBlob::setPartKeyValue"); + DBUG_PRINT("info", ("dist=%u part=%u key=", getDistKey(part), part)); + DBUG_DUMP("info", theKeyBuf.data, 4 * theTable->m_keyLenInWords); Uint32* data = (Uint32*)theKeyBuf.data; unsigned size = theTable->m_keyLenInWords; - DBG("setPartKeyValue dist=" << getDistKey(part) << " part=" << part << " key=" << ndb_blob_debug(data, size)); // TODO use attr ids after compatibility with 4.1.7 not needed if (anOp->equal("PK", theKeyBuf.data) == -1 || anOp->equal("DIST", getDistKey(part)) == -1 || anOp->equal("PART", part) == -1) { setErrorCode(anOp); - return -1; + DBUG_RETURN(-1); } - return 0; + DBUG_RETURN(0); } int NdbBlob::getHeadInlineValue(NdbOperation* anOp) { - DBG("getHeadInlineValue"); + DBUG_ENTER("NdbBlob::getHeadInlineValue"); theHeadInlineRecAttr = anOp->getValue_impl(theColumn, theHeadInlineBuf.data); if (theHeadInlineRecAttr == NULL) { setErrorCode(anOp); - return -1; + DBUG_RETURN(-1); } - return 0; + DBUG_RETURN(0); } void NdbBlob::getHeadFromRecAttr() { + DBUG_ENTER("NdbBlob::getHeadFromRecAttr"); assert(theHeadInlineRecAttr != NULL); theNullFlag = theHeadInlineRecAttr->isNULL(); assert(theNullFlag != -1); theLength = ! theNullFlag ? theHead->length : 0; - DBG("getHeadFromRecAttr [out]"); + DBUG_VOID_RETURN; } int NdbBlob::setHeadInlineValue(NdbOperation* anOp) { - DBG("setHeadInlineValue"); + DBUG_ENTER("NdbBlob::setHeadInlineValue"); theHead->length = theLength; if (theLength < theInlineSize) memset(theInlineData + theLength, 0, theInlineSize - theLength); @@ -438,10 +417,10 @@ NdbBlob::setHeadInlineValue(NdbOperation* anOp) const char* aValue = theNullFlag ? 0 : theHeadInlineBuf.data; if (anOp->setValue(theColumn, aValue, theHeadInlineBuf.size) == -1) { setErrorCode(anOp); - return -1; + DBUG_RETURN(-1); } theHeadInlineUpdateFlag = false; - return 0; + DBUG_RETURN(0); } // getValue/setValue @@ -449,40 +428,42 @@ NdbBlob::setHeadInlineValue(NdbOperation* anOp) int NdbBlob::getValue(void* data, Uint32 bytes) { - DBG("getValue data=" << hex << data << " bytes=" << dec << bytes); + DBUG_ENTER("NdbBlob::getValue"); + DBUG_PRINT("info", ("data=%p bytes=%u", data, bytes)); if (theGetFlag || theState != Prepared) { setErrorCode(NdbBlobImpl::ErrState); - return -1; + DBUG_RETURN(-1); } if (! isReadOp() && ! isScanOp()) { setErrorCode(NdbBlobImpl::ErrUsage); - return -1; + DBUG_RETURN(-1); } if (data == NULL && bytes != 0) { setErrorCode(NdbBlobImpl::ErrUsage); - return -1; + DBUG_RETURN(-1); } theGetFlag = true; theGetBuf = static_cast<char*>(data); theGetSetBytes = bytes; - return 0; + DBUG_RETURN(0); } int NdbBlob::setValue(const void* data, Uint32 bytes) { - DBG("setValue data=" << hex << data << " bytes=" << dec << bytes); + DBUG_ENTER("NdbBlob::setValue"); + DBUG_PRINT("info", ("data=%p bytes=%u", data, bytes)); if (theSetFlag || theState != Prepared) { setErrorCode(NdbBlobImpl::ErrState); - return -1; + DBUG_RETURN(-1); } if (! isInsertOp() && ! isUpdateOp() && ! isWriteOp()) { setErrorCode(NdbBlobImpl::ErrUsage); - return -1; + DBUG_RETURN(-1); } if (data == NULL && bytes != 0) { setErrorCode(NdbBlobImpl::ErrUsage); - return -1; + DBUG_RETURN(-1); } theSetFlag = true; theSetBuf = static_cast<const char*>(data); @@ -495,15 +476,15 @@ NdbBlob::setValue(const void* data, Uint32 bytes) n = theInlineSize; assert(thePos == 0); if (writeDataPrivate(theSetBuf, n) == -1) - return -1; + DBUG_RETURN(-1); } else { theNullFlag = true; theLength = 0; } if (setHeadInlineValue(theNdbOp) == -1) - return -1; + DBUG_RETURN(-1); } - return 0; + DBUG_RETURN(0); } // activation hook @@ -511,14 +492,15 @@ NdbBlob::setValue(const void* data, Uint32 bytes) int NdbBlob::setActiveHook(ActiveHook activeHook, void* arg) { - DBG("setActiveHook hook=" << hex << (void*)activeHook << " arg=" << hex << arg); + DBUG_ENTER("NdbBlob::setActiveHook"); + DBUG_PRINT("info", ("hook=%p arg=%p", (void*)activeHook, arg)); if (theState != Prepared) { setErrorCode(NdbBlobImpl::ErrState); - return -1; + DBUG_RETURN(-1); } theActiveHook = activeHook; theActiveHookArg = arg; - return 0; + DBUG_RETURN(0); } // misc operations @@ -526,63 +508,64 @@ NdbBlob::setActiveHook(ActiveHook activeHook, void* arg) int NdbBlob::getNull(bool& isNull) { - DBG("getNull"); + DBUG_ENTER("NdbBlob::getNull"); if (theState == Prepared && theSetFlag) { isNull = (theSetBuf == NULL); - return 0; + DBUG_RETURN(0); } if (theNullFlag == -1) { setErrorCode(NdbBlobImpl::ErrState); - return -1; + DBUG_RETURN(-1); } isNull = theNullFlag; - return 0; + DBUG_RETURN(0); } int NdbBlob::setNull() { - DBG("setNull"); + DBUG_ENTER("NdbBlob::setNull"); if (theNullFlag == -1) { if (theState == Prepared) { - return setValue(0, 0); + DBUG_RETURN(setValue(0, 0)); } setErrorCode(NdbBlobImpl::ErrState); - return -1; + DBUG_RETURN(-1); } if (theNullFlag) - return 0; + DBUG_RETURN(0); if (deleteParts(0, getPartCount()) == -1) - return -1; + DBUG_RETURN(-1); theNullFlag = true; theLength = 0; theHeadInlineUpdateFlag = true; - return 0; + DBUG_RETURN(0); } int NdbBlob::getLength(Uint64& len) { - DBG("getLength"); + DBUG_ENTER("NdbBlob::getLength"); if (theState == Prepared && theSetFlag) { len = theGetSetBytes; - return 0; + DBUG_RETURN(0); } if (theNullFlag == -1) { setErrorCode(NdbBlobImpl::ErrState); - return -1; + DBUG_RETURN(-1); } len = theLength; - return 0; + DBUG_RETURN(0); } int NdbBlob::truncate(Uint64 length) { - DBG("truncate [in] length=" << length); + DBUG_ENTER("NdbBlob::truncate"); + DBUG_PRINT("info", ("length=%llu", length)); if (theNullFlag == -1) { setErrorCode(NdbBlobImpl::ErrState); - return -1; + DBUG_RETURN(-1); } if (theLength > length) { if (length > theInlineSize) { @@ -590,46 +573,46 @@ NdbBlob::truncate(Uint64 length) Uint32 part2 = getPartNumber(theLength - 1); assert(part2 >= part1); if (part2 > part1 && deleteParts(part1 + 1, part2 - part1) == -1) - return -1; + DBUG_RETURN(-1); } else { if (deleteParts(0, getPartCount()) == -1) - return -1; + DBUG_RETURN(-1); } theLength = length; theHeadInlineUpdateFlag = true; if (thePos > length) thePos = length; } - DBG("truncate [out]"); - return 0; + DBUG_RETURN(0); } int NdbBlob::getPos(Uint64& pos) { - DBG("getPos"); + DBUG_ENTER("NdbBlob::getPos"); if (theNullFlag == -1) { setErrorCode(NdbBlobImpl::ErrState); - return -1; + DBUG_RETURN(-1); } pos = thePos; - return 0; + DBUG_RETURN(0); } int NdbBlob::setPos(Uint64 pos) { - DBG("setPos pos=" << pos); + DBUG_ENTER("NdbBlob::setPos"); + DBUG_PRINT("info", ("pos=%llu", pos)); if (theNullFlag == -1) { setErrorCode(NdbBlobImpl::ErrState); - return -1; + DBUG_RETURN(-1); } if (pos > theLength) { setErrorCode(NdbBlobImpl::ErrSeek); - return -1; + DBUG_RETURN(-1); } thePos = pos; - return 0; + DBUG_RETURN(0); } // read/write @@ -648,7 +631,8 @@ NdbBlob::readData(void* data, Uint32& bytes) int NdbBlob::readDataPrivate(char* buf, Uint32& bytes) { - DBG("readData [in] bytes=" << bytes); + DBUG_ENTER("NdbBlob::readDataPrivate"); + DBUG_PRINT("info", ("bytes=%u", bytes)); assert(thePos <= theLength); Uint64 pos = thePos; if (bytes > theLength - pos) @@ -668,20 +652,20 @@ NdbBlob::readDataPrivate(char* buf, Uint32& bytes) } if (len > 0 && thePartSize == 0) { setErrorCode(NdbBlobImpl::ErrSeek); - return -1; + DBUG_RETURN(-1); } if (len > 0) { assert(pos >= theInlineSize); Uint32 off = (pos - theInlineSize) % thePartSize; // partial first block if (off != 0) { - DBG("partial first block pos=" << pos << " len=" << len); + DBUG_PRINT("info", ("partial first block pos=%llu len=%u", pos, len)); Uint32 part = (pos - theInlineSize) / thePartSize; if (readParts(thePartBuf.data, part, 1) == -1) - return -1; + DBUG_RETURN(-1); // need result now if (executePendingBlobReads() == -1) - return -1; + DBUG_RETURN(-1); Uint32 n = thePartSize - off; if (n > len) n = len; @@ -698,7 +682,7 @@ NdbBlob::readDataPrivate(char* buf, Uint32& bytes) Uint32 part = (pos - theInlineSize) / thePartSize; Uint32 count = len / thePartSize; if (readParts(buf, part, count) == -1) - return -1; + DBUG_RETURN(-1); Uint32 n = thePartSize * count; pos += n; buf += n; @@ -707,14 +691,14 @@ NdbBlob::readDataPrivate(char* buf, Uint32& bytes) } if (len > 0) { // partial last block - DBG("partial last block pos=" << pos << " len=" << len); + DBUG_PRINT("info", ("partial last block pos=%llu len=%u", pos, len)); assert((pos - theInlineSize) % thePartSize == 0 && len < thePartSize); Uint32 part = (pos - theInlineSize) / thePartSize; if (readParts(thePartBuf.data, part, 1) == -1) - return -1; + DBUG_RETURN(-1); // need result now if (executePendingBlobReads() == -1) - return -1; + DBUG_RETURN(-1); memcpy(buf, thePartBuf.data, len); Uint32 n = len; pos += n; @@ -724,8 +708,7 @@ NdbBlob::readDataPrivate(char* buf, Uint32& bytes) assert(len == 0); thePos = pos; assert(thePos <= theLength); - DBG("readData [out]"); - return 0; + DBUG_RETURN(0); } int @@ -742,7 +725,8 @@ NdbBlob::writeData(const void* data, Uint32 bytes) int NdbBlob::writeDataPrivate(const char* buf, Uint32 bytes) { - DBG("writeData [in] bytes=" << bytes); + DBUG_ENTER("NdbBlob::writeDataPrivate"); + DBUG_PRINT("info", ("bytes=%u", bytes)); assert(thePos <= theLength); Uint64 pos = thePos; Uint32 len = bytes; @@ -766,23 +750,23 @@ NdbBlob::writeDataPrivate(const char* buf, Uint32 bytes) } if (len > 0 && thePartSize == 0) { setErrorCode(NdbBlobImpl::ErrSeek); - return -1; + DBUG_RETURN(-1); } if (len > 0) { assert(pos >= theInlineSize); Uint32 off = (pos - theInlineSize) % thePartSize; // partial first block if (off != 0) { - DBG("partial first block pos=" << pos << " len=" << len); + DBUG_PRINT("info", ("partial first block pos=%llu len=%u", pos, len)); // flush writes to guarantee correct read if (executePendingBlobWrites() == -1) - return -1; + DBUG_RETURN(-1); Uint32 part = (pos - theInlineSize) / thePartSize; if (readParts(thePartBuf.data, part, 1) == -1) - return -1; + DBUG_RETURN(-1); // need result now if (executePendingBlobReads() == -1) - return -1; + DBUG_RETURN(-1); Uint32 n = thePartSize - off; if (n > len) { memset(thePartBuf.data + off + len, theFillChar, n - len); @@ -790,7 +774,7 @@ NdbBlob::writeDataPrivate(const char* buf, Uint32 bytes) } memcpy(thePartBuf.data + off, buf, n); if (updateParts(thePartBuf.data, part, 1) == -1) - return -1; + DBUG_RETURN(-1); pos += n; buf += n; len -= n; @@ -805,10 +789,10 @@ NdbBlob::writeDataPrivate(const char* buf, Uint32 bytes) for (unsigned i = 0; i < count; i++) { if (part + i < getPartCount()) { if (updateParts(buf, part + i, 1) == -1) - return -1; + DBUG_RETURN(-1); } else { if (insertParts(buf, part + i, 1) == -1) - return -1; + DBUG_RETURN(-1); } Uint32 n = thePartSize; pos += n; @@ -819,30 +803,30 @@ NdbBlob::writeDataPrivate(const char* buf, Uint32 bytes) } if (len > 0) { // partial last block - DBG("partial last block pos=" << pos << " len=" << len); + DBUG_PRINT("info", ("partial last block pos=%llu len=%u", pos, len)); assert((pos - theInlineSize) % thePartSize == 0 && len < thePartSize); Uint32 part = (pos - theInlineSize) / thePartSize; if (theLength > pos + len) { // flush writes to guarantee correct read if (executePendingBlobWrites() == -1) - return -1; + DBUG_RETURN(-1); if (readParts(thePartBuf.data, part, 1) == -1) - return -1; + DBUG_RETURN(-1); // need result now if (executePendingBlobReads() == -1) - return -1; + DBUG_RETURN(-1); memcpy(thePartBuf.data, buf, len); if (updateParts(thePartBuf.data, part, 1) == -1) - return -1; + DBUG_RETURN(-1); } else { memcpy(thePartBuf.data, buf, len); memset(thePartBuf.data + len, theFillChar, thePartSize - len); if (part < getPartCount()) { if (updateParts(thePartBuf.data, part, 1) == -1) - return -1; + DBUG_RETURN(-1); } else { if (insertParts(thePartBuf.data, part, 1) == -1) - return -1; + DBUG_RETURN(-1); } } Uint32 n = len; @@ -857,14 +841,14 @@ NdbBlob::writeDataPrivate(const char* buf, Uint32 bytes) } thePos = pos; assert(thePos <= theLength); - DBG("writeData [out]"); - return 0; + DBUG_RETURN(0); } int NdbBlob::readParts(char* buf, Uint32 part, Uint32 count) { - DBG("readParts [in] part=" << part << " count=" << count); + DBUG_ENTER("NdbBlob::readParts"); + DBUG_PRINT("info", ("part=%u count=%u", part, count)); Uint32 n = 0; while (n < count) { NdbOperation* tOp = theNdbCon->getNdbOperation(theBlobTable); @@ -873,7 +857,7 @@ NdbBlob::readParts(char* buf, Uint32 part, Uint32 count) setPartKeyValue(tOp, part + n) == -1 || tOp->getValue((Uint32)3, buf) == NULL) { setErrorCode(tOp); - return -1; + DBUG_RETURN(-1); } tOp->m_abortOption = NdbTransaction::AbortOnError; buf += thePartSize; @@ -881,13 +865,14 @@ NdbBlob::readParts(char* buf, Uint32 part, Uint32 count) thePendingBlobOps |= (1 << NdbOperation::ReadRequest); theNdbCon->thePendingBlobOps |= (1 << NdbOperation::ReadRequest); } - return 0; + DBUG_RETURN(0); } int NdbBlob::insertParts(const char* buf, Uint32 part, Uint32 count) { - DBG("insertParts [in] part=" << part << " count=" << count); + DBUG_ENTER("NdbBlob::insertParts"); + DBUG_PRINT("info", ("part=%u count=%u", part, count)); Uint32 n = 0; while (n < count) { NdbOperation* tOp = theNdbCon->getNdbOperation(theBlobTable); @@ -896,7 +881,7 @@ NdbBlob::insertParts(const char* buf, Uint32 part, Uint32 count) setPartKeyValue(tOp, part + n) == -1 || tOp->setValue((Uint32)3, buf) == -1) { setErrorCode(tOp); - return -1; + DBUG_RETURN(-1); } tOp->m_abortOption = NdbTransaction::AbortOnError; buf += thePartSize; @@ -904,13 +889,14 @@ NdbBlob::insertParts(const char* buf, Uint32 part, Uint32 count) thePendingBlobOps |= (1 << NdbOperation::InsertRequest); theNdbCon->thePendingBlobOps |= (1 << NdbOperation::InsertRequest); } - return 0; + DBUG_RETURN(0); } int NdbBlob::updateParts(const char* buf, Uint32 part, Uint32 count) { - DBG("updateParts [in] part=" << part << " count=" << count); + DBUG_ENTER("NdbBlob::updateParts"); + DBUG_PRINT("info", ("part=%u count=%u", part, count)); Uint32 n = 0; while (n < count) { NdbOperation* tOp = theNdbCon->getNdbOperation(theBlobTable); @@ -919,7 +905,7 @@ NdbBlob::updateParts(const char* buf, Uint32 part, Uint32 count) setPartKeyValue(tOp, part + n) == -1 || tOp->setValue((Uint32)3, buf) == -1) { setErrorCode(tOp); - return -1; + DBUG_RETURN(-1); } tOp->m_abortOption = NdbTransaction::AbortOnError; buf += thePartSize; @@ -927,13 +913,14 @@ NdbBlob::updateParts(const char* buf, Uint32 part, Uint32 count) thePendingBlobOps |= (1 << NdbOperation::UpdateRequest); theNdbCon->thePendingBlobOps |= (1 << NdbOperation::UpdateRequest); } - return 0; + DBUG_RETURN(0); } int NdbBlob::deleteParts(Uint32 part, Uint32 count) { - DBG("deleteParts [in] part=" << part << " count=" << count); + DBUG_ENTER("NdbBlob::deleteParts"); + DBUG_PRINT("info", ("part=%u count=%u", part, count)); Uint32 n = 0; while (n < count) { NdbOperation* tOp = theNdbCon->getNdbOperation(theBlobTable); @@ -941,14 +928,14 @@ NdbBlob::deleteParts(Uint32 part, Uint32 count) tOp->deleteTuple() == -1 || setPartKeyValue(tOp, part + n) == -1) { setErrorCode(tOp); - return -1; + DBUG_RETURN(-1); } tOp->m_abortOption = NdbTransaction::AbortOnError; n++; thePendingBlobOps |= (1 << NdbOperation::DeleteRequest); theNdbCon->thePendingBlobOps |= (1 << NdbOperation::DeleteRequest); } - return 0; + DBUG_RETURN(0); } /* @@ -958,7 +945,8 @@ NdbBlob::deleteParts(Uint32 part, Uint32 count) int NdbBlob::deletePartsUnknown(Uint32 part) { - DBG("deletePartsUnknown [in] part=" << part << " count=all"); + DBUG_ENTER("NdbBlob::deletePartsUnknown"); + DBUG_PRINT("info", ("part=%u count=all", part)); static const unsigned maxbat = 256; static const unsigned minbat = 1; unsigned bat = minbat; @@ -974,26 +962,25 @@ NdbBlob::deletePartsUnknown(Uint32 part) tOp->deleteTuple() == -1 || setPartKeyValue(tOp, part + count + n) == -1) { setErrorCode(tOp); - return -1; + DBUG_RETURN(-1); } tOp->m_abortOption= NdbTransaction::AO_IgnoreError; n++; } - DBG("deletePartsUnknown: executeNoBlobs [in] bat=" << bat); + DBUG_PRINT("info", ("bat=%u", bat)); if (theNdbCon->executeNoBlobs(NdbTransaction::NoCommit) == -1) - return -1; - DBG("deletePartsUnknown: executeNoBlobs [out]"); + DBUG_RETURN(-1); n = 0; while (n < bat) { NdbOperation* tOp = tOpList[n]; if (tOp->theError.code != 0) { if (tOp->theError.code != 626) { setErrorCode(tOp); - return -1; + DBUG_RETURN(-1); } // first non-existent part - DBG("deletePartsUnknown [out] count=" << count); - return 0; + DBUG_PRINT("info", ("count=%u", count)); + DBUG_RETURN(0); } n++; count++; @@ -1009,31 +996,29 @@ NdbBlob::deletePartsUnknown(Uint32 part) int NdbBlob::executePendingBlobReads() { + DBUG_ENTER("NdbBlob::executePendingBlobReads"); Uint8 flags = (1 << NdbOperation::ReadRequest); if (thePendingBlobOps & flags) { - DBG("executePendingBlobReads: executeNoBlobs [in]"); if (theNdbCon->executeNoBlobs(NdbTransaction::NoCommit) == -1) - return -1; - DBG("executePendingBlobReads: executeNoBlobs [out]"); + DBUG_RETURN(-1); thePendingBlobOps = 0; theNdbCon->thePendingBlobOps = 0; } - return 0; + DBUG_RETURN(0); } int NdbBlob::executePendingBlobWrites() { + DBUG_ENTER("NdbBlob::executePendingBlobWrites"); Uint8 flags = 0xFF & ~(1 << NdbOperation::ReadRequest); if (thePendingBlobOps & flags) { - DBG("executePendingBlobWrites: executeNoBlobs [in]"); if (theNdbCon->executeNoBlobs(NdbTransaction::NoCommit) == -1) - return -1; - DBG("executePendingBlobWrites: executeNoBlobs [out]"); + DBUG_RETURN(-1); thePendingBlobOps = 0; theNdbCon->thePendingBlobOps = 0; } - return 0; + DBUG_RETURN(0); } // callbacks @@ -1041,15 +1026,14 @@ NdbBlob::executePendingBlobWrites() int NdbBlob::invokeActiveHook() { - DBG("invokeActiveHook [in]"); + DBUG_ENTER("NdbBlob::invokeActiveHook"); assert(theState == Active && theActiveHook != NULL); int ret = (*theActiveHook)(this, theActiveHookArg); - DBG("invokeActiveHook [out] ret=" << ret); if (ret != 0) { // no error is set on blob level - return -1; + DBUG_RETURN(-1); } - return 0; + DBUG_RETURN(0); } // blob handle maintenance @@ -1062,6 +1046,8 @@ NdbBlob::invokeActiveHook() int NdbBlob::atPrepare(NdbTransaction* aCon, NdbOperation* anOp, const NdbColumnImpl* aColumn) { + DBUG_ENTER("NdbBlob::atPrepare"); + DBUG_PRINT("info", ("this=%p op=%p con=%p", this, anOp, aCon)); assert(theState == Idle); // ndb api stuff theNdb = anOp->theNdb; @@ -1070,7 +1056,6 @@ NdbBlob::atPrepare(NdbTransaction* aCon, NdbOperation* anOp, const NdbColumnImpl theTable = anOp->m_currentTable; theAccessTable = anOp->m_accessTable; theColumn = aColumn; - DBG("atPrepare [in]"); NdbDictionary::Column::Type partType = NdbDictionary::Column::Undefined; switch (theColumn->getType()) { case NdbDictionary::Column::Blob: @@ -1083,7 +1068,7 @@ NdbBlob::atPrepare(NdbTransaction* aCon, NdbOperation* anOp, const NdbColumnImpl break; default: setErrorCode(NdbBlobImpl::ErrUsage); - return -1; + DBUG_RETURN(-1); } // sizes theInlineSize = theColumn->getInlineSize(); @@ -1101,7 +1086,7 @@ NdbBlob::atPrepare(NdbTransaction* aCon, NdbOperation* anOp, const NdbColumnImpl bc->getType() != partType || bc->getLength() != (int)thePartSize) { setErrorCode(NdbBlobImpl::ErrTable); - return -1; + DBUG_RETURN(-1); } theBlobTable = &NdbTableImpl::getImpl(*bt); } @@ -1122,7 +1107,7 @@ NdbBlob::atPrepare(NdbTransaction* aCon, NdbOperation* anOp, const NdbColumnImpl unsigned size = theTable->m_keyLenInWords; if (theNdbOp->getKeyFromTCREQ(data, size) == -1) { setErrorCode(NdbBlobImpl::ErrUsage); - return -1; + DBUG_RETURN(-1); } } if (isIndexOp()) { @@ -1131,13 +1116,13 @@ NdbBlob::atPrepare(NdbTransaction* aCon, NdbOperation* anOp, const NdbColumnImpl unsigned size = theAccessTable->m_keyLenInWords; if (theNdbOp->getKeyFromTCREQ(data, size) == -1) { setErrorCode(NdbBlobImpl::ErrUsage); - return -1; + DBUG_RETURN(-1); } } if (isReadOp()) { // add read of head+inline in this op if (getHeadInlineValue(theNdbOp) == -1) - return -1; + DBUG_RETURN(-1); } if (isInsertOp()) { // becomes NULL unless set before execute @@ -1155,16 +1140,15 @@ NdbBlob::atPrepare(NdbTransaction* aCon, NdbOperation* anOp, const NdbColumnImpl if (isScanOp()) { // add read of head+inline in this op if (getHeadInlineValue(theNdbOp) == -1) - return -1; + DBUG_RETURN(-1); supportedOp = true; } if (! supportedOp) { setErrorCode(NdbBlobImpl::ErrUsage); - return -1; + DBUG_RETURN(-1); } setState(Prepared); - DBG("atPrepare [out]"); - return 0; + DBUG_RETURN(0); } /* @@ -1177,9 +1161,10 @@ NdbBlob::atPrepare(NdbTransaction* aCon, NdbOperation* anOp, const NdbColumnImpl int NdbBlob::preExecute(NdbTransaction::ExecType anExecType, bool& batch) { - DBG("preExecute [in]"); + DBUG_ENTER("NdbBlob::preExecute"); + DBUG_PRINT("info", ("this=%p op=%p con=%p", this, theNdbOp, theNdbCon)); if (theState == Invalid) - return -1; + DBUG_RETURN(-1); assert(theState == Prepared); // handle different operation types assert(isKeyOp()); @@ -1197,7 +1182,7 @@ NdbBlob::preExecute(NdbTransaction::ExecType anExecType, bool& batch) Uint32 bytes = theGetSetBytes - theInlineSize; assert(thePos == theInlineSize); if (writeDataPrivate(buf, bytes) == -1) - return -1; + DBUG_RETURN(-1); if (theHeadInlineUpdateFlag) { // add an operation to update head+inline NdbOperation* tOp = theNdbCon->getNdbOperation(theTable); @@ -1206,9 +1191,9 @@ NdbBlob::preExecute(NdbTransaction::ExecType anExecType, bool& batch) setTableKeyValue(tOp) == -1 || setHeadInlineValue(tOp) == -1) { setErrorCode(NdbBlobImpl::ErrAbort); - return -1; + DBUG_RETURN(-1); } - DBG("add op to update head+inline"); + DBUG_PRINT("info", ("add op to update head+inline")); } } } @@ -1221,7 +1206,7 @@ NdbBlob::preExecute(NdbTransaction::ExecType anExecType, bool& batch) setTableKeyValue(tOp) == -1 || getHeadInlineValue(tOp) == -1) { setErrorCode(tOp); - return -1; + DBUG_RETURN(-1); } if (isWriteOp()) { tOp->m_abortOption = NdbTransaction::AO_IgnoreError; @@ -1229,7 +1214,7 @@ NdbBlob::preExecute(NdbTransaction::ExecType anExecType, bool& batch) theHeadInlineReadOp = tOp; // execute immediately batch = true; - DBG("add op before to read head+inline"); + DBUG_PRINT("info", ("add op before to read head+inline")); } } if (isIndexOp()) { @@ -1245,7 +1230,7 @@ NdbBlob::preExecute(NdbTransaction::ExecType anExecType, bool& batch) setAccessKeyValue(tOp) == -1 || tOp->getValue(pkAttrId, theKeyBuf.data) == NULL) { setErrorCode(tOp); - return -1; + DBUG_RETURN(-1); } } else { NdbIndexOperation* tOp = theNdbCon->getNdbIndexOperation(theAccessTable->m_index, theTable, theNdbOp); @@ -1254,11 +1239,11 @@ NdbBlob::preExecute(NdbTransaction::ExecType anExecType, bool& batch) setAccessKeyValue(tOp) == -1 || getTableKeyValue(tOp) == -1) { setErrorCode(tOp); - return -1; + DBUG_RETURN(-1); } } } - DBG("added op before to read table key"); + DBUG_PRINT("info", ("added op before to read table key")); if (isUpdateOp() || isDeleteOp()) { // add op before this one to read head+inline via index NdbIndexOperation* tOp = theNdbCon->getNdbIndexOperation(theAccessTable->m_index, theTable, theNdbOp); @@ -1267,7 +1252,7 @@ NdbBlob::preExecute(NdbTransaction::ExecType anExecType, bool& batch) setAccessKeyValue(tOp) == -1 || getHeadInlineValue(tOp) == -1) { setErrorCode(tOp); - return -1; + DBUG_RETURN(-1); } if (isWriteOp()) { tOp->m_abortOption = NdbTransaction::AO_IgnoreError; @@ -1275,7 +1260,7 @@ NdbBlob::preExecute(NdbTransaction::ExecType anExecType, bool& batch) theHeadInlineReadOp = tOp; // execute immediately batch = true; - DBG("added index op before to read head+inline"); + DBUG_PRINT("info", ("added index op before to read head+inline")); } if (isWriteOp()) { // XXX until IgnoreError fixed for index op @@ -1293,10 +1278,10 @@ NdbBlob::preExecute(NdbTransaction::ExecType anExecType, bool& batch) n = theInlineSize; assert(thePos == 0); if (writeDataPrivate(theSetBuf, n) == -1) - return -1; + DBUG_RETURN(-1); } if (setHeadInlineValue(theNdbOp) == -1) - return -1; + DBUG_RETURN(-1); // the read op before us may overwrite theHeadInlineCopyBuf.copyfrom(theHeadInlineBuf); } @@ -1305,8 +1290,8 @@ NdbBlob::preExecute(NdbTransaction::ExecType anExecType, bool& batch) // need blob head for callback batch = true; } - DBG("preExecute [out] batch=" << batch); - return 0; + DBUG_PRINT("info", ("batch=%u", batch)); + DBUG_RETURN(0); } /* @@ -1318,13 +1303,14 @@ NdbBlob::preExecute(NdbTransaction::ExecType anExecType, bool& batch) int NdbBlob::postExecute(NdbTransaction::ExecType anExecType) { - DBG("postExecute [in] type=" << anExecType); + DBUG_ENTER("NdbBlob::postExecute"); + DBUG_PRINT("info", ("this=%p op=%p con=%p anExecType=%u", this, theNdbOp, theNdbCon, anExecType)); if (theState == Invalid) - return -1; + DBUG_RETURN(-1); if (theState == Active) { setState(anExecType == NdbTransaction::NoCommit ? Active : Closed); - DBG("postExecute [skip]"); - return 0; + DBUG_PRINT("info", ("skip active")); + DBUG_RETURN(0); } assert(theState == Prepared); setState(anExecType == NdbTransaction::NoCommit ? Active : Closed); @@ -1340,14 +1326,14 @@ NdbBlob::postExecute(NdbTransaction::ExecType anExecType) if (isReadOp()) { getHeadFromRecAttr(); if (setPos(0) == -1) - return -1; + DBUG_RETURN(-1); if (theGetFlag) { assert(theGetSetBytes == 0 || theGetBuf != 0); assert(theGetSetBytes <= theInlineSize || anExecType == NdbTransaction::NoCommit); Uint32 bytes = theGetSetBytes; if (readDataPrivate(theGetBuf, bytes) == -1) - return -1; + DBUG_RETURN(-1); } } if (isUpdateOp()) { @@ -1357,13 +1343,13 @@ NdbBlob::postExecute(NdbTransaction::ExecType anExecType) // setValue overwrites everything if (theSetBuf != NULL) { if (truncate(0) == -1) - return -1; + DBUG_RETURN(-1); assert(thePos == 0); if (writeDataPrivate(theSetBuf, theGetSetBytes) == -1) - return -1; + DBUG_RETURN(-1); } else { if (setNull() == -1) - return -1; + DBUG_RETURN(-1); } } } @@ -1374,9 +1360,9 @@ NdbBlob::postExecute(NdbTransaction::ExecType anExecType) Uint64 tLength = theLength; Uint64 tPos = thePos; getHeadFromRecAttr(); - DBG("tuple found"); + DBUG_PRINT("info", ("tuple found")); if (truncate(0) == -1) - return -1; + DBUG_RETURN(-1); // restore previous head+inline theHeadInlineBuf.copyfrom(theHeadInlineCopyBuf); theNullFlag = tNullFlag; @@ -1385,16 +1371,16 @@ NdbBlob::postExecute(NdbTransaction::ExecType anExecType) } else { if (theHeadInlineReadOp->theError.code != 626) { setErrorCode(theHeadInlineReadOp); - return -1; + DBUG_RETURN(-1); } - DBG("tuple not found"); + DBUG_PRINT("info", ("tuple not found")); /* * Read found no tuple but it is possible that a tuple was * created after the read by another transaction. Delete all * blob parts which may exist. */ if (deletePartsUnknown(0) == -1) - return -1; + DBUG_RETURN(-1); } if (theSetFlag && theGetSetBytes > theInlineSize) { assert(theSetBuf != NULL); @@ -1402,33 +1388,33 @@ NdbBlob::postExecute(NdbTransaction::ExecType anExecType) Uint32 bytes = theGetSetBytes - theInlineSize; assert(thePos == theInlineSize); if (writeDataPrivate(buf, bytes) == -1) - return -1; + DBUG_RETURN(-1); } } if (isWriteOp() && isIndexOp()) { // XXX until IgnoreError fixed for index op if (deletePartsUnknown(0) == -1) - return -1; + DBUG_RETURN(-1); if (theSetFlag && theGetSetBytes > theInlineSize) { assert(theSetBuf != NULL); const char* buf = theSetBuf + theInlineSize; Uint32 bytes = theGetSetBytes - theInlineSize; assert(thePos == theInlineSize); if (writeDataPrivate(buf, bytes) == -1) - return -1; + DBUG_RETURN(-1); } } if (isDeleteOp()) { assert(anExecType == NdbTransaction::NoCommit); getHeadFromRecAttr(); if (deleteParts(0, getPartCount()) == -1) - return -1; + DBUG_RETURN(-1); } setState(anExecType == NdbTransaction::NoCommit ? Active : Closed); // activation callback if (theActiveHook != NULL) { if (invokeActiveHook() == -1) - return -1; + DBUG_RETURN(-1); } if (anExecType == NdbTransaction::NoCommit && theHeadInlineUpdateFlag) { NdbOperation* tOp = theNdbCon->getNdbOperation(theTable); @@ -1437,13 +1423,12 @@ NdbBlob::postExecute(NdbTransaction::ExecType anExecType) setTableKeyValue(tOp) == -1 || setHeadInlineValue(tOp) == -1) { setErrorCode(NdbBlobImpl::ErrAbort); - return -1; + DBUG_RETURN(-1); } tOp->m_abortOption = NdbTransaction::AbortOnError; - DBG("added op to update head+inline"); + DBUG_PRINT("info", ("added op to update head+inline")); } - DBG("postExecute [out]"); - return 0; + DBUG_RETURN(0); } /* @@ -1453,9 +1438,10 @@ NdbBlob::postExecute(NdbTransaction::ExecType anExecType) int NdbBlob::preCommit() { - DBG("preCommit [in]"); + DBUG_ENTER("NdbBlob::preCommit"); + DBUG_PRINT("info", ("this=%p op=%p con=%p", this, theNdbOp, theNdbCon)); if (theState == Invalid) - return -1; + DBUG_RETURN(-1); assert(theState == Active); assert(isKeyOp()); if (isInsertOp() || isUpdateOp() || isWriteOp()) { @@ -1467,14 +1453,13 @@ NdbBlob::preCommit() setTableKeyValue(tOp) == -1 || setHeadInlineValue(tOp) == -1) { setErrorCode(NdbBlobImpl::ErrAbort); - return -1; + DBUG_RETURN(-1); } tOp->m_abortOption = NdbTransaction::AbortOnError; - DBG("added op to update head+inline"); + DBUG_PRINT("info", ("added op to update head+inline")); } } - DBG("preCommit [out]"); - return 0; + DBUG_RETURN(0); } /* @@ -1483,35 +1468,35 @@ NdbBlob::preCommit() int NdbBlob::atNextResult() { - DBG("atNextResult [in]"); + DBUG_ENTER("NdbBlob::atNextResult"); + DBUG_PRINT("info", ("this=%p op=%p con=%p", this, theNdbOp, theNdbCon)); if (theState == Invalid) - return -1; + DBUG_RETURN(-1); assert(isScanOp()); // get primary key { Uint32* data = (Uint32*)theKeyBuf.data; unsigned size = theTable->m_keyLenInWords; if (((NdbScanOperation*)theNdbOp)->getKeyFromKEYINFO20(data, size) == -1) { setErrorCode(NdbBlobImpl::ErrUsage); - return -1; + DBUG_RETURN(-1); } } getHeadFromRecAttr(); if (setPos(0) == -1) - return -1; + DBUG_RETURN(-1); if (theGetFlag) { assert(theGetSetBytes == 0 || theGetBuf != 0); Uint32 bytes = theGetSetBytes; if (readDataPrivate(theGetBuf, bytes) == -1) - return -1; + DBUG_RETURN(-1); } setState(Active); // activation callback if (theActiveHook != NULL) { if (invokeActiveHook() == -1) - return -1; + DBUG_RETURN(-1); } - DBG("atNextResult [out]"); - return 0; + DBUG_RETURN(0); } // misc @@ -1527,13 +1512,15 @@ NdbBlob::getColumn() void NdbBlob::setErrorCode(int anErrorCode, bool invalidFlag) { - DBG("setErrorCode code=" << anErrorCode); + DBUG_ENTER("NdbBlob::setErrorCode"); + DBUG_PRINT("info", ("this=%p code=%u", this, anErrorCode)); theError.code = anErrorCode; // conditionally copy error to operation level if (theNdbOp != NULL && theNdbOp->theError.code == 0) theNdbOp->setErrorCode(theError.code); if (invalidFlag) setState(Invalid); + DBUG_VOID_RETURN; } void diff --git a/storage/ndb/src/ndbapi/NdbDictionary.cpp b/storage/ndb/src/ndbapi/NdbDictionary.cpp index 4cc47543cec..79b6fb4c0e8 100644 --- a/storage/ndb/src/ndbapi/NdbDictionary.cpp +++ b/storage/ndb/src/ndbapi/NdbDictionary.cpp @@ -773,9 +773,11 @@ NdbDictionary::Dictionary::getTable(const char * name) const void NdbDictionary::Dictionary::invalidateTable(const char * name){ + DBUG_ENTER("NdbDictionaryImpl::invalidateTable"); NdbTableImpl * t = m_impl.getTable(name); if(t) m_impl.invalidateObject(* t); + DBUG_VOID_RETURN; } void @@ -811,11 +813,13 @@ NdbDictionary::Dictionary::getIndex(const char * indexName, void NdbDictionary::Dictionary::invalidateIndex(const char * indexName, const char * tableName){ + DBUG_ENTER("NdbDictionaryImpl::invalidateIndex"); NdbIndexImpl * i = m_impl.getIndex(indexName, tableName); if(i) { assert(i->m_table != 0); m_impl.invalidateObject(* i->m_table); } + DBUG_VOID_RETURN; } void diff --git a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp index 6ecaf54b888..34d1614d043 100644 --- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -735,19 +735,19 @@ NdbDictionaryImpl::~NdbDictionaryImpl() } Ndb_local_table_info * -NdbDictionaryImpl::fetchGlobalTableImpl(const char * internalTableName) +NdbDictionaryImpl::fetchGlobalTableImpl(const BaseString& internalTableName) { NdbTableImpl *impl; m_globalHash->lock(); - impl = m_globalHash->get(internalTableName); + impl = m_globalHash->get(internalTableName.c_str()); m_globalHash->unlock(); if (impl == 0){ impl = m_receiver.getTable(internalTableName, m_ndb.usingFullyQualifiedNames()); m_globalHash->lock(); - m_globalHash->put(internalTableName, impl); + m_globalHash->put(internalTableName.c_str(), impl); m_globalHash->unlock(); if(impl == 0){ @@ -758,7 +758,7 @@ NdbDictionaryImpl::fetchGlobalTableImpl(const char * internalTableName) Ndb_local_table_info *info= Ndb_local_table_info::create(impl, m_local_table_data_size); - m_localHash.put(internalTableName, info); + m_localHash.put(internalTableName.c_str(), info); m_ndb.theFirstTupleId[impl->getTableId()] = ~0; m_ndb.theLastTupleId[impl->getTableId()] = ~0; @@ -806,14 +806,13 @@ NdbDictionaryImpl::setTransporter(class Ndb* ndb, return false; } -NdbTableImpl * -NdbDictionaryImpl::getIndexTable(NdbIndexImpl * index, +NdbTableImpl * +NdbDictionaryImpl::getIndexTable(NdbIndexImpl * index, NdbTableImpl * table) { - const char * internalName = - m_ndb.internalizeIndexName(table, index->getName()); - - return getTable(m_ndb.externalizeTableName(internalName)); + const BaseString internalName( + m_ndb.internalize_index_name(table, index->getName())); + return getTable(m_ndb.externalizeTableName(internalName.c_str())); } #if 0 @@ -1055,7 +1054,7 @@ NdbDictInterface::dictSignal(NdbApiSignal* signal, } DBUG_RETURN(-1); } - +#if 0 /* Get dictionary information for a table using table id as reference @@ -1079,6 +1078,7 @@ NdbDictInterface::getTable(int tableId, bool fullyQualifiedNames) return getTable(&tSignal, 0, 0, fullyQualifiedNames); } +#endif /* @@ -1090,36 +1090,31 @@ NdbDictInterface::getTable(int tableId, bool fullyQualifiedNames) */ NdbTableImpl * -NdbDictInterface::getTable(const char * name, bool fullyQualifiedNames) +NdbDictInterface::getTable(const BaseString& name, bool fullyQualifiedNames) { NdbApiSignal tSignal(m_reference); GetTabInfoReq* const req = CAST_PTR(GetTabInfoReq, tSignal.getDataPtrSend()); - const Uint32 str_len= strlen(name) + 1; // NULL terminated - const Uint32 str_len_words= (str_len + 3) / 4; // Size in words - - if (str_len > MAX_SECTION_SIZE) - { - m_error.code= 4307; - return 0; - } - - m_namebuf.clear(); - m_namebuf.grow(str_len_words*4); // Word size aligned number of bytes - m_namebuf.append(name, str_len); + const Uint32 namelen= name.length() + 1; // NULL terminated + const Uint32 namelen_words= (namelen + 3) >> 2; // Size in words req->senderRef= m_reference; req->senderData= 0; req->requestType= GetTabInfoReq::RequestByName | GetTabInfoReq::LongSignalConf; - req->tableNameLen= str_len; + req->tableNameLen= namelen; tSignal.theReceiversBlockNumber= DBDICT; tSignal.theVerId_signalNumber= GSN_GET_TABINFOREQ; tSignal.theLength= GetTabInfoReq::SignalLength; + // Copy name to m_buffer to get a word sized buffer + m_buffer.clear(); + m_buffer.grow(namelen_words*4); + m_buffer.append(name.c_str(), namelen); + LinearSectionPtr ptr[1]; - ptr[0].p= (Uint32*)m_namebuf.get_data(); - ptr[0].sz= str_len_words; + ptr[0].p= (Uint32*)m_buffer.get_data(); + ptr[0].sz= namelen_words; return getTable(&tSignal, ptr, 1, fullyQualifiedNames); } @@ -1463,7 +1458,7 @@ NdbDictionaryImpl::createTable(NdbTableImpl &t) return 0; // update table def from DICT Ndb_local_table_info *info= - get_local_table_info(t.m_internalName.c_str(),false); + get_local_table_info(t.m_internalName,false); if (info == NULL) { m_error.code= 709; return -1; @@ -1490,7 +1485,7 @@ NdbDictionaryImpl::createBlobTables(NdbTableImpl &t) return -1; // Save BLOB table handle Ndb_local_table_info *info= - get_local_table_info(bt.m_internalName.c_str(), false); + get_local_table_info(bt.m_internalName, false); if (info == 0) { return -1; } @@ -1534,12 +1529,11 @@ NdbDictInterface::createTable(Ndb & ndb, int NdbDictionaryImpl::alterTable(NdbTableImpl &impl) { - BaseString internalName = impl.m_internalName; + BaseString internalName(impl.m_internalName); const char * originalInternalName = internalName.c_str(); - BaseString externalName = impl.m_externalName; DBUG_ENTER("NdbDictionaryImpl::alterTable"); - if(!get_local_table_info(originalInternalName, false)){ + if(!get_local_table_info(internalName, false)){ m_error.code= 709; DBUG_RETURN(-1); } @@ -1594,14 +1588,14 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, //validate(); //aggregate(); - const char * internalName = - ndb.internalizeTableName(impl.m_externalName.c_str()); + const BaseString internalName( + ndb.internalize_table_name(impl.m_externalName.c_str())); impl.m_internalName.assign(internalName); UtilBufferWriter w(m_buffer); DictTabInfo::Table tmpTab; tmpTab.init(); - BaseString::snprintf(tmpTab.TableName, - sizeof(tmpTab.TableName), - internalName); + BaseString::snprintf(tmpTab.TableName, + sizeof(tmpTab.TableName), + internalName.c_str()); bool haveAutoIncrement = false; Uint64 autoIncrementValue = 0; @@ -1865,14 +1859,14 @@ NdbDictionaryImpl::dropTable(const char * name) // If table stored in cache is incompatible with the one in the kernel // we must clear the cache and try again if (ret == INCOMPATIBLE_VERSION) { - const char * internalTableName = m_ndb.internalizeTableName(name); + const BaseString internalTableName(m_ndb.internalize_table_name(name)); - DBUG_PRINT("info",("INCOMPATIBLE_VERSION internal_name: %s", internalTableName)); - m_localHash.drop(internalTableName); + DBUG_PRINT("info",("INCOMPATIBLE_VERSION internal_name: %s", internalTableName.c_str())); + m_localHash.drop(internalTableName.c_str()); m_globalHash->lock(); tab->m_status = NdbDictionary::Object::Invalid; m_globalHash->drop(tab); - m_globalHash->unlock(); + m_globalHash->unlock(); DBUG_RETURN(dropTable(name)); } @@ -2013,13 +2007,14 @@ int NdbDictionaryImpl::invalidateObject(NdbTableImpl & impl) { const char * internalTableName = impl.m_internalName.c_str(); - - m_localHash.drop(internalTableName); + DBUG_ENTER("NdbDictionaryImpl::invalidateObject"); + DBUG_PRINT("enter", ("internal_name: %s", internalTableName)); + m_localHash.drop(internalTableName); m_globalHash->lock(); impl.m_status = NdbDictionary::Object::Invalid; m_globalHash->drop(&impl); m_globalHash->unlock(); - return 0; + DBUG_RETURN(0); } int @@ -2038,8 +2033,8 @@ NdbDictionaryImpl::removeCachedObject(NdbTableImpl & impl) * Get index info */ NdbIndexImpl* -NdbDictionaryImpl::getIndexImpl(const char * externalName, - const char * internalName) +NdbDictionaryImpl::getIndexImpl(const char * externalName, + const BaseString& internalName) { Ndb_local_table_info * info = get_local_table_info(internalName, false); @@ -2055,21 +2050,11 @@ NdbDictionaryImpl::getIndexImpl(const char * externalName, return 0; } - /* - * internalName may be pointer to m_ndb.theImpl->m_internalname.c_str() - * and may get deallocated in next call. - * - * Passing around pointers to volatile internal members may not be - * optimal. Suggest use BaseString instances passed by value. - */ - - BaseString save_me(internalName); NdbTableImpl* prim = getTable(tab->m_primaryTable.c_str()); if(prim == 0){ m_error.code = 4243; return 0; } - internalName = save_me.c_str(); /** * Create index impl @@ -2175,12 +2160,11 @@ NdbDictInterface::createIndex(Ndb & ndb, m_error.code = 4241; return -1; } - const char * internalName = - ndb.internalizeIndexName(&table, impl.getName()); - + const BaseString internalName( + ndb.internalize_index_name(&table, impl.getName())); impl.m_internalName.assign(internalName); - w.add(DictTabInfo::TableName, internalName); + w.add(DictTabInfo::TableName, internalName.c_str()); w.add(DictTabInfo::TableLoggedFlag, impl.m_logging); NdbApiSignal tSignal(m_reference); @@ -2286,20 +2270,20 @@ NdbDictionaryImpl::dropIndex(const char * indexName, // If index stored in cache is incompatible with the one in the kernel // we must clear the cache and try again if (ret == INCOMPATIBLE_VERSION) { - const char * internalIndexName = (tableName) + const BaseString internalIndexName((tableName) ? - m_ndb.internalizeIndexName(getTable(tableName), indexName) + m_ndb.internalize_index_name(getTable(tableName), indexName) : - m_ndb.internalizeTableName(indexName); // Index is also a table - - m_localHash.drop(internalIndexName); + m_ndb.internalize_table_name(indexName)); // Index is also a table + + m_localHash.drop(internalIndexName.c_str()); m_globalHash->lock(); idx->m_table->m_status = NdbDictionary::Object::Invalid; m_globalHash->drop(idx->m_table); - m_globalHash->unlock(); + m_globalHash->unlock(); return dropIndex(indexName, tableName); } - + return ret; } @@ -2315,19 +2299,19 @@ NdbDictionaryImpl::dropIndex(NdbIndexImpl & impl, const char * tableName) return -1; } - const char * internalIndexName = (tableName) + const BaseString internalIndexName((tableName) ? - m_ndb.internalizeIndexName(getTable(tableName), indexName) + m_ndb.internalize_index_name(getTable(tableName), indexName) : - m_ndb.internalizeTableName(indexName); // Index is also a table + m_ndb.internalize_table_name(indexName)); // Index is also a table if(impl.m_status == NdbDictionary::Object::New){ return dropIndex(indexName, tableName); } - + int ret = m_receiver.dropIndex(impl, *timpl); if(ret == 0){ - m_localHash.drop(internalIndexName); + m_localHash.drop(internalIndexName.c_str()); m_globalHash->lock(); impl.m_table->m_status = NdbDictionary::Object::Invalid; m_globalHash->drop(impl.m_table); @@ -2532,8 +2516,12 @@ NdbDictInterface::createEvent(class Ndb & ndb, w.add(SimpleProperties::StringValue, evnt.m_externalName.c_str()); if (getFlag == 0) + { + const BaseString internal_tabname( + ndb.internalize_table_name(evnt.m_tableName.c_str())); w.add(SimpleProperties::StringValue, - ndb.internalizeTableName(evnt.m_tableName.c_str())); + internal_tabname.c_str()); + } LinearSectionPtr ptr[1]; ptr[0].p = (Uint32*)m_buffer.get_data(); diff --git a/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp b/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp index 7e3e3b19294..754d0000718 100644 --- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp +++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp @@ -19,7 +19,6 @@ #include <ndb_types.h> #include <kernel_types.h> -#include <ndb_limits.h> #include <NdbError.hpp> #include <BaseString.hpp> #include <Vector.hpp> @@ -309,8 +308,8 @@ public: int listObjects(NdbDictionary::Dictionary::List& list, Uint32 requestData, bool fullyQualifiedNames); int listObjects(NdbApiSignal* signal); - NdbTableImpl * getTable(int tableId, bool fullyQualifiedNames); - NdbTableImpl * getTable(const char * name, bool fullyQualifiedNames); +/* NdbTableImpl * getTable(int tableId, bool fullyQualifiedNames); */ + NdbTableImpl * getTable(const BaseString& name, bool fullyQualifiedNames); NdbTableImpl * getTable(class NdbApiSignal * signal, LinearSectionPtr ptr[3], Uint32 noOfSections, bool fullyQualifiedNames); @@ -368,8 +367,6 @@ private: Uint32 m_fragmentId; UtilBuffer m_buffer; - // Buffer used when requesting a table by name - UtilBuffer m_namebuf; }; class NdbDictionaryImpl : public NdbDictionary::Dictionary { @@ -406,13 +403,12 @@ public: int listObjects(List& list, NdbDictionary::Object::Type type); int listIndexes(List& list, Uint32 indexId); - + NdbTableImpl * getTable(const char * tableName, void **data= 0); - Ndb_local_table_info * get_local_table_info(const char * internalName, - bool do_add_blob_tables); + Ndb_local_table_info* get_local_table_info( + const BaseString& internalTableName, bool do_add_blob_tables); NdbIndexImpl * getIndex(const char * indexName, const char * tableName); - NdbIndexImpl * getIndexImpl(const char * name, const char * internalName); NdbEventImpl * getEvent(const char * eventName); NdbEventImpl * getEventImpl(const char * internalName); @@ -430,7 +426,9 @@ public: NdbDictInterface m_receiver; Ndb & m_ndb; private: - Ndb_local_table_info * fetchGlobalTableImpl(const char * internalName); + NdbIndexImpl * getIndexImpl(const char * name, + const BaseString& internalName); + Ndb_local_table_info * fetchGlobalTableImpl(const BaseString& internalName); }; inline @@ -638,26 +636,27 @@ NdbDictionaryImpl::getImpl(const NdbDictionary::Dictionary & t){ */ inline -NdbTableImpl * -NdbDictionaryImpl::getTable(const char * tableName, void **data) +NdbTableImpl * +NdbDictionaryImpl::getTable(const char * table_name, void **data) { + const BaseString internal_tabname(m_ndb.internalize_table_name(table_name)); Ndb_local_table_info *info= - get_local_table_info(m_ndb.internalizeTableName(tableName), true); - if (info == 0) { + get_local_table_info(internal_tabname, true); + if (info == 0) return 0; - } - if (data) { + + if (data) *data= info->m_local_data; - } + return info->m_table_impl; } inline Ndb_local_table_info * -NdbDictionaryImpl::get_local_table_info(const char * internalTableName, +NdbDictionaryImpl::get_local_table_info(const BaseString& internalTableName, bool do_add_blob_tables) { - Ndb_local_table_info *info= m_localHash.get(internalTableName); + Ndb_local_table_info *info= m_localHash.get(internalTableName.c_str()); if (info == 0) { info= fetchGlobalTableImpl(internalTableName); if (info == 0) { @@ -672,34 +671,35 @@ NdbDictionaryImpl::get_local_table_info(const char * internalTableName, inline NdbIndexImpl * -NdbDictionaryImpl::getIndex(const char * indexName, - const char * tableName) +NdbDictionaryImpl::getIndex(const char * index_name, + const char * table_name) { - if (tableName || m_ndb.usingFullyQualifiedNames()) { - const char * internalIndexName = 0; - if (tableName) { - NdbTableImpl * t = getTable(tableName); - if (t != 0) - internalIndexName = m_ndb.internalizeIndexName(t, indexName); - } else { - internalIndexName = - m_ndb.internalizeTableName(indexName); // Index is also a table - } - if (internalIndexName) { - Ndb_local_table_info * info = get_local_table_info(internalIndexName, - false); - if (info) { - NdbTableImpl * tab = info->m_table_impl; + if (table_name || m_ndb.usingFullyQualifiedNames()) + { + const BaseString internal_indexname( + (table_name) + ? + m_ndb.internalize_index_name(getTable(table_name), index_name) + : + m_ndb.internalize_table_name(index_name)); // Index is also a table + + if (internal_indexname.length()) + { + Ndb_local_table_info * info= + get_local_table_info(internal_indexname, false); + if (info) + { + NdbTableImpl * tab= info->m_table_impl; if (tab->m_index == 0) - tab->m_index = getIndexImpl(indexName, internalIndexName); + tab->m_index= getIndexImpl(index_name, internal_indexname); if (tab->m_index != 0) - tab->m_index->m_table = tab; + tab->m_index->m_table= tab; return tab->m_index; } } } - m_error.code = 4243; + m_error.code= 4243; return 0; } diff --git a/storage/ndb/src/ndbapi/NdbImpl.hpp b/storage/ndb/src/ndbapi/NdbImpl.hpp index f4ce76fee61..d73b8afe10c 100644 --- a/storage/ndb/src/ndbapi/NdbImpl.hpp +++ b/storage/ndb/src/ndbapi/NdbImpl.hpp @@ -65,7 +65,6 @@ public: BaseString m_schemaname; // Schema name BaseString m_prefix; // Buffer for preformatted internal name <db>/<schema>/ - BaseString m_internalname; void update_prefix() { @@ -73,23 +72,6 @@ public: m_schemaname.c_str(), table_name_separator); } - const char* internalize_table_name(const char* ext_name) - { - // Internal table name format <db>/<schema>/<table> - return m_internalname.assign(m_prefix).append(ext_name).c_str(); - } - - const char* internalize_index_name(const NdbTableImpl *table, - const char* ext_name) - { - // Internal index name format <db>/<schema>/<tabid>/<table> - return m_internalname.assign(m_prefix).appfmt("%d%c%s", - table->m_tableId, - table_name_separator, - ext_name).c_str(); - } - - }; #ifdef VM_TRACE diff --git a/storage/ndb/src/ndbapi/NdbLinHash.hpp b/storage/ndb/src/ndbapi/NdbLinHash.hpp index f245a261a04..05670534c95 100644 --- a/storage/ndb/src/ndbapi/NdbLinHash.hpp +++ b/storage/ndb/src/ndbapi/NdbLinHash.hpp @@ -192,7 +192,7 @@ template <class C> inline Int32 NdbLinHash<C>::insertKey( const char* str, Uint32 len, Uint32 lkey1, C* data ) -{ +{ const Uint32 hash = Hash(str, len); int dir, seg; getBucket(hash, &dir, &seg); @@ -219,8 +219,9 @@ NdbLinHash<C>::insertKey( const char* str, Uint32 len, Uint32 lkey1, C* data ) chain->localkey1 = lkey1; chain->next = 0; chain->theData = data; + len++; // Null terminated chain->str = new Uint32[((len + 3) >> 2)]; - memcpy( &chain->str[0], str, len ); + memcpy( &chain->str[0], str, len); if (oldChain != 0) oldChain->next = chain; else diff --git a/storage/ndb/src/ndbapi/NdbTransaction.cpp b/storage/ndb/src/ndbapi/NdbTransaction.cpp index d0d664c9a3c..675c9383c6e 100644 --- a/storage/ndb/src/ndbapi/NdbTransaction.cpp +++ b/storage/ndb/src/ndbapi/NdbTransaction.cpp @@ -25,7 +25,6 @@ #include "TransporterFacade.hpp" #include "API.hpp" #include "NdbBlob.hpp" -#include <ndb_limits.h> #include <signaldata/TcKeyConf.hpp> #include <signaldata/TcIndx.hpp> @@ -1287,10 +1286,9 @@ NdbTransaction::getNdbIndexOperation(const char* anIndexName, { // This unique index is defined from SQL level static const char* uniqueSuffix= "$unique"; - char uniqueIndexName[MAX_TAB_NAME_SIZE]; - - strxnmov(uniqueIndexName, MAX_TAB_NAME_SIZE, anIndexName, uniqueSuffix, NullS); - index = theNdb->theDictionary->getIndex(uniqueIndexName, + BaseString uniqueIndexName(anIndexName); + uniqueIndexName.append(uniqueSuffix); + index = theNdb->theDictionary->getIndex(uniqueIndexName.c_str(), aTableName); } else diff --git a/storage/ndb/test/ndbapi/testBlobs.cpp b/storage/ndb/test/ndbapi/testBlobs.cpp index 3f5d1982522..fb105713f8e 100644 --- a/storage/ndb/test/ndbapi/testBlobs.cpp +++ b/storage/ndb/test/ndbapi/testBlobs.cpp @@ -23,14 +23,13 @@ #include <NdbOut.hpp> #include <NdbTest.hpp> #include <NdbTick.h> -#include <ndb/src/ndbapi/NdbBlobImpl.hpp> struct Bcol { bool m_nullable; unsigned m_inline; unsigned m_partsize; unsigned m_stripe; - char m_btname[NdbBlobImpl::BlobTableNameSize]; + char m_btname[200]; Bcol(bool a, unsigned b, unsigned c, unsigned d) : m_nullable(a), m_inline(b), @@ -365,7 +364,7 @@ calcBval(const Bcol& b, Bval& v, bool keepsize) { if (b.m_nullable && urandom(10) == 0) { v.m_len = 0; - delete v.m_val; + delete [] v.m_val; v.m_val = 0; v.m_buf = new char [1]; } else { @@ -375,7 +374,7 @@ calcBval(const Bcol& b, Bval& v, bool keepsize) v.m_len = urandom(b.m_inline); else v.m_len = urandom(b.m_inline + g_opt.m_parts * b.m_partsize + 1); - delete v.m_val; + delete [] v.m_val; v.m_val = new char [v.m_len + 1]; for (unsigned i = 0; i < v.m_len; i++) v.m_val[i] = 'a' + urandom(25); diff --git a/storage/ndb/test/ndbapi/testDict.cpp b/storage/ndb/test/ndbapi/testDict.cpp index aca8b299b49..dd5846f0d62 100644 --- a/storage/ndb/test/ndbapi/testDict.cpp +++ b/storage/ndb/test/ndbapi/testDict.cpp @@ -1009,10 +1009,10 @@ int runGetPrimaryKey(NDBT_Context* ctx, NDBT_Step* step){ struct ErrorCodes { int error_id; bool crash;}; ErrorCodes NF_codes[] = { - {6003, true}, - {6004, true}, + {6003, true} + ,{6004, true} //,6005, true, - {7173, false} + //{7173, false} }; int @@ -1031,17 +1031,6 @@ runNF1(NDBT_Context* ctx, NDBT_Step* step){ int result = NDBT_OK; - /** - * Need to run LCP at high rate otherwise - * packed replicas become "to many" - */ - int val = DumpStateOrd::DihMinTimeBetweenLCP; - if(restarter.dumpStateAllNodes(&val, 1) != 0){ - do { CHECK(0); } while(0); - g_err << "Failed to set LCP to min value" << endl; - return NDBT_FAILED; - } - const int loops = ctx->getNumLoops(); for (int l = 0; l < loops && result == NDBT_OK ; l++){ const int sz = sizeof(NF_codes)/sizeof(NF_codes[0]); @@ -1064,7 +1053,7 @@ runNF1(NDBT_Context* ctx, NDBT_Step* step){ CHECK2(dict->createTable(* pTab) == 0, "failed to create table"); - + if (crash) { CHECK2(restarter.waitNodesNoStart(&nodeId, 1) == 0, "waitNodesNoStart failed"); @@ -1088,9 +1077,6 @@ runNF1(NDBT_Context* ctx, NDBT_Step* step){ CHECK2(restarter.waitClusterStarted() == 0, "waitClusterStarted failed"); } - - CHECK2(restarter.dumpStateOneNode(nodeId, &val, 1) == 0, - "Failed to set LCP to min value"); } } } diff --git a/storage/ndb/test/ndbapi/testNdbApi.cpp b/storage/ndb/test/ndbapi/testNdbApi.cpp index ad1b1462ae7..65324af6fe6 100644 --- a/storage/ndb/test/ndbapi/testNdbApi.cpp +++ b/storage/ndb/test/ndbapi/testNdbApi.cpp @@ -1037,6 +1037,239 @@ int runCheckGetNdbErrorOperation(NDBT_Context* ctx, NDBT_Step* step){ return result; } +int runBug_11133(NDBT_Context* ctx, NDBT_Step* step){ + int result = NDBT_OK; + const NdbDictionary::Table* pTab = ctx->getTab(); + + HugoOperations hugoOps(*pTab); + + Ndb* pNdb = GETNDB(step); + Uint32 lm; + + NdbConnection* pCon = pNdb->startTransaction(); + if (pCon == NULL){ + pNdb->closeTransaction(pCon); + return NDBT_FAILED; + } + + NdbOperation* pOp = pCon->getNdbOperation(pTab->getName()); + if (pOp == NULL){ + ERR(pCon->getNdbError()); + pNdb->closeTransaction(pCon); + return NDBT_FAILED; + } + + if (pOp->readTuple(NdbOperation::LM_Exclusive) != 0){ + pNdb->closeTransaction(pCon); + ERR(pOp->getNdbError()); + return NDBT_FAILED; + } + + for(int a = 0; a<pTab->getNoOfColumns(); a++){ + if (pTab->getColumn(a)->getPrimaryKey() == true){ + if(hugoOps.equalForAttr(pOp, a, 1) != 0){ + ERR(pCon->getNdbError()); + pNdb->closeTransaction(pCon); + return NDBT_FAILED; + } + } + } + + for(int a = 0; a<pTab->getNoOfColumns(); a++){ + if (pTab->getColumn(a)->getPrimaryKey() != true){ + if (pOp->getValue(pTab->getColumn(a)->getName()) == NULL) { + ERR(pCon->getNdbError()); + pNdb->closeTransaction(pCon); + return NDBT_FAILED; + } + } + } + + int check = pCon->execute(NoCommit); + if (check == 0){ + ndbout << "execute worked" << endl; + } else { + ERR(pCon->getNdbError()); + result = NDBT_FAILED; + } + + pOp = pCon->getNdbOperation(pTab->getName()); + if (pOp == NULL){ + ERR(pCon->getNdbError()); + pNdb->closeTransaction(pCon); + return NDBT_FAILED; + } + + if (pOp->deleteTuple() != 0){ + pNdb->closeTransaction(pCon); + ERR(pOp->getNdbError()); + return NDBT_FAILED; + } + + for(int a = 0; a<pTab->getNoOfColumns(); a++){ + if (pTab->getColumn(a)->getPrimaryKey() == true){ + if(hugoOps.equalForAttr(pOp, a, 1) != 0){ + ERR(pCon->getNdbError()); + pNdb->closeTransaction(pCon); + return NDBT_FAILED; + } + } + } + + check = pCon->execute(NoCommit); + if (check == 0){ + ndbout << "execute worked" << endl; + } else { + ERR(pCon->getNdbError()); + result = NDBT_FAILED; + } + + pOp = pCon->getNdbOperation(pTab->getName()); + if (pOp == NULL){ + ERR(pCon->getNdbError()); + pNdb->closeTransaction(pCon); + return NDBT_FAILED; + } + + if (pOp->writeTuple() != 0){ + pNdb->closeTransaction(pCon); + ERR(pOp->getNdbError()); + return NDBT_FAILED; + } + + for(int a = 0; a<pTab->getNoOfColumns(); a++){ + if (pTab->getColumn(a)->getPrimaryKey() == true){ + if(hugoOps.equalForAttr(pOp, a, 1) != 0){ + ERR(pCon->getNdbError()); + pNdb->closeTransaction(pCon); + return NDBT_FAILED; + } + } + } + + for(int a = 0; a<pTab->getNoOfColumns(); a++){ + if (pTab->getColumn(a)->getPrimaryKey() != true){ + if(hugoOps.setValueForAttr(pOp, a, 1, 1) != 0) + { + ERR(pCon->getNdbError()); + pNdb->closeTransaction(pCon); + return NDBT_FAILED; + } + } + } + + check = pCon->execute(NoCommit); + if (check == 0){ + ndbout << "execute worked" << endl; + } else { + ERR(pCon->getNdbError()); + result = NDBT_FAILED; + } + + pOp = pCon->getNdbOperation(pTab->getName()); + if (pOp == NULL){ + ERR(pCon->getNdbError()); + pNdb->closeTransaction(pCon); + return NDBT_FAILED; + } + + if (pOp->writeTuple() != 0){ + pNdb->closeTransaction(pCon); + ERR(pOp->getNdbError()); + return NDBT_FAILED; + } + + for(int a = 0; a<pTab->getNoOfColumns(); a++){ + if (pTab->getColumn(a)->getPrimaryKey() == true){ + if(hugoOps.equalForAttr(pOp, a, 1) != 0){ + ERR(pCon->getNdbError()); + pNdb->closeTransaction(pCon); + return NDBT_FAILED; + } + } + } + + for(int a = 0; a<pTab->getNoOfColumns(); a++){ + if (pTab->getColumn(a)->getPrimaryKey() != true){ + if(hugoOps.setValueForAttr(pOp, a, 1, 1) != 0) + { + ERR(pCon->getNdbError()); + pNdb->closeTransaction(pCon); + return NDBT_FAILED; + } + } + } + + check = pCon->execute(NoCommit); + if (check == 0){ + ndbout << "execute worked" << endl; + } else { + ERR(pCon->getNdbError()); + result = NDBT_FAILED; + } + + check = pCon->execute(Rollback); + if (check == 0){ + ndbout << "execute worked" << endl; + } else { + ERR(pCon->getNdbError()); + result = NDBT_FAILED; + } + + pCon->close(); + + pCon = pNdb->startTransaction(); + if (pCon == NULL){ + pNdb->closeTransaction(pCon); + return NDBT_FAILED; + } + + pOp = pCon->getNdbOperation(pTab->getName()); + if (pOp == NULL){ + ERR(pCon->getNdbError()); + pNdb->closeTransaction(pCon); + return NDBT_FAILED; + } + + if (pOp->writeTuple() != 0){ + pNdb->closeTransaction(pCon); + ERR(pOp->getNdbError()); + return NDBT_FAILED; + } + + for(int a = 0; a<pTab->getNoOfColumns(); a++){ + if (pTab->getColumn(a)->getPrimaryKey() == true){ + if(hugoOps.equalForAttr(pOp, a, 1) != 0){ + ERR(pCon->getNdbError()); + pNdb->closeTransaction(pCon); + return NDBT_FAILED; + } + } + } + + for(int a = 0; a<pTab->getNoOfColumns(); a++){ + if (pTab->getColumn(a)->getPrimaryKey() != true){ + if(hugoOps.setValueForAttr(pOp, a, 1, 1) != 0) + { + ERR(pCon->getNdbError()); + pNdb->closeTransaction(pCon); + return NDBT_FAILED; + } + } + } + + check = pCon->execute(Commit); + if (check == 0){ + ndbout << "execute worked" << endl; + } else { + ERR(pCon->getNdbError()); + result = NDBT_FAILED; + } + + return result; +} + + NDBT_TESTSUITE(testNdbApi); TESTCASE("MaxNdb", @@ -1112,6 +1345,12 @@ TESTCASE("ReadWithoutGetValue", INITIALIZER(runReadWithoutGetValue); FINALIZER(runClearTable); } +TESTCASE("Bug_11133", + "Test ReadEx-Delete-Write\n"){ + INITIALIZER(runLoadTable); + INITIALIZER(runBug_11133); + FINALIZER(runClearTable); +} NDBT_TESTSUITE_END(testNdbApi); int main(int argc, const char** argv){ diff --git a/storage/ndb/test/ndbapi/testOIBasic.cpp b/storage/ndb/test/ndbapi/testOIBasic.cpp index b6fc2e29bf5..942ee2ec966 100644 --- a/storage/ndb/test/ndbapi/testOIBasic.cpp +++ b/storage/ndb/test/ndbapi/testOIBasic.cpp @@ -31,6 +31,7 @@ #include <NdbSleep.h> #include <my_sys.h> #include <NdbSqlUtil.hpp> +#include <ndb_version.h> // options @@ -171,6 +172,47 @@ randompct(unsigned pct) return urandom(100) < pct; } +static unsigned +random_coprime(unsigned n) +{ + unsigned prime[] = { 101, 211, 307, 401, 503, 601, 701, 809, 907 }; + unsigned count = sizeof(prime) / sizeof(prime[0]); + if (n == 0) + return 0; + while (1) { + unsigned i = urandom(count); + if (n % prime[i] != 0) + return prime[i]; + } +} + +// random re-sequence of 0...(n-1) + +struct Rsq { + Rsq(unsigned n); + unsigned next(); +private: + unsigned m_n; + unsigned m_i; + unsigned m_start; + unsigned m_prime; +}; + +Rsq::Rsq(unsigned n) +{ + m_n = n; + m_i = 0; + m_start = urandom(n); + m_prime = random_coprime(n); +} + +unsigned +Rsq::next() +{ + assert(m_n != 0); + return (m_start + m_i++ * m_prime) % m_n; +} + // log and error macros static NdbMutex *ndbout_mutex = NULL; @@ -1032,8 +1074,8 @@ makebuiltintables(Par par) // name - pk - type - length - nullable - cs t->coladd(0, new Col(*t, 0, "a", 0, Col::Unsigned, 1, 0, 0)); t->coladd(1, new Col(*t, 1, "b", 1, Col::Unsigned, 1, 0, 0)); - t->coladd(2, new Col(*t, 2, "c", 0, Col::Char, 20, 1, getcs(par))); - t->coladd(3, new Col(*t, 3, "d", 0, Col::Varchar, 5, 0, getcs(par))); + t->coladd(2, new Col(*t, 2, "c", 0, Col::Varchar, 20, 0, getcs(par))); + t->coladd(3, new Col(*t, 3, "d", 0, Col::Char, 5, 0, getcs(par))); t->coladd(4, new Col(*t, 4, "e", 0, Col::Longvarchar, 5, 1, getcs(par))); if (useindex(par, 0)) { // b @@ -1071,10 +1113,10 @@ makebuiltintables(Par par) t->itabadd(4, x); } if (useindex(par, 5)) { - // a, b, d + // b, c, d ITab* x = new ITab(*t, "ti1z5", ITab::UniqueHashIndex, 3); - x->icoladd(0, new ICol(*x, 0, *t->m_col[0])); - x->icoladd(1, new ICol(*x, 1, *t->m_col[1])); + x->icoladd(0, new ICol(*x, 0, *t->m_col[1])); + x->icoladd(1, new ICol(*x, 1, *t->m_col[2])); x->icoladd(2, new ICol(*x, 2, *t->m_col[3])); t->itabadd(5, x); } @@ -2254,14 +2296,18 @@ Row::insrow(Par par) assert(! m_exist); CHK(con.getNdbOperation(tab) == 0); CHKCON(con.m_op->insertTuple() == 0, con); + Rsq rsq1(tab.m_cols); for (unsigned k = 0; k < tab.m_cols; k++) { - const Val& val = *m_val[k]; + unsigned k2 = rsq1.next(); + const Val& val = *m_val[k2]; const Col& col = val.m_col; if (col.m_pk) CHK(val.equal(par) == 0); } + Rsq rsq2(tab.m_cols); for (unsigned k = 0; k < tab.m_cols; k++) { - const Val& val = *m_val[k]; + unsigned k2 = rsq2.next(); + const Val& val = *m_val[k2]; const Col& col = val.m_col; if (! col.m_pk) CHK(val.setval(par) == 0); @@ -2278,14 +2324,18 @@ Row::updrow(Par par) assert(m_exist); CHK(con.getNdbOperation(tab) == 0); CHKCON(con.m_op->updateTuple() == 0, con); + Rsq rsq1(tab.m_cols); for (unsigned k = 0; k < tab.m_cols; k++) { - const Val& val = *m_val[k]; + unsigned k2 = rsq1.next(); + const Val& val = *m_val[k2]; const Col& col = val.m_col; if (col.m_pk) CHK(val.equal(par) == 0); } + Rsq rsq2(tab.m_cols); for (unsigned k = 0; k < tab.m_cols; k++) { - const Val& val = *m_val[k]; + unsigned k2 = rsq2.next(); + const Val& val = *m_val[k2]; const Col& col = val.m_col; if (! col.m_pk) CHK(val.setval(par) == 0); @@ -2303,15 +2353,19 @@ Row::updrow(Par par, const ITab& itab) assert(m_exist); CHK(con.getNdbIndexOperation(itab, tab) == 0); CHKCON(con.m_op->updateTuple() == 0, con); + Rsq rsq1(itab.m_icols); for (unsigned k = 0; k < itab.m_icols; k++) { - const ICol& icol = *itab.m_icol[k]; + unsigned k2 = rsq1.next(); + const ICol& icol = *itab.m_icol[k2]; const Col& col = icol.m_col; unsigned m = col.m_num; const Val& val = *m_val[m]; CHK(val.equal(par, icol) == 0); } + Rsq rsq2(tab.m_cols); for (unsigned k = 0; k < tab.m_cols; k++) { - const Val& val = *m_val[k]; + unsigned k2 = rsq2.next(); + const Val& val = *m_val[k2]; const Col& col = val.m_col; if (! col.m_pk) CHK(val.setval(par) == 0); @@ -2328,8 +2382,10 @@ Row::delrow(Par par) assert(m_exist); CHK(con.getNdbOperation(m_tab) == 0); CHKCON(con.m_op->deleteTuple() == 0, con); + Rsq rsq1(tab.m_cols); for (unsigned k = 0; k < tab.m_cols; k++) { - const Val& val = *m_val[k]; + unsigned k2 = rsq1.next(); + const Val& val = *m_val[k2]; const Col& col = val.m_col; if (col.m_pk) CHK(val.equal(par) == 0); @@ -2347,8 +2403,10 @@ Row::delrow(Par par, const ITab& itab) assert(m_exist); CHK(con.getNdbIndexOperation(itab, tab) == 0); CHKCON(con.m_op->deleteTuple() == 0, con); + Rsq rsq1(itab.m_icols); for (unsigned k = 0; k < itab.m_icols; k++) { - const ICol& icol = *itab.m_icol[k]; + unsigned k2 = rsq1.next(); + const ICol& icol = *itab.m_icol[k2]; const Col& col = icol.m_col; unsigned m = col.m_num; const Val& val = *m_val[m]; @@ -2365,8 +2423,10 @@ Row::selrow(Par par) const Tab& tab = m_tab; CHK(con.getNdbOperation(m_tab) == 0); CHKCON(con.m_op->readTuple() == 0, con); + Rsq rsq1(tab.m_cols); for (unsigned k = 0; k < tab.m_cols; k++) { - const Val& val = *m_val[k]; + unsigned k2 = rsq1.next(); + const Val& val = *m_val[k2]; const Col& col = val.m_col; if (col.m_pk) CHK(val.equal(par) == 0); @@ -2382,8 +2442,10 @@ Row::selrow(Par par, const ITab& itab) assert(itab.m_type == ITab::UniqueHashIndex && &itab.m_tab == &tab); CHK(con.getNdbIndexOperation(itab, tab) == 0); CHKCON(con.m_op->readTuple() == 0, con); + Rsq rsq1(itab.m_icols); for (unsigned k = 0; k < itab.m_icols; k++) { - const ICol& icol = *itab.m_icol[k]; + unsigned k2 = rsq1.next(); + const ICol& icol = *itab.m_icol[k2]; const Col& col = icol.m_col; unsigned m = col.m_num; const Val& val = *m_val[m]; @@ -2397,8 +2459,10 @@ Row::setrow(Par par) { Con& con = par.con(); const Tab& tab = m_tab; + Rsq rsq1(tab.m_cols); for (unsigned k = 0; k < tab.m_cols; k++) { - const Val& val = *m_val[k]; + unsigned k2 = rsq1.next(); + const Val& val = *m_val[k2]; const Col& col = val.m_col; if (! col.m_pk) CHK(val.setval(par) == 0); @@ -2810,8 +2874,10 @@ Set::getval(Par par) { Con& con = par.con(); const Tab& tab = m_tab; + Rsq rsq1(tab.m_cols); for (unsigned k = 0; k < tab.m_cols; k++) { - CHK(con.getValue(k, m_rec[k]) == 0); + unsigned k2 = rsq1.next(); + CHK(con.getValue(k2, m_rec[k2]) == 0); } return 0; } @@ -3093,18 +3159,16 @@ int BSet::setbnd(Par par) const { if (m_bvals != 0) { - unsigned p1 = urandom(m_bvals); - unsigned p2 = 10009; // prime - // random order + Rsq rsq1(m_bvals); for (unsigned j = 0; j < m_bvals; j++) { - unsigned k = p1 + p2 * j; - const BVal& bval = *m_bval[k % m_bvals]; + unsigned j2 = rsq1.next(); + const BVal& bval = *m_bval[j2]; CHK(bval.setbnd(par) == 0); } // duplicate if (urandom(5) == 0) { - unsigned k = urandom(m_bvals); - const BVal& bval = *m_bval[k]; + unsigned j3 = urandom(m_bvals); + const BVal& bval = *m_bval[j3]; CHK(bval.setbnd(par) == 0); } } @@ -3118,19 +3182,16 @@ BSet::setflt(Par par) const CHK(con.getNdbScanFilter() == 0); CHK(con.beginFilter(NdbScanFilter::AND) == 0); if (m_bvals != 0) { - unsigned p1 = urandom(m_bvals); - unsigned p2 = 10009; // prime - const unsigned extras = 5; - // random order - for (unsigned j = 0; j < m_bvals + extras; j++) { - unsigned k = p1 + p2 * j; - const BVal& bval = *m_bval[k % m_bvals]; + Rsq rsq1(m_bvals); + for (unsigned j = 0; j < m_bvals; j++) { + unsigned j2 = rsq1.next(); + const BVal& bval = *m_bval[j2]; CHK(bval.setflt(par) == 0); } // duplicate if (urandom(5) == 0) { - unsigned k = urandom(m_bvals); - const BVal& bval = *m_bval[k]; + unsigned j3 = urandom(m_bvals); + const BVal& bval = *m_bval[j3]; CHK(bval.setflt(par) == 0); } } @@ -4176,7 +4237,8 @@ readverifyfull(Par par) CHK(scanreadtable(par) == 0); // once more via tup scan par.m_tupscan = true; - CHK(scanreadtable(par) == 0); + if (NDB_VERSION < MAKE_VERSION(5, 1, 0)) //TODO + CHK(scanreadtable(par) == 0); } // each thread scans different indexes for (unsigned i = 0; i < tab.m_itabs; i++) { diff --git a/storage/ndb/test/run-test/daily-basic-tests.txt b/storage/ndb/test/run-test/daily-basic-tests.txt index e3d7501e6f7..ce9f97a9cb2 100644 --- a/storage/ndb/test/run-test/daily-basic-tests.txt +++ b/storage/ndb/test/run-test/daily-basic-tests.txt @@ -516,6 +516,10 @@ max-time: 500 cmd: testNdbApi args: -n ReadWithoutGetValue +max-time: 500 +cmd: testNdbApi +args: -n Bug_11133 T1 + #max-time: 500 #cmd: testInterpreter #args: T1 diff --git a/storage/ndb/tools/restore/Restore.cpp b/storage/ndb/tools/restore/Restore.cpp index 81a8d4aba41..b53255820db 100644 --- a/storage/ndb/tools/restore/Restore.cpp +++ b/storage/ndb/tools/restore/Restore.cpp @@ -765,6 +765,7 @@ RestoreLogIterator::RestoreLogIterator(const RestoreMetaData & md) setLogFile(md, 0); m_count = 0; + m_last_gci = 0; } const LogEntry * @@ -772,7 +773,6 @@ RestoreLogIterator::getNextLogEntry(int & res) { // Read record length typedef BackupFormat::LogFile::LogEntry LogE; - Uint32 gcp= 0; LogE * logE= 0; Uint32 len= ~0; const Uint32 stopGCP = m_metaData.getStopGCP(); @@ -802,10 +802,10 @@ RestoreLogIterator::getNextLogEntry(int & res) { if(hasGcp){ len--; - gcp = ntohl(logE->Data[len-2]); + m_last_gci = ntohl(logE->Data[len-2]); } - } while(gcp > stopGCP + 1); - + } while(m_last_gci > stopGCP + 1); + m_logEntry.m_table = m_metaData.getTable(logE->TableId); switch(logE->TriggerEvent){ case TriggerEvent::TE_INSERT: diff --git a/storage/ndb/tools/restore/Restore.hpp b/storage/ndb/tools/restore/Restore.hpp index d7f6e3b7799..85793baf9df 100644 --- a/storage/ndb/tools/restore/Restore.hpp +++ b/storage/ndb/tools/restore/Restore.hpp @@ -361,6 +361,7 @@ private: const RestoreMetaData & m_metaData; Uint32 m_count; + Uint32 m_last_gci; LogEntry m_logEntry; public: RestoreLogIterator(const RestoreMetaData &); diff --git a/storage/ndb/tools/restore/consumer_restore.cpp b/storage/ndb/tools/restore/consumer_restore.cpp index d72b82569e2..b20f9fd3204 100644 --- a/storage/ndb/tools/restore/consumer_restore.cpp +++ b/storage/ndb/tools/restore/consumer_restore.cpp @@ -526,7 +526,14 @@ BackupRestore::logEntry(const LogEntry & tup) << " Exiting..."; exit(-1); } + + if (check != 0) + { + err << "Error defining op: " << trans->getNdbError() << endl; + exit(-1); + } // if + Bitmask<4096> keys; for (Uint32 i= 0; i < tup.size(); i++) { const AttributeS * attr = tup[i]; @@ -539,9 +546,21 @@ BackupRestore::logEntry(const LogEntry & tup) const Uint32 length = (size / 8) * arraySize; if (attr->Desc->m_column->getPrimaryKey()) - op->equal(attr->Desc->attrId, dataPtr, length); + { + if(!keys.get(attr->Desc->attrId)) + { + keys.set(attr->Desc->attrId); + check= op->equal(attr->Desc->attrId, dataPtr, length); + } + } else - op->setValue(attr->Desc->attrId, dataPtr, length); + check= op->setValue(attr->Desc->attrId, dataPtr, length); + + if (check != 0) + { + err << "Error defining op: " << trans->getNdbError() << endl; + exit(-1); + } // if } const int ret = trans->execute(NdbTransaction::Commit); @@ -550,18 +569,25 @@ BackupRestore::logEntry(const LogEntry & tup) // Both insert update and delete can fail during log running // and it's ok // TODO: check that the error is either tuple exists or tuple does not exist? + bool ok= false; + NdbError errobj= trans->getNdbError(); switch(tup.m_type) { case LogEntry::LE_INSERT: + if(errobj.status == NdbError::PermanentError && + errobj.classification == NdbError::ConstraintViolation) + ok= true; break; case LogEntry::LE_UPDATE: - break; case LogEntry::LE_DELETE: + if(errobj.status == NdbError::PermanentError && + errobj.classification == NdbError::NoDataFound) + ok= true; break; } - if (false) + if (!ok) { - err << "execute failed: " << trans->getNdbError() << endl; + err << "execute failed: " << errobj << endl; exit(-1); } } |