Loading mysql-test/r/ndb_dd_basic.result +28 −0 Original line number Diff line number Diff line Loading @@ -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; Loading mysql-test/t/ndb_dd_basic.test +40 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 ############################ Loading sql/ha_ndbcluster.cc +33 −1 Original line number Diff line number Diff line Loading @@ -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) Loading Loading @@ -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); Loading sql/sql_table.cc +14 −0 Original line number Diff line number Diff line Loading @@ -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")); Loading Loading @@ -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"); Loading Loading @@ -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 Loading sql/sql_update.cc +4 −2 Original line number Diff line number Diff line Loading @@ -201,6 +201,8 @@ int mysql_update(THD *thd, table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET; else { 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); } Loading Loading
mysql-test/r/ndb_dd_basic.result +28 −0 Original line number Diff line number Diff line Loading @@ -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; Loading
mysql-test/t/ndb_dd_basic.test +40 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 ############################ Loading
sql/ha_ndbcluster.cc +33 −1 Original line number Diff line number Diff line Loading @@ -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) Loading Loading @@ -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); Loading
sql/sql_table.cc +14 −0 Original line number Diff line number Diff line Loading @@ -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")); Loading Loading @@ -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"); Loading Loading @@ -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 Loading
sql/sql_update.cc +4 −2 Original line number Diff line number Diff line Loading @@ -201,6 +201,8 @@ int mysql_update(THD *thd, table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET; else { 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); } Loading