From 65255d3540bced78c11c5537d5ce10935a384774 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 11 Apr 2005 20:04:50 +0200 Subject: [PATCH 1/7] don't check record's checksum in REPAIR myisam/mi_dynrec.c: new parameter for _mi_rec_check(). myisam/myisamdef.h: new parameter for _mi_rec_check(). --- myisam/mi_check.c | 7 +++++-- myisam/mi_dynrec.c | 11 ++++------- myisam/myisamdef.h | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 0123278a23f..f710d3a8454 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -971,7 +971,8 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) info->checksum=mi_checksum(info,record); if (param->testflag & (T_EXTEND | T_MEDIUM | T_VERBOSE)) { - if (_mi_rec_check(info,record, info->rec_buff,block_info.rec_len)) + if (_mi_rec_check(info,record, info->rec_buff,block_info.rec_len, + test(info->s->calc_checksum))) { mi_check_print_error(param,"Found wrong packed record at %s", llstr(start_recpos,llbuff)); @@ -3024,7 +3025,9 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) if ((param->testflag & (T_EXTEND | T_REP)) || searching) { if (_mi_rec_check(info, sort_param->record, sort_param->rec_buff, - sort_param->find_length)) + sort_param->find_length, + (param->testflag & T_QUICK) && + test(info->s->calc_checksum))) { mi_check_print_info(param,"Found wrong packed record at %s", llstr(sort_param->start_recpos,llbuff)); diff --git a/myisam/mi_dynrec.c b/myisam/mi_dynrec.c index 0b8d3c97872..43783ca2d36 100644 --- a/myisam/mi_dynrec.c +++ b/myisam/mi_dynrec.c @@ -806,7 +806,7 @@ uint _mi_rec_pack(MI_INFO *info, register byte *to, register const byte *from) */ my_bool _mi_rec_check(MI_INFO *info,const char *record, byte *rec_buff, - ulong packed_length) + ulong packed_length, my_bool with_checksum) { uint length,new_length,flag,bit,i; char *pos,*end,*packpos,*to; @@ -901,13 +901,10 @@ my_bool _mi_rec_check(MI_INFO *info,const char *record, byte *rec_buff, if (packed_length != (uint) (to - rec_buff) + test(info->s->calc_checksum) || (bit != 1 && (flag & ~(bit - 1)))) goto err; - if (info->s->calc_checksum) + if (with_checksum && ((uchar) info->checksum != (uchar) *to)) { - if ((uchar) info->checksum != (uchar) *to) - { - DBUG_PRINT("error",("wrong checksum for row")); - goto err; - } + DBUG_PRINT("error",("wrong checksum for row")); + goto err; } DBUG_RETURN(0); diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h index 916932c9eb3..a41bcf5449b 100644 --- a/myisam/myisamdef.h +++ b/myisam/myisamdef.h @@ -582,7 +582,7 @@ extern byte *mi_alloc_rec_buff(MI_INFO *,ulong, byte**); extern ulong _mi_rec_unpack(MI_INFO *info,byte *to,byte *from, ulong reclength); extern my_bool _mi_rec_check(MI_INFO *info,const char *record, byte *packpos, - ulong reclength); + ulong packed_length, my_bool with_checkum); extern int _mi_write_part_record(MI_INFO *info,my_off_t filepos,ulong length, my_off_t next_filepos,byte **record, ulong *reclength,int *flag); From c99e332cf1c96eca8c6edd4792a972cecc2fa092 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 11 Apr 2005 22:36:07 +0200 Subject: [PATCH 2/7] backport kill.test fix from 5.0 --- mysql-test/r/kill.result | 2 +- mysql-test/t/kill.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/kill.result b/mysql-test/r/kill.result index dcf17e4bf52..ba9ba2833f6 100644 --- a/mysql-test/r/kill.result +++ b/mysql-test/r/kill.result @@ -6,7 +6,7 @@ select ((@id := kill_id) - kill_id) from t1; 0 kill @id; select 1; -ERROR HY000: MySQL server has gone away +Got one of the listed errors select ((@id := kill_id) - kill_id) from t1; ((@id := kill_id) - kill_id) 0 diff --git a/mysql-test/t/kill.test b/mysql-test/t/kill.test index 4afb60a7bdd..1fec41d8ee4 100644 --- a/mysql-test/t/kill.test +++ b/mysql-test/t/kill.test @@ -27,7 +27,7 @@ connection con1; --disable_reconnect # this statement should fail ---error 2006 +--error 2006,2013 select 1; --enable_reconnect # this should work, and we should have a new connection_id() From 583d38f3f7f39d8124ae5785d3217b1d08f39c6d Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 12 Apr 2005 13:36:43 +0200 Subject: [PATCH 3/7] bug#9757 - ndb Impl. stupid mgm lock against shutting down 2 nodes simultaniously Add some more dump ndb/src/kernel/blocks/dbdih/DbdihMain.cpp: Impl. 2 new dump 1) to query nf handling state 2) that impl. sending of arbitrary signal... to be used with extreme care ndb/src/kernel/main.cpp: enable critical and warnings in out file ndb/src/mgmsrv/MgmtSrvr.cpp: call handleStopReply on nfCompleteRep instead ndb/src/mgmsrv/MgmtSrvr.hpp: call handleStopReply on nfCompleteRep instead --- ndb/src/kernel/blocks/dbdih/DbdihMain.cpp | 45 +++++++++++++++++++++++ ndb/src/kernel/main.cpp | 2 + ndb/src/mgmsrv/MgmtSrvr.cpp | 13 +++++-- ndb/src/mgmsrv/MgmtSrvr.hpp | 2 +- 4 files changed, 57 insertions(+), 5 deletions(-) diff --git a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp index 0bc8351a9db..efd1740651c 100644 --- a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp +++ b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp @@ -69,6 +69,9 @@ #include #include +#include +extern EventLogger g_eventLogger; + #define SYSFILE ((Sysfile *)&sysfileData[0]) #define RETURN_IF_NODE_NOT_ALIVE(node) \ @@ -13103,6 +13106,48 @@ Dbdih::execDUMP_STATE_ORD(Signal* signal) } } } + + if(dumpState->args[0] == 7019 && signal->getLength() == 2) + { + char buf2[8+1]; + NodeRecordPtr nodePtr; + nodePtr.i = signal->theData[1]; + ptrCheckGuard(nodePtr, MAX_NDB_NODES, nodeRecord); + infoEvent("NF Node %d tc: %d lqh: %d dih: %d dict: %d recNODE_FAILREP: %d", + nodePtr.i, + nodePtr.p->dbtcFailCompleted, + nodePtr.p->dblqhFailCompleted, + nodePtr.p->dbdihFailCompleted, + nodePtr.p->dbdictFailCompleted, + nodePtr.p->recNODE_FAILREP); + infoEvent(" m_NF_COMPLETE_REP: %s m_nodefailSteps: %s", + nodePtr.p->m_NF_COMPLETE_REP.getText(), + nodePtr.p->m_nodefailSteps.getText(buf2)); + } + + if(dumpState->args[0] == 7020 && signal->getLength() > 3) + { + Uint32 gsn= signal->theData[1]; + Uint32 block= signal->theData[2]; + Uint32 length= signal->length() - 3; + memmove(signal->theData, signal->theData+3, 4*length); + sendSignal(numberToRef(block, getOwnNodeId()), gsn, signal, length, JBB); + + warningEvent("-- SENDING CUSTOM SIGNAL --"); + char buf[100], buf2[100]; + buf2[0]= 0; + for(Uint32 i = 0; itheData[i]); + snprintf(buf2, 100, "%s", buf); + } + warningEvent("gsn: %d block: %s, length: %d theData: %s", + gsn, getBlockName(block, "UNKNOWN"), length, buf); + + g_eventLogger.warning("-- SENDING CUSTOM SIGNAL --"); + g_eventLogger.warning("gsn: %d block: %s, length: %d theData: %s", + gsn, getBlockName(block, "UNKNOWN"), length, buf); + } if(dumpState->args[0] == DumpStateOrd::DihDumpLCPState){ infoEvent("-- Node %d LCP STATE --", getOwnNodeId()); diff --git a/ndb/src/kernel/main.cpp b/ndb/src/kernel/main.cpp index e6e0a7ca877..1e5cd5270e4 100644 --- a/ndb/src/kernel/main.cpp +++ b/ndb/src/kernel/main.cpp @@ -58,7 +58,9 @@ int main(int argc, char** argv) // Print to stdout/console g_eventLogger.createConsoleHandler(); g_eventLogger.setCategory("NDB"); + g_eventLogger.enable(Logger::LL_ON, Logger::LL_CRITICAL); g_eventLogger.enable(Logger::LL_ON, Logger::LL_ERROR); + g_eventLogger.enable(Logger::LL_ON, Logger::LL_WARNING); globalEmulatorData.create(); diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp index 3bc00b18f50..98cdcdca2f7 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -2061,7 +2061,7 @@ MgmtSrvr::handleStopReply(NodeId nodeId, Uint32 errCode) } void -MgmtSrvr::handleStatus(NodeId nodeId, bool alive) +MgmtSrvr::handleStatus(NodeId nodeId, bool alive, bool nfComplete) { DBUG_ENTER("MgmtSrvr::handleStatus"); Uint32 theData[25]; @@ -2070,9 +2070,15 @@ MgmtSrvr::handleStatus(NodeId nodeId, bool alive) m_started_nodes.push_back(nodeId); theData[0] = EventReport::Connected; } else { - handleStopReply(nodeId, 0); theData[0] = EventReport::Disconnected; + if(nfComplete) + { + theData[0] = EventReport::NodeFailCompleted; + handleStopReply(nodeId, 0); + return; + } } + eventReport(_ownNodeId, theData); DBUG_VOID_RETURN; } @@ -2097,8 +2103,7 @@ MgmtSrvr::nodeStatusNotification(void* mgmSrv, Uint32 nodeId, { DBUG_ENTER("MgmtSrvr::nodeStatusNotification"); DBUG_PRINT("enter",("nodeid= %d, alive= %d, nfComplete= %d", nodeId, alive, nfComplete)); - if(!(!alive && nfComplete)) - ((MgmtSrvr*)mgmSrv)->handleStatus(nodeId, alive); + ((MgmtSrvr*)mgmSrv)->handleStatus(nodeId, alive, nfComplete); DBUG_VOID_RETURN; } diff --git a/ndb/src/mgmsrv/MgmtSrvr.hpp b/ndb/src/mgmsrv/MgmtSrvr.hpp index 6378e763363..a05b29b7f31 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.hpp +++ b/ndb/src/mgmsrv/MgmtSrvr.hpp @@ -573,7 +573,7 @@ private: // Returns: - //************************************************************************** - void handleStatus(NodeId nodeId, bool alive); + void handleStatus(NodeId nodeId, bool alive, bool nfComplete); //************************************************************************** // Description: Handle the death of a process // Parameters: From efd06e1910797dd801e4156f1e654561d345cee6 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 12 Apr 2005 13:56:24 +0200 Subject: [PATCH 4/7] bug#9757 - ndb - post review use DBUG_RETURN ndb/src/mgmsrv/MgmtSrvr.cpp: bug#9757 - ndb use DBUG_RETURN --- ndb/src/mgmsrv/MgmtSrvr.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp index 98cdcdca2f7..fb05e57e138 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -2073,9 +2073,8 @@ MgmtSrvr::handleStatus(NodeId nodeId, bool alive, bool nfComplete) theData[0] = EventReport::Disconnected; if(nfComplete) { - theData[0] = EventReport::NodeFailCompleted; handleStopReply(nodeId, 0); - return; + DBUG_VOID_RETURN; } } From dec90f5b36f3977849009031fcd6b1891c08a884 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 12 Apr 2005 16:12:34 +0300 Subject: [PATCH 5/7] InnoDB: Ignore character set mismatch in ALTER TABLE and RENAME TABLE if foreign_key_checks=0. (Bug #9802) innobase/dict/dict0dict.c: dict_foreign_add_to_cache(): Add flag check_types. If the flag is FALSE, ignore character set mismatch. innobase/dict/dict0load.c: dict_load_foreign(), dict_load_foreigns(): Add flag check_types. If the flag is FALSE, differences in character sets will be ignored. innobase/include/dict0dict.h: dict_foreign_add_to_cache(): Add flag check_types. If the flag is FALSE, differences in character sets will be ignored. innobase/include/dict0load.h: dict_load_foreigns(): Add flag check_types. If the flag is FALSE, differences in character sets will be ignored. innobase/row/row0mysql.c: row_table_add_foreign_constraints(), row_rename_table_for_mysql(): Pass trx->check_foreigns to dict_load_foreigns() sql/ha_innodb.cc: ha_innobase::rename_table(): Clear trx->check_foreign if necessary. --- innobase/dict/dict0dict.c | 19 ++++++++++++++++--- innobase/dict/dict0load.c | 15 +++++++-------- innobase/include/dict0dict.h | 3 ++- innobase/include/dict0load.h | 3 ++- innobase/row/row0mysql.c | 8 +++----- sql/ha_innodb.cc | 4 ++++ 6 files changed, 34 insertions(+), 18 deletions(-) diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c index cb48c86c541..bbc47fe9c2b 100644 --- a/innobase/dict/dict0dict.c +++ b/innobase/dict/dict0dict.c @@ -2167,7 +2167,8 @@ ulint dict_foreign_add_to_cache( /*======================*/ /* out: DB_SUCCESS or error code */ - dict_foreign_t* foreign) /* in, own: foreign key constraint */ + dict_foreign_t* foreign, /* in, own: foreign key constraint */ + ibool check_types) /* in: TRUE=check type compatibility */ { dict_table_t* for_table; dict_table_t* ref_table; @@ -2203,10 +2204,16 @@ dict_foreign_add_to_cache( } if (for_in_cache->referenced_table == NULL && ref_table) { + dict_index_t* types_idx; + if (check_types) { + types_idx = for_in_cache->foreign_index; + } else { + types_idx = NULL; + } index = dict_foreign_find_index(ref_table, (const char**) for_in_cache->referenced_col_names, for_in_cache->n_fields, - for_in_cache->foreign_index); + types_idx); if (index == NULL) { dict_foreign_error_report(ef, for_in_cache, @@ -2230,10 +2237,16 @@ dict_foreign_add_to_cache( } if (for_in_cache->foreign_table == NULL && for_table) { + dict_index_t* types_idx; + if (check_types) { + types_idx = for_in_cache->referenced_index; + } else { + types_idx = NULL; + } index = dict_foreign_find_index(for_table, (const char**) for_in_cache->foreign_col_names, for_in_cache->n_fields, - for_in_cache->referenced_index); + types_idx); if (index == NULL) { dict_foreign_error_report(ef, for_in_cache, diff --git a/innobase/dict/dict0load.c b/innobase/dict/dict0load.c index e5aafcad2c2..0d58823a2ea 100644 --- a/innobase/dict/dict0load.c +++ b/innobase/dict/dict0load.c @@ -873,7 +873,7 @@ dict_load_table( dict_load_indexes(table, heap); - err = dict_load_foreigns(table->name); + err = dict_load_foreigns(table->name, TRUE); /* if (err != DB_SUCCESS) { @@ -1092,8 +1092,9 @@ ulint dict_load_foreign( /*==============*/ /* out: DB_SUCCESS or error code */ - const char* id) /* in: foreign constraint id as a + const char* id, /* in: foreign constraint id as a null-terminated string */ + ibool check_types)/* in: TRUE=check type compatibility */ { dict_foreign_t* foreign; dict_table_t* sys_foreign; @@ -1105,7 +1106,6 @@ dict_load_foreign( rec_t* rec; byte* field; ulint len; - ulint err; mtr_t mtr; #ifdef UNIV_SYNC_DEBUG @@ -1205,9 +1205,7 @@ dict_load_foreign( a new foreign key constraint but loading one from the data dictionary. */ - err = dict_foreign_add_to_cache(foreign); - - return(err); + return(dict_foreign_add_to_cache(foreign, check_types)); } /*************************************************************************** @@ -1221,7 +1219,8 @@ ulint dict_load_foreigns( /*===============*/ /* out: DB_SUCCESS or error code */ - const char* table_name) /* in: table name */ + const char* table_name, /* in: table name */ + ibool check_types) /* in: TRUE=check type compatibility */ { btr_pcur_t pcur; mem_heap_t* heap; @@ -1320,7 +1319,7 @@ loop: /* Load the foreign constraint definition to the dictionary cache */ - err = dict_load_foreign(id); + err = dict_load_foreign(id, check_types); if (err != DB_SUCCESS) { btr_pcur_close(&pcur); diff --git a/innobase/include/dict0dict.h b/innobase/include/dict0dict.h index ca632691450..745a776bda1 100644 --- a/innobase/include/dict0dict.h +++ b/innobase/include/dict0dict.h @@ -189,7 +189,8 @@ ulint dict_foreign_add_to_cache( /*======================*/ /* out: DB_SUCCESS or error code */ - dict_foreign_t* foreign); /* in, own: foreign key constraint */ + dict_foreign_t* foreign, /* in, own: foreign key constraint */ + ibool check_types); /* in: TRUE=check type compatibility */ /************************************************************************* Checks if a table is referenced by foreign keys. */ diff --git a/innobase/include/dict0load.h b/innobase/include/dict0load.h index 1f0a5407140..f13620bc6e8 100644 --- a/innobase/include/dict0load.h +++ b/innobase/include/dict0load.h @@ -81,7 +81,8 @@ ulint dict_load_foreigns( /*===============*/ /* out: DB_SUCCESS or error code */ - const char* table_name); /* in: table name */ + const char* table_name, /* in: table name */ + ibool check_types); /* in: TRUE=check type compatibility */ /************************************************************************ Prints to the standard output information on all tables found in the data dictionary system table. */ diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index e2b34e6e3f1..9410f2ce7cc 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -1796,7 +1796,7 @@ row_table_add_foreign_constraints( if (err == DB_SUCCESS) { /* Check that also referencing constraints are ok */ - err = dict_load_foreigns(name); + err = dict_load_foreigns(name, trx->check_foreigns); } if (err != DB_SUCCESS) { @@ -3204,6 +3204,8 @@ row_rename_table_for_mysql( goto funct_exit; } + err = dict_load_foreigns(new_name, trx->check_foreigns); + if (row_is_mysql_tmp_table_name(old_name)) { /* MySQL is doing an ALTER TABLE command and it @@ -3213,8 +3215,6 @@ row_rename_table_for_mysql( table. But we want to load also the foreign key constraint definitions for the original table name. */ - err = dict_load_foreigns(new_name); - if (err != DB_SUCCESS) { ut_print_timestamp(stderr); fputs(" InnoDB: Error: in ALTER TABLE ", @@ -3233,8 +3233,6 @@ row_rename_table_for_mysql( trx->error_state = DB_SUCCESS; } } else { - err = dict_load_foreigns(new_name); - if (err != DB_SUCCESS) { ut_print_timestamp(stderr); diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 322d5188a75..bd2a5139021 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -4183,6 +4183,10 @@ ha_innobase::rename_table( trx->mysql_thd = current_thd; trx->mysql_query_str = &((*current_thd).query); + if (current_thd->options & OPTION_NO_FOREIGN_KEY_CHECKS) { + trx->check_foreigns = FALSE; + } + name_len1 = strlen(from); name_len2 = strlen(to); From 9faf085b9f831e8bb77ba106d8561b0b0baafdc6 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Apr 2005 12:42:23 +0200 Subject: [PATCH 6/7] Fix for bug#9813: Test 'ndb_basic': Autoincrement fails in 64 bit --- ndb/src/ndbapi/Ndb.cpp | 42 +++++++++++++++++++++++++----------------- sql/ha_ndbcluster.cc | 34 ++++++++++++++++++++++------------ sql/mysqld.cc | 2 +- 3 files changed, 48 insertions(+), 30 deletions(-) diff --git a/ndb/src/ndbapi/Ndb.cpp b/ndb/src/ndbapi/Ndb.cpp index b5493622b70..9d520d5eac9 100644 --- a/ndb/src/ndbapi/Ndb.cpp +++ b/ndb/src/ndbapi/Ndb.cpp @@ -722,26 +722,28 @@ Remark: Returns a new TupleId to the application. Uint64 Ndb::getAutoIncrementValue(const char* aTableName, Uint32 cacheSize) { - DEBUG_TRACE("getAutoIncrementValue"); + DBUG_ENTER("getAutoIncrementValue"); const char * internalTableName = internalizeTableName(aTableName); Ndb_local_table_info *info= theDictionary->get_local_table_info(internalTableName, false); if (info == 0) - return ~0; + DBUG_RETURN(~(Uint64)0); const NdbTableImpl *table= info->m_table_impl; Uint64 tupleId = getTupleIdFromNdb(table->m_tableId, cacheSize); - return tupleId; + DBUG_PRINT("info", ("value %u", tupleId)); + DBUG_RETURN(tupleId); } Uint64 Ndb::getAutoIncrementValue(const NdbDictionary::Table * aTable, Uint32 cacheSize) { - DEBUG_TRACE("getAutoIncrementValue"); + DBUG_ENTER("getAutoIncrementValue"); if (aTable == 0) - return ~0; + DBUG_RETURN(~(Uint64)0); const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable); Uint64 tupleId = getTupleIdFromNdb(table->m_tableId, cacheSize); - return tupleId; + DBUG_PRINT("info", ("value %u", tupleId)); + DBUG_RETURN(tupleId); } Uint64 @@ -749,46 +751,52 @@ Ndb::getTupleIdFromNdb(const char* aTableName, Uint32 cacheSize) { const NdbTableImpl* table = theDictionary->getTable(aTableName); if (table == 0) - return ~0; + return ~(Uint64)0; return getTupleIdFromNdb(table->m_tableId, cacheSize); } Uint64 Ndb::getTupleIdFromNdb(Uint32 aTableId, Uint32 cacheSize) { + DBUG_ENTER("getTupleIdFromNdb"); if ( theFirstTupleId[aTableId] != theLastTupleId[aTableId] ) { theFirstTupleId[aTableId]++; - return theFirstTupleId[aTableId]; + DBUG_PRINT("info", ("next cached value %u", theFirstTupleId[aTableId])); + DBUG_RETURN(theFirstTupleId[aTableId]); } else // theFirstTupleId == theLastTupleId { - return opTupleIdOnNdb(aTableId, cacheSize, 0); + DBUG_PRINT("info",("reading %u values from database", + (cacheSize == 0) ? 1 : cacheSize)); + DBUG_RETURN(opTupleIdOnNdb(aTableId, (cacheSize == 0) ? 1 : cacheSize, 0)); } } Uint64 Ndb::readAutoIncrementValue(const char* aTableName) { - DEBUG_TRACE("readtAutoIncrementValue"); + DBUG_ENTER("readtAutoIncrementValue"); const NdbTableImpl* table = theDictionary->getTable(aTableName); if (table == 0) { theError= theDictionary->getNdbError(); - return ~0; + DBUG_RETURN(~(Uint64)0); } Uint64 tupleId = readTupleIdFromNdb(table->m_tableId); - return tupleId; + DBUG_PRINT("info", ("value %u", tupleId)); + DBUG_RETURN(tupleId); } Uint64 Ndb::readAutoIncrementValue(const NdbDictionary::Table * aTable) { - DEBUG_TRACE("readtAutoIncrementValue"); + DBUG_ENTER("readtAutoIncrementValue"); if (aTable == 0) - return ~0; + DBUG_RETURN(~(Uint64)0); const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable); Uint64 tupleId = readTupleIdFromNdb(table->m_tableId); - return tupleId; + DBUG_PRINT("info", ("value %u", tupleId)); + DBUG_RETURN(tupleId); } Uint64 @@ -821,7 +829,7 @@ Ndb::setAutoIncrementValue(const NdbDictionary::Table * aTable, Uint64 val, bool { DEBUG_TRACE("setAutoIncrementValue " << val); if (aTable == 0) - return ~0; + return ~(Uint64)0; const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable); return setTupleIdInNdb(table->m_tableId, val, increase); } @@ -971,7 +979,7 @@ Ndb::opTupleIdOnNdb(Uint32 aTableId, Uint64 opValue, Uint32 op) setDatabaseName(currentDb.c_str()); setDatabaseSchemaName(currentSchema.c_str()); - return ~0; + return ~(Uint64)0; } Uint32 diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 7025ac2cd1a..fc1e838fbd2 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -1854,7 +1854,7 @@ int ha_ndbcluster::write_row(byte *record) m_rows_inserted++; no_uncommitted_rows_update(1); m_bulk_insert_not_flushed= TRUE; - if ((m_rows_to_insert == 1) || + if ((m_rows_to_insert == (ha_rows) 1) || ((m_rows_inserted % m_bulk_insert_rows) == 0) || set_blob_value) { @@ -2919,8 +2919,12 @@ void ha_ndbcluster::start_bulk_insert(ha_rows rows) DBUG_ENTER("start_bulk_insert"); DBUG_PRINT("enter", ("rows: %d", (int)rows)); - m_rows_inserted= 0; - m_rows_to_insert= rows; + m_rows_inserted= (ha_rows) 0; + if (rows == (ha_rows) 0) + /* We don't know how many will be inserted, guess */ + m_rows_to_insert= m_autoincrement_prefetch; + else + m_rows_to_insert= rows; /* Calculate how many rows that should be inserted @@ -2954,7 +2958,7 @@ int ha_ndbcluster::end_bulk_insert() // Send rows to NDB DBUG_PRINT("info", ("Sending inserts to NDB, "\ "rows_inserted:%d, bulk_insert_rows: %d", - m_rows_inserted, m_bulk_insert_rows)); + (int) m_rows_inserted, (int) m_bulk_insert_rows)); m_bulk_insert_not_flushed= FALSE; if (execute_no_commit(this,trans) != 0) { no_uncommitted_rows_execute_failure(); @@ -2962,8 +2966,8 @@ int ha_ndbcluster::end_bulk_insert() } } - m_rows_inserted= 0; - m_rows_to_insert= 1; + m_rows_inserted= (ha_rows) 0; + m_rows_to_insert= (ha_rows) 1; DBUG_RETURN(error); } @@ -3152,7 +3156,8 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type) // store thread specific data first to set the right context m_force_send= thd->variables.ndb_force_send; m_ha_not_exact_count= !thd->variables.ndb_use_exact_count; - m_autoincrement_prefetch= thd->variables.ndb_autoincrement_prefetch_sz; + m_autoincrement_prefetch= + (ha_rows) thd->variables.ndb_autoincrement_prefetch_sz; if (!thd->transaction.on) m_transaction_on= FALSE; else @@ -3566,7 +3571,7 @@ static int create_ndb_column(NDBCOL &col, static void ndb_set_fragmentation(NDBTAB &tab, TABLE *form, uint pk_length) { - if (form->max_rows == 0) /* default setting, don't set fragmentation */ + if (form->max_rows == (ha_rows) 0) /* default setting, don't set fragmentation */ return; /** * get the number of fragments right @@ -3929,7 +3934,12 @@ longlong ha_ndbcluster::get_auto_increment() DBUG_ENTER("get_auto_increment"); DBUG_PRINT("enter", ("m_tabname: %s", m_tabname)); Ndb *ndb= get_ndb(); + + if (m_rows_inserted > m_rows_to_insert) + /* We guessed too low */ + m_rows_to_insert+= m_autoincrement_prefetch; int cache_size= + (int) (m_rows_to_insert - m_rows_inserted < m_autoincrement_prefetch) ? m_rows_to_insert - m_rows_inserted : (m_rows_to_insert > m_autoincrement_prefetch) ? @@ -3964,9 +3974,9 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg): m_primary_key_update(FALSE), m_retrieve_all_fields(FALSE), m_retrieve_primary_key(FALSE), - m_rows_to_insert(1), - m_rows_inserted(0), - m_bulk_insert_rows(1024), + m_rows_to_insert((ha_rows) 1), + m_rows_inserted((ha_rows) 0), + m_bulk_insert_rows((ha_rows) 1024), m_bulk_insert_not_flushed(FALSE), m_ops_pending(0), m_skip_auto_increment(TRUE), @@ -3976,7 +3986,7 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg): m_dupkey((uint) -1), m_ha_not_exact_count(FALSE), m_force_send(TRUE), - m_autoincrement_prefetch(32), + m_autoincrement_prefetch((ha_rows) 32), m_transaction_on(TRUE), m_use_local_query_cache(FALSE) { diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 0590333a20f..ade747ac180 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4548,7 +4548,7 @@ Disable with --skip-ndbcluster (will save memory).", "Specify number of autoincrement values that are prefetched.", (gptr*) &global_system_variables.ndb_autoincrement_prefetch_sz, (gptr*) &global_system_variables.ndb_autoincrement_prefetch_sz, - 0, GET_INT, REQUIRED_ARG, 32, 1, 256, 0, 0, 0}, + 0, GET_ULONG, REQUIRED_ARG, 32, 1, 256, 0, 0, 0}, {"ndb-force-send", OPT_NDB_FORCE_SEND, "Force send of buffers to ndb immediately without waiting for " "other threads.", From a160dcb73c97647efa6e6758a200062efd733319 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Apr 2005 13:17:39 +0200 Subject: [PATCH 7/7] Fixed failed merge --- sql/ha_ndbcluster.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index f1ec5e1c56b..d9ce1909c6d 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -3728,7 +3728,7 @@ static int create_ndb_column(NDBCOL &col, static void ndb_set_fragmentation(NDBTAB &tab, TABLE *form, uint pk_length) { - if (form->max_rows == (ha_rows) 0) /* default setting, don't set fragmentation */ + if (form->s->max_rows == (ha_rows) 0) /* default setting, don't set fragmentation */ return; /** * get the number of fragments right