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/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index cefd313067b..4a52aabc351 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -4457,7 +4457,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); #ifdef HAVE_NDB_BINLOG if (thd->slave_thread) @@ -10787,6 +10789,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); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 3eb47ebae6e..feaefa160b8 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3488,6 +3488,7 @@ bool mysql_create_table_internal(THD *thd, { bool create_if_not_exists = create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS; + if (ha_table_exists_in_engine(thd, db, table_name)) { DBUG_PRINT("info", ("Table with same name already existed in handler")); @@ -4618,6 +4619,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"); @@ -4698,6 +4700,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 diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 19c171b1be0..56c952f34ce 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); } } 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/common/transporter/TCP_Transporter.cpp b/storage/ndb/src/common/transporter/TCP_Transporter.cpp index 18171a09974..298e43710b0 100644 --- a/storage/ndb/src/common/transporter/TCP_Transporter.cpp +++ b/storage/ndb/src/common/transporter/TCP_Transporter.cpp @@ -152,6 +152,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 @@ -166,6 +168,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 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/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/mgmclient/CommandInterpreter.cpp b/storage/ndb/src/mgmclient/CommandInterpreter.cpp index 793b2e3cc98..93fc3d46e43 100644 --- a/storage/ndb/src/mgmclient/CommandInterpreter.cpp +++ b/storage/ndb/src/mgmclient/CommandInterpreter.cpp @@ -1966,6 +1966,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); @@ -2492,6 +2495,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")) { @@ -2525,6 +2529,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(); diff --git a/storage/ndb/src/mgmsrv/ConfigInfo.cpp b/storage/ndb/src/mgmsrv/ConfigInfo.cpp index ba04ceee7ec..05abe4ced9e 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..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, @@ -705,7 +705,7 @@ const ParamInfo ParamInfoArray[] = { CI_USED, false, CI_INT, - "40", + "0", "20", STR_VALUE(MAX_INT_RNIL) }, @@ -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 diff --git a/storage/ndb/src/ndbapi/NdbScanFilter.cpp b/storage/ndb/src/ndbapi/NdbScanFilter.cpp index 89abba2eddc..eb0ef4ba391 100644 --- a/storage/ndb/src/ndbapi/NdbScanFilter.cpp +++ b/storage/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 { 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 */