From f106321eae6cc1529ad6c3bc25286ff7b1a8014b Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 29 Jan 2007 15:17:40 +0000 Subject: [PATCH 01/13] Bug#23354 Add explaination when ndb_mgm do restart ndb/src/mgmclient/CommandInterpreter.cpp: Add printout to indicate the usage of "-n" --- ndb/src/mgmclient/CommandInterpreter.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ndb/src/mgmclient/CommandInterpreter.cpp b/ndb/src/mgmclient/CommandInterpreter.cpp index 420dbd121a1..d6952f0b0eb 100644 --- a/ndb/src/mgmclient/CommandInterpreter.cpp +++ b/ndb/src/mgmclient/CommandInterpreter.cpp @@ -2029,6 +2029,9 @@ CommandInterpreter::executeRestart(Vector &command_list, return -1; } + if (!nostart) + ndbout_c("Shutting down nodes with \"-n, no start\" option, to subsequently start the nodes."); + result= ndb_mgm_restart3(m_mgmsrv, no_of_nodes, node_ids, initialstart, nostart, abort, &need_disconnect); From ba234148927efb3b226e6814bb36a9e6139762c3 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 Mar 2007 18:13:10 +0800 Subject: [PATCH 02/13] Bug#25295, ALTER TABLE operations for NDB tables require inclusion of ENGINE=ndbcluster. this patch of bug25295 depends on the patches of bug25877 and bug25880 sql/ha_ndbcluster.cc: add check for storage media changes between old and new table when do 'alter table ...' --- sql/ha_ndbcluster.cc | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 4aa6d4d3167..1580bfb8b6f 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -10641,6 +10641,36 @@ bool ha_ndbcluster::check_if_incompatible_data(HA_CREATE_INFO *create_info, if (field->flags & FIELD_IN_ADD_INDEX) ai=1; } + + char tablespace_name[FN_LEN]; + if (get_tablespace_name(current_thd, tablespace_name, FN_LEN)) + { + if (create_info->tablespace) + { + if (strcmp(create_info->tablespace, tablespace_name)) + { + DBUG_PRINT("info", ("storage media is changed, old tablespace=%s, new tablespace=%s", + tablespace_name, create_info->tablespace)); + DBUG_RETURN(COMPATIBLE_DATA_NO); + } + } + else + { + DBUG_PRINT("info", ("storage media is changed, old is DISK and tablespace=%s, new is MEM", + tablespace_name)); + DBUG_RETURN(COMPATIBLE_DATA_NO); + } + } + else + { + if (create_info->storage_media != HA_SM_MEMORY) + { + DBUG_PRINT("info", ("storage media is changed, old is MEM, new is DISK and tablespace=%s", + create_info->tablespace)); + DBUG_RETURN(COMPATIBLE_DATA_NO); + } + } + if (table_changes != IS_EQUAL_YES) DBUG_RETURN(COMPATIBLE_DATA_NO); From 4c07323096d5d45f49352e8e3b41701416246ff2 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 Mar 2007 10:36:20 +0800 Subject: [PATCH 03/13] BUG#21699 DROP last DATAFILE from TABLESPACE even though there are still table in it. And it gives the cofusing error message. mysql-test/r/ndb_dd_basic.result: adding some test result for increasing test codes. mysql-test/t/ndb_dd_basic.test: adding some test codes for nodatafile in tablespace. storage/ndb/include/kernel/signaldata/Extent.hpp: Add NoDatafile error code when allocating extent. storage/ndb/src/kernel/blocks/tsman.cpp: when there is no datafile in spacefile , it should return NoDatafile error code, rather than NoExtentAvailable. storage/ndb/src/ndbapi/ndberror.c: add no datafile error code and corresponding error message for NoDatafile --- mysql-test/r/ndb_dd_basic.result | 28 +++++++++++++ mysql-test/t/ndb_dd_basic.test | 40 +++++++++++++++++++ .../ndb/include/kernel/signaldata/Extent.hpp | 3 +- storage/ndb/src/kernel/blocks/tsman.cpp | 6 +++ storage/ndb/src/ndbapi/ndberror.c | 3 +- 5 files changed, 78 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/ndb_dd_basic.result b/mysql-test/r/ndb_dd_basic.result index 014858e6856..470c2cb9c0e 100644 --- a/mysql-test/r/ndb_dd_basic.result +++ b/mysql-test/r/ndb_dd_basic.result @@ -186,6 +186,34 @@ INITIAL_SIZE 1000000000000K ENGINE = NDB; ERROR HY000: The size number was correct but we don't allow the digit part to be more than 2 billion DROP TABLE t1; +create tablespace ts2 +add datafile 'datafile2_1.dat' +use logfile group lg1 +initial_size 12M +engine ndb; +CREATE TABLE City ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL, +CountryCode char(3) NOT NULL, +District char(20) NOT NULL, +Population int(11) NOT NULL, +PRIMARY KEY (ID) +) ENGINE=ndbcluster +tablespace ts2 +storage disk; +alter tablespace ts2 +drop datafile 'datafile2_1.dat' +engine ndb; +insert +into City (Name,CountryCode,District,Population) +values ('BeiJing','CN','Beijing',2000); +ERROR HY000: Got error 1602 'No datafile in tablespace' from NDBCLUSTER +drop tablespace ts2 +engine ndb; +ERROR HY000: Failed to drop TABLESPACE +drop table City; +drop tablespace ts2 +engine ndb; CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(4) NOT NULL, c CHAR(4) NOT NULL, KEY(b)) TABLESPACE ts1 STORAGE DISK ENGINE = NDB; INSERT INTO t1 VALUES (1,'1','1'), (2,'2','2'), (3,'3','3'); BEGIN; diff --git a/mysql-test/t/ndb_dd_basic.test b/mysql-test/t/ndb_dd_basic.test index 5d43d7997b0..81286d3121f 100644 --- a/mysql-test/t/ndb_dd_basic.test +++ b/mysql-test/t/ndb_dd_basic.test @@ -7,6 +7,10 @@ # Change Date: 2006-01-11 # Change: Cleanup and test rename ################################# +# Change Author: Guangbao Ni +# Change Date: 2007-03-20 +# Change: Test insert data when no datafile in spacetable +################################# -- source include/have_ndb.inc @@ -216,6 +220,42 @@ ENGINE = NDB; DROP TABLE t1; +create tablespace ts2 +add datafile 'datafile2_1.dat' +use logfile group lg1 +initial_size 12M +engine ndb; + +CREATE TABLE City ( + ID int(11) NOT NULL AUTO_INCREMENT, + Name char(35) NOT NULL, + CountryCode char(3) NOT NULL, + District char(20) NOT NULL, + Population int(11) NOT NULL, + PRIMARY KEY (ID) +) ENGINE=ndbcluster +tablespace ts2 +storage disk; + +alter tablespace ts2 +drop datafile 'datafile2_1.dat' +engine ndb; + +#It will give error messages: NoDatafile in tablespace +--error ER_GET_ERRMSG +insert +into City (Name,CountryCode,District,Population) +values ('BeiJing','CN','Beijing',2000); + +--error ER_DROP_FILEGROUP_FAILED +drop tablespace ts2 +engine ndb; + +drop table City; + +drop tablespace ts2 +engine ndb; + ############################ # Test update of mm/dd part ############################ diff --git a/storage/ndb/include/kernel/signaldata/Extent.hpp b/storage/ndb/include/kernel/signaldata/Extent.hpp index 88f2e394233..283ea7ba85a 100644 --- a/storage/ndb/include/kernel/signaldata/Extent.hpp +++ b/storage/ndb/include/kernel/signaldata/Extent.hpp @@ -31,7 +31,8 @@ struct AllocExtentReq { enum ErrorCode { UnmappedExtentPageIsNotImplemented = 1, - NoExtentAvailable = 1601 + NoExtentAvailable = 1601, + NoDatafile = 1602 }; union diff --git a/storage/ndb/src/kernel/blocks/tsman.cpp b/storage/ndb/src/kernel/blocks/tsman.cpp index 99fbc683cee..62aa80a67fe 100644 --- a/storage/ndb/src/kernel/blocks/tsman.cpp +++ b/storage/ndb/src/kernel/blocks/tsman.cpp @@ -1483,6 +1483,12 @@ Tsman::execALLOC_EXTENT_REQ(Signal* signal) { jam(); err = AllocExtentReq::NoExtentAvailable; + Local_datafile_list full_tmp(m_file_pool, ts_ptr.p->m_full_files); + if (tmp.isEmpty() && full_tmp.isEmpty()) + { + jam(); + err = AllocExtentReq::NoDatafile; + } } /** diff --git a/storage/ndb/src/ndbapi/ndberror.c b/storage/ndb/src/ndbapi/ndberror.c index 7dd16f2d57f..b21b64156c8 100644 --- a/storage/ndb/src/ndbapi/ndberror.c +++ b/storage/ndb/src/ndbapi/ndberror.c @@ -201,7 +201,8 @@ ErrorBundle ErrorCodes[] = { { 904, HA_ERR_INDEX_FILE_FULL, IS, "Out of fragment records (increase MaxNoOfOrderedIndexes)" }, { 905, DMEC, IS, "Out of attribute records (increase MaxNoOfAttributes)" }, { 1601, HA_ERR_RECORD_FILE_FULL, IS, "Out extents, tablespace full" }, - + { 1602, DMEC, IS,"No datafile in tablespace" }, + /** * TimeoutExpired */ From e320fd786922e4c9045c34575b2a1f0f133e3bdf Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 21 Mar 2007 15:36:22 +0800 Subject: [PATCH 04/13] Bug#24568, NdbScanFilter NAND/NOR operations sometimes do not works as expected this patch is an absolutely necessary supplement of the previous patch, the previous patch doesnot cover isnull() and isnotnull() methods' effect. ndb/src/ndbapi/NdbScanFilter.cpp: correct isnull() and isnotnull() when these two methods called in a NAND/NOR operation --- ndb/src/ndbapi/NdbScanFilter.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ndb/src/ndbapi/NdbScanFilter.cpp b/ndb/src/ndbapi/NdbScanFilter.cpp index 89abba2eddc..eb0ef4ba391 100644 --- a/ndb/src/ndbapi/NdbScanFilter.cpp +++ b/ndb/src/ndbapi/NdbScanFilter.cpp @@ -328,12 +328,18 @@ NdbScanFilterImpl::cond_col(Interpreter::UnaryCondition op, Uint32 AttrId){ int NdbScanFilter::isnull(int AttrId){ - return m_impl.cond_col(Interpreter::IS_NULL, AttrId); + if(m_impl.m_negative == 1) + return m_impl.cond_col(Interpreter::IS_NOT_NULL, AttrId); + else + return m_impl.cond_col(Interpreter::IS_NULL, AttrId); } int NdbScanFilter::isnotnull(int AttrId){ - return m_impl.cond_col(Interpreter::IS_NOT_NULL, AttrId); + if(m_impl.m_negative == 1) + return m_impl.cond_col(Interpreter::IS_NULL, AttrId); + else + return m_impl.cond_col(Interpreter::IS_NOT_NULL, AttrId); } struct tab3 { From 774a19554b10c03adcfc6e7202252c6075ef6c62 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 22 Mar 2007 12:16:52 +0800 Subject: [PATCH 05/13] Bug#27127, Incorrect behaviour of timestamp column with DEFAULT CURRENT_TIMESTAMP correct the bitmap_set_bit when a field is timestamp and described with default CURRENT_TIMESTAMP or on update CURRENT_TIMESTAMP, then it will reduce a little time cost when the field doesnot need to write. sql/sql_update.cc: here table->timestamp_field represent only the timestamp field related to CURRENT_TIMESTAMP, when the timestamp_field_type is 0 or 1, it need not to write the field data further. --- sql/sql_update.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 5aea05a9d39..bae1f8e9210 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -201,8 +201,10 @@ int mysql_update(THD *thd, table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET; else { - bitmap_set_bit(table->write_set, - table->timestamp_field->field_index); + if (table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_UPDATE || + table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_BOTH) + bitmap_set_bit(table->write_set, + table->timestamp_field->field_index); } } From 744de3ccabbae1a4c2d94cacb7a50c00c9de8b44 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 22 Mar 2007 15:54:41 +0800 Subject: [PATCH 06/13] Bug#25446, START BACKUP NOWAIT Reports error and then continues storage/ndb/src/mgmclient/CommandInterpreter.cpp: add a goto to avoid a repeated ndb_mgm_start_backup() call --- storage/ndb/src/mgmclient/CommandInterpreter.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/storage/ndb/src/mgmclient/CommandInterpreter.cpp b/storage/ndb/src/mgmclient/CommandInterpreter.cpp index fdcea63640c..c3dd5c340ce 100644 --- a/storage/ndb/src/mgmclient/CommandInterpreter.cpp +++ b/storage/ndb/src/mgmclient/CommandInterpreter.cpp @@ -2489,6 +2489,7 @@ CommandInterpreter::executeStartBackup(char* parameters, bool interactive) { flags = 0; result = ndb_mgm_start_backup(m_mgmsrv, 0, &backupId, &reply); + goto END_BACKUP; } else if (sz == 1 || (sz == 3 && args[1] == "WAIT" && args[2] == "COMPLETED")) { @@ -2522,6 +2523,7 @@ CommandInterpreter::executeStartBackup(char* parameters, bool interactive) } result = ndb_mgm_start_backup(m_mgmsrv, flags, &backupId, &reply); +END_BACKUP: if (result != 0) { ndbout << "Backup failed" << endl; printError(); From c36e06dd90fa60c6a81264863291a088acb08be2 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Mar 2007 10:32:06 +0800 Subject: [PATCH 07/13] Bug#26898, Alter table to empty merge from ndb causes mysqld to crash sql/ha_ndbcluster.cc: remove the assertion, when trans is NULL, return 0 directly since the transaction is possibly released in ha_ndbcluster::external_lock(...) function --- sql/ha_ndbcluster.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 1def6f221f7..8e38f2eb128 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -4366,7 +4366,9 @@ static int ndbcluster_commit(handlerton *hton, THD *thd, bool all) DBUG_PRINT("transaction",("%s", trans == thd_ndb->stmt ? "stmt" : "all")); - DBUG_ASSERT(ndb && trans); + DBUG_ASSERT(ndb); + if (trans == NULL) + DBUG_RETURN(0); if (execute_commit(thd,trans) != 0) { From 18f10e353093a192d2465794c2273d598d939ac0 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Mar 2007 10:59:05 +0800 Subject: [PATCH 08/13] Bug#24521, ndbd node crashes if try to create many datafiles for tablespace storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp: change MaxNoOfOpenFiles's default value to 0, that means no max openning files limitation in ndbfs when user doesnot set explicitly the value in config.ini; Meanwhile, if user set a specific value of MaxNoOfOpenFile and hit the max limiation, he deserves the result. storage/ndb/src/mgmsrv/ConfigInfo.cpp: change default to 0 storage/ndb/src/mgmsrv/ParamInfo.cpp: change default to 0 --- storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp | 6 +++--- storage/ndb/src/mgmsrv/ConfigInfo.cpp | 2 +- storage/ndb/src/mgmsrv/ParamInfo.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp b/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp index 6fb9ef774d0..aa124770d23 100644 --- a/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp +++ b/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp @@ -105,11 +105,11 @@ Ndbfs::execREAD_CONFIG_REQ(Signal* signal) theRequestPool = new Pool; - m_maxFiles = 40; + m_maxFiles = 0; ndb_mgm_get_int_parameter(p, CFG_DB_MAX_OPEN_FILES, &m_maxFiles); Uint32 noIdleFiles = 27; ndb_mgm_get_int_parameter(p, CFG_DB_INITIAL_OPEN_FILES, &noIdleFiles); - if (noIdleFiles > m_maxFiles) + if (noIdleFiles > m_maxFiles && m_maxFiles != 0) m_maxFiles = noIdleFiles; // Create idle AsyncFiles for (Uint32 i = 0; i < noIdleFiles; i++){ @@ -650,7 +650,7 @@ AsyncFile* Ndbfs::createAsyncFile(){ // Check limit of open files - if (theFiles.size()+1 == m_maxFiles) { + if (m_maxFiles !=0 && theFiles.size()+1 == m_maxFiles) { // Print info about all open files for (unsigned i = 0; i < theFiles.size(); i++){ AsyncFile* file = theFiles[i]; diff --git a/storage/ndb/src/mgmsrv/ConfigInfo.cpp b/storage/ndb/src/mgmsrv/ConfigInfo.cpp index 6351af7246e..224758f8c5f 100644 --- a/storage/ndb/src/mgmsrv/ConfigInfo.cpp +++ b/storage/ndb/src/mgmsrv/ConfigInfo.cpp @@ -879,7 +879,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::CI_USED, false, ConfigInfo::CI_INT, - "40", + "0", "20", STR_VALUE(MAX_INT_RNIL) }, diff --git a/storage/ndb/src/mgmsrv/ParamInfo.cpp b/storage/ndb/src/mgmsrv/ParamInfo.cpp index 888b7948c05..a05472de2cb 100644 --- a/storage/ndb/src/mgmsrv/ParamInfo.cpp +++ b/storage/ndb/src/mgmsrv/ParamInfo.cpp @@ -705,7 +705,7 @@ const ParamInfo ParamInfoArray[] = { CI_USED, false, CI_INT, - "40", + "0", "20", STR_VALUE(MAX_INT_RNIL) }, From 76678a48e2df70b9ff3ae44e4de9c8c0e9a743e2 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 30 Mar 2007 15:01:03 +0000 Subject: [PATCH 09/13] BUG#24793 Add SO_KEEPALIVE socket option to avoid cluster nodes keeping dead connections forever. ndb/src/common/transporter/TCP_Transporter.cpp: Add SO_KEEPALIVE socket option --- ndb/src/common/transporter/TCP_Transporter.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ndb/src/common/transporter/TCP_Transporter.cpp b/ndb/src/common/transporter/TCP_Transporter.cpp index 91a5fb50c57..897bad8b787 100644 --- a/ndb/src/common/transporter/TCP_Transporter.cpp +++ b/ndb/src/common/transporter/TCP_Transporter.cpp @@ -155,6 +155,8 @@ TCP_Transporter::initTransporter() { void TCP_Transporter::setSocketOptions(){ + int sockOptKeepAlive = 1; + if (setsockopt(theSocket, SOL_SOCKET, SO_RCVBUF, (char*)&sockOptRcvBufSize, sizeof(sockOptRcvBufSize)) < 0) { #ifdef DEBUG_TRANSPORTER @@ -169,6 +171,11 @@ TCP_Transporter::setSocketOptions(){ #endif }//if + if (setsockopt(theSocket, SOL_SOCKET, SO_KEEPALIVE, + (char*)&sockOptKeepAlive, sizeof(sockOptKeepAlive)) < 0) { + ndbout_c("The setsockopt SO_KEEPALIVE error code = %d", InetErrno); + }//if + //----------------------------------------------- // Set the TCP_NODELAY option so also small packets are sent // as soon as possible From e10f4df4147cf684f09435a969971ce6f97132f3 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 3 Apr 2007 16:40:16 +0800 Subject: [PATCH 10/13] Bug#25875, Newly created table through CREATE TABLE .. LIKE has no ndb_dd attributes sql/sql_table.cc: add something to get possible tablespace info from src table in mysql_create_like_table() at sql/sql_table.cc --- sql/sql_table.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 0697fdd79b4..ab833ebe6b9 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4611,6 +4611,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, #ifdef WITH_PARTITION_STORAGE_ENGINE char tmp_path[FN_REFLEN]; #endif + char ts_name[FN_LEN]; TABLE_LIST src_tables_list, dst_tables_list; DBUG_ENTER("mysql_create_like_table"); @@ -4691,6 +4692,18 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, if (simple_open_n_lock_tables(thd, &src_tables_list)) DBUG_RETURN(TRUE); + /* + For bug#25875, Newly created table through CREATE TABLE .. LIKE + has no ndb_dd attributes; + Add something to get possible tablespace info from src table, + it can get valid tablespace name only for disk-base ndb table + */ + if ((src_tables_list.table->file->get_tablespace_name(thd, ts_name, FN_LEN))) + { + create_info->tablespace= ts_name; + create_info->storage_media= HA_SM_DISK; + } + /* Validate the destination table From 5203ea6ccb349aae5e53e3f0247256a9fc60208e Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 3 Apr 2007 18:44:29 +0800 Subject: [PATCH 11/13] BUG#18676 when cluster storage engine is down, misleading error message on create table with 4009. mysql-test/r/ndb_autodiscover.result: changes ndbd error code to mysqld error code when no cluster connection sql/ha_ndbcluster.cc: map 4009 error code to mysql not connected error sql/handler.cc: define return codes to ha_table_exists_in_engine to something useful NOTE: in 5.1 this should call a handlerton method, not horrible ifdef ndb stuff sql/sql_table.cc: clearly define what happens on create table if exits/not exists/not connected to engine --- mysql-test/r/ndb_autodiscover.result | 2 +- sql/ha_ndbcluster.cc | 11 +++++------ sql/handler.cc | 8 ++++---- sql/sql_table.cc | 25 +++++++++++++++++++------ 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/mysql-test/r/ndb_autodiscover.result b/mysql-test/r/ndb_autodiscover.result index 6d1b7eb152d..01ea884a8ba 100644 --- a/mysql-test/r/ndb_autodiscover.result +++ b/mysql-test/r/ndb_autodiscover.result @@ -382,7 +382,7 @@ create table t1 (a int primary key) engine=ndb; select * from t1; a select * from t1; -ERROR HY000: Can't lock file (errno: 4009) +ERROR HY000: Can't lock file (errno: 157) use test; drop database test_only_ndb_tables; CREATE TABLE t9 ( diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 7a9c7d0d021..ead7343db88 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -203,6 +203,8 @@ static const err_code_mapping err_map[]= { 284, HA_ERR_TABLE_DEF_CHANGED, 0 }, + {4009, HA_ERR_NO_CONNECTION, 1 }, + { 0, 1, 0 }, { -1, -1, 1 } @@ -5042,14 +5044,11 @@ int ndbcluster_table_exists_in_engine(THD* thd, const char *db, const char *name dict->invalidateTable(name); if (!(tab= dict->getTable(name))) { - const NdbError err= dict->getNdbError(); - if (err.code == 709) - DBUG_RETURN(0); - ERR_RETURN(err); + ERR_RETURN(dict->getNdbError()); } DBUG_PRINT("info", ("Found table %s", tab->getName())); - DBUG_RETURN(1); + DBUG_RETURN(HA_ERR_TABLE_EXIST); } @@ -5234,7 +5233,7 @@ int ndbcluster_find_files(THD *thd,const char *db,const char *path, DBUG_PRINT("info", ("%s existed on disk", name)); // The .ndb file exists on disk, but it's not in list of tables in ndb // Verify that handler agrees table is gone. - if (ndbcluster_table_exists_in_engine(thd, db, file_name) == 0) + if (ndbcluster_table_exists_in_engine(thd, db, file_name) == HA_ERR_NO_SUCH_TABLE) { DBUG_PRINT("info", ("NDB says %s does not exists", file_name)); it.remove(); diff --git a/sql/handler.cc b/sql/handler.cc index 5a27e470d70..62f765f0d22 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -2442,14 +2442,14 @@ ha_find_files(THD *thd,const char *db,const char *path, Ask handler if the table exists in engine RETURN - 0 Table does not exist - 1 Table exists - # Error code + HA_ERR_NO_SUCH_TABLE Table does not exist + HA_ERR_TABLE_EXIST Table exists + # Error code */ int ha_table_exists_in_engine(THD* thd, const char* db, const char* name) { - int error= 0; + int error= HA_ERR_NO_SUCH_TABLE; DBUG_ENTER("ha_table_exists_in_engine"); DBUG_PRINT("enter", ("db: %s, name: %s", db, name)); #ifdef HAVE_NDBCLUSTER_DB diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 512d990347f..1ad1cb6426b 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1696,6 +1696,7 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name, alias); DBUG_RETURN(FALSE); } + DBUG_PRINT("info",("1")); my_error(ER_TABLE_EXISTS_ERROR, MYF(0), alias); DBUG_RETURN(TRUE); } @@ -1706,6 +1707,7 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name, { if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS) goto warn; + DBUG_PRINT("info",("2")); my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name); goto end; } @@ -1724,14 +1726,25 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name, { bool create_if_not_exists = create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS; - if (ha_table_exists_in_engine(thd, db, table_name)) + int retcode = ha_table_exists_in_engine(thd, db, table_name); + DBUG_PRINT("info", ("exists_in_engine: %u",retcode)); + switch (retcode) { - DBUG_PRINT("info", ("Table with same name already existed in handler")); + case HA_ERR_NO_SUCH_TABLE: + /* Normal case, no table exists. we can go and create it */ + break; + case HA_ERR_TABLE_EXIST: + DBUG_PRINT("info", ("Table existed in handler")); - if (create_if_not_exists) - goto warn; - my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name); - goto end; + if (create_if_not_exists) + goto warn; + my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name); + goto end; + break; + default: + DBUG_PRINT("info", ("error: %u from storage engine", retcode)); + my_error(retcode, MYF(0),table_name); + goto end; } } From ee58034fc9c67615e60799e20e7d6d30ed01f58b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 Apr 2007 15:22:37 +0800 Subject: [PATCH 12/13] recovery from 5.0 merge for bug18676 mysql-test/r/ndb_autodiscover.result: recovery for bug#18676 merge in 5.0 sql/ha_ndbcluster.cc: recovery for bug#18676 merge in 5.0 sql/handler.cc: recovery for bug#18676 merge in 5.0 sql/sql_table.cc: recovery for bug#18676 merge in 5.0 --- mysql-test/r/ndb_autodiscover.result | 2 +- sql/ha_ndbcluster.cc | 2 ++ sql/handler.cc | 8 ++++---- sql/sql_table.cc | 2 -- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/ndb_autodiscover.result b/mysql-test/r/ndb_autodiscover.result index 487f52f6427..cb85c4ac873 100644 --- a/mysql-test/r/ndb_autodiscover.result +++ b/mysql-test/r/ndb_autodiscover.result @@ -382,7 +382,7 @@ create table t1 (a int primary key) engine=ndb; select * from t1; a select * from t1; -ERROR HY000: Can't lock file (errno: 157) +ERROR HY000: Can't lock file (errno: 4009) use test; drop database test_only_ndb_tables; CREATE TABLE t9 ( diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 5ea29265388..4db35cd7377 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -221,6 +221,7 @@ static int ndb_to_mysql_error(const NdbError *ndberr) { /* read the mysql mapped error code */ int error= ndberr->mysql_code; + switch (error) { /* errors for which we do not add warnings, just return mapped error code @@ -239,6 +240,7 @@ static int ndb_to_mysql_error(const NdbError *ndberr) default: break; } + /* Push the NDB error message as warning - Used to be able to use SHOW WARNINGS toget more info on what the error is diff --git a/sql/handler.cc b/sql/handler.cc index 751b324165d..23c3103493e 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -2865,9 +2865,9 @@ ha_find_files(THD *thd,const char *db,const char *path, Ask handler if the table exists in engine RETURN - HA_ERR_NO_SUCH_TABLE Table does not exist - HA_ERR_TABLE_EXIST Table exists - # Error code + 0 Table does not exist + 1 Table exists + # Error code */ struct st_table_exists_in_engine_args @@ -2891,7 +2891,7 @@ static my_bool table_exists_in_engine_handlerton(THD *thd, st_plugin_int *plugin int ha_table_exists_in_engine(THD* thd, const char* db, const char* name) { - int error= HA_ERR_NO_SUCH_TABLE; + int error= 0; DBUG_ENTER("ha_table_exists_in_engine"); DBUG_PRINT("enter", ("db: %s, name: %s", db, name)); st_table_exists_in_engine_args args= {db, name}; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 006ff3d7093..fc401e93d9c 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3439,7 +3439,6 @@ bool mysql_create_table_internal(THD *thd, error= 0; goto err; } - DBUG_PRINT("info",("1")); my_error(ER_TABLE_EXISTS_ERROR, MYF(0), alias); goto err; } @@ -3451,7 +3450,6 @@ bool mysql_create_table_internal(THD *thd, { if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS) goto warn; - DBUG_PRINT("info",("2")); my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name); goto unlock_and_end; } From 22e2ca5473531bb3af80f85959b51ae112e7b859 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 Apr 2007 19:30:43 +0800 Subject: [PATCH 13/13] sync the initialization configuration information between ConfigInfo.cpp and ParamInfo.cpp --- storage/ndb/src/mgmsrv/ParamInfo.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/storage/ndb/src/mgmsrv/ParamInfo.cpp b/storage/ndb/src/mgmsrv/ParamInfo.cpp index a05472de2cb..26a759e43d2 100644 --- a/storage/ndb/src/mgmsrv/ParamInfo.cpp +++ b/storage/ndb/src/mgmsrv/ParamInfo.cpp @@ -380,10 +380,10 @@ const ParamInfo ParamInfoArray[] = { "If set to yes, then NDB Cluster data will not be swapped out to disk", CI_USED, true, - CI_BOOL, - "false", - "false", - "true" }, + CI_INT, + "0", + "1", + "2" }, { CFG_DB_WATCHDOG_INTERVAL, @@ -1114,6 +1114,18 @@ const ParamInfo ParamInfoArray[] = { "0", "0", STR_VALUE(MAX_INT_RNIL) }, + + { + CFG_DB_MEMREPORT_FREQUENCY, + "MemReportFrequency", + DB_TOKEN, + "Frequency of mem reports in seconds, 0 = only when passing %-limits", + CI_USED, + false, + CI_INT, + "0", + "0", + STR_VALUE(MAX_INT_RNIL) }, /*************************************************************************** * API