Loading mysql-test/r/ndb_alter_table.result +63 −4 Original line number Diff line number Diff line Loading @@ -72,6 +72,21 @@ col6 col1 col3 fourth col4 col4_5 col5 col7 col8 1 100 3 4 5 PENDING 0000-00-00 00:00:00 1 101 3 4 5 PENDING 0000-00-00 00:00:00 2 102 4 3 5 99 PENDING EXTRA 2004-01-01 00:00:00 delete from t1; insert into t1 values (0,0,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00'); SET SQL_MODE=''; insert into t1 values (1,0,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00'); select * from t1 order by col1; col6 col1 col3 fourth col4 col4_5 col5 col7 col8 0 0 4 3 5 99 PENDING EXTRA 2004-01-01 00:00:00 1 103 4 3 5 99 PENDING EXTRA 2004-01-01 00:00:00 alter table t1 drop column col4_5; insert into t1 values (2,0,4,3,5,"PENDING","EXTRA",'2004-01-01 00:00:00'); select * from t1 order by col1; col6 col1 col3 fourth col4 col5 col7 col8 0 0 4 3 5 PENDING EXTRA 2004-01-01 00:00:00 1 103 4 3 5 PENDING EXTRA 2004-01-01 00:00:00 2 104 4 3 5 PENDING EXTRA 2004-01-01 00:00:00 drop table t1; CREATE TABLE t1 ( a INT NOT NULL, Loading @@ -79,16 +94,60 @@ b INT NOT NULL ) ENGINE=ndbcluster; INSERT INTO t1 VALUES (9410,9412); ALTER TABLE t1 ADD COLUMN c int not null; select * from t1; select * from t1 order by a; a b c 9410 9412 0 select * from t1; select * from t1 order by a; a b c 9410 9412 0 alter table t1 drop c; select * from t1; select * from t1 order by a; a b 9410 9412 drop table t1; select * from t1; select * from t1 order by a; ERROR 42S02: Table 'test.t1' doesn't exist CREATE TABLE t1 ( a INT NOT NULL PRIMARY KEY, b INT NOT NULL ) ENGINE=ndbcluster; INSERT INTO t1 VALUES (0,1),(17,18); select * from t1 order by a; a b 0 1 17 18 alter table t1 modify column a int not null auto_increment; select * from t1 order by a; a b 0 1 17 18 INSERT INTO t1 VALUES (0,19),(20,21); select * from t1 order by a; a b 0 1 17 18 18 19 20 21 drop table t1; CREATE TABLE t1 ( a INT NOT NULL PRIMARY KEY, b INT NOT NULL ) ENGINE=ndbcluster; INSERT INTO t1 VALUES (0,1),(17,18); select * from t1; a b 17 18 0 1 alter table t1 add c int not null unique auto_increment; select * from t1 order by a; a b c 0 1 2 17 18 1 INSERT INTO t1 VALUES (18,19,3),(20,21,0); select * from t1 order by a; a b c 0 1 2 17 18 1 18 19 3 20 21 4 drop table t1; mysql-test/t/ndb_alter_table.test +37 −3 Original line number Diff line number Diff line Loading @@ -47,6 +47,14 @@ select * from t1 order by col1; insert into t1 values (2, NULL,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00'); show table status; select * from t1 order by col1; delete from t1; insert into t1 values (0,0,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00'); SET SQL_MODE=''; insert into t1 values (1,0,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00'); select * from t1 order by col1; alter table t1 drop column col4_5; insert into t1 values (2,0,4,3,5,"PENDING","EXTRA",'2004-01-01 00:00:00'); select * from t1 order by col1; drop table t1; Loading @@ -66,19 +74,45 @@ connect (con2,localhost,,,test); connection con1; ALTER TABLE t1 ADD COLUMN c int not null; select * from t1; select * from t1 order by a; connection con2; select * from t1; select * from t1 order by a; alter table t1 drop c; connection con1; select * from t1; select * from t1 order by a; drop table t1; connection con2; --error 1146 select * from t1 order by a; CREATE TABLE t1 ( a INT NOT NULL PRIMARY KEY, b INT NOT NULL ) ENGINE=ndbcluster; INSERT INTO t1 VALUES (0,1),(17,18); select * from t1 order by a; alter table t1 modify column a int not null auto_increment; select * from t1 order by a; INSERT INTO t1 VALUES (0,19),(20,21); select * from t1 order by a; drop table t1; CREATE TABLE t1 ( a INT NOT NULL PRIMARY KEY, b INT NOT NULL ) ENGINE=ndbcluster; INSERT INTO t1 VALUES (0,1),(17,18); select * from t1; alter table t1 add c int not null unique auto_increment; select * from t1 order by a; INSERT INTO t1 VALUES (18,19,3),(20,21,0); select * from t1 order by a; drop table t1; #--disable_warnings #DROP TABLE IF EXISTS t2; Loading sql/ha_ndbcluster.cc +3 −1 Original line number Diff line number Diff line Loading @@ -3402,7 +3402,9 @@ longlong ha_ndbcluster::get_auto_increment() DBUG_ENTER("get_auto_increment"); DBUG_PRINT("enter", ("m_tabname: %s", m_tabname)); int cache_size= (rows_to_insert > autoincrement_prefetch) ? (rows_to_insert - rows_inserted < autoincrement_prefetch) ? rows_to_insert - rows_inserted : (rows_to_insert > autoincrement_prefetch) ? rows_to_insert : autoincrement_prefetch; Uint64 auto_value= Loading sql/sql_table.cc +12 −0 Original line number Diff line number Diff line Loading @@ -3303,6 +3303,8 @@ copy_data_between_tables(TABLE *from,TABLE *to, List<Item> all_fields; ha_rows examined_rows; bool auto_increment_field_copied= 0; ulong old_sql_mode; bool no_auto_on_zero; DBUG_ENTER("copy_data_between_tables"); if (!(copy= new Copy_field[to->fields])) Loading Loading @@ -3361,6 +3363,11 @@ copy_data_between_tables(TABLE *from,TABLE *to, goto err; } /* Turn on NO_AUTO_VALUE_ON_ZERO if not already on */ old_sql_mode= thd->variables.sql_mode; if (!(no_auto_on_zero= thd->variables.sql_mode & MODE_NO_AUTO_VALUE_ON_ZERO)) thd->variables.sql_mode|= MODE_NO_AUTO_VALUE_ON_ZERO; /* Handler must be told explicitly to retrieve all columns, because this function does not set field->query_id in the columns to the current query id */ Loading Loading @@ -3417,6 +3424,11 @@ copy_data_between_tables(TABLE *from,TABLE *to, to->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); ha_enable_transaction(thd,TRUE); /* Turn off NO_AUTO_VALUE_ON_ZERO if it was not already off */ if (!no_auto_on_zero) thd->variables.sql_mode= old_sql_mode; /* Ensure that the new table is saved properly to disk so that we can do a rename Loading Loading
mysql-test/r/ndb_alter_table.result +63 −4 Original line number Diff line number Diff line Loading @@ -72,6 +72,21 @@ col6 col1 col3 fourth col4 col4_5 col5 col7 col8 1 100 3 4 5 PENDING 0000-00-00 00:00:00 1 101 3 4 5 PENDING 0000-00-00 00:00:00 2 102 4 3 5 99 PENDING EXTRA 2004-01-01 00:00:00 delete from t1; insert into t1 values (0,0,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00'); SET SQL_MODE=''; insert into t1 values (1,0,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00'); select * from t1 order by col1; col6 col1 col3 fourth col4 col4_5 col5 col7 col8 0 0 4 3 5 99 PENDING EXTRA 2004-01-01 00:00:00 1 103 4 3 5 99 PENDING EXTRA 2004-01-01 00:00:00 alter table t1 drop column col4_5; insert into t1 values (2,0,4,3,5,"PENDING","EXTRA",'2004-01-01 00:00:00'); select * from t1 order by col1; col6 col1 col3 fourth col4 col5 col7 col8 0 0 4 3 5 PENDING EXTRA 2004-01-01 00:00:00 1 103 4 3 5 PENDING EXTRA 2004-01-01 00:00:00 2 104 4 3 5 PENDING EXTRA 2004-01-01 00:00:00 drop table t1; CREATE TABLE t1 ( a INT NOT NULL, Loading @@ -79,16 +94,60 @@ b INT NOT NULL ) ENGINE=ndbcluster; INSERT INTO t1 VALUES (9410,9412); ALTER TABLE t1 ADD COLUMN c int not null; select * from t1; select * from t1 order by a; a b c 9410 9412 0 select * from t1; select * from t1 order by a; a b c 9410 9412 0 alter table t1 drop c; select * from t1; select * from t1 order by a; a b 9410 9412 drop table t1; select * from t1; select * from t1 order by a; ERROR 42S02: Table 'test.t1' doesn't exist CREATE TABLE t1 ( a INT NOT NULL PRIMARY KEY, b INT NOT NULL ) ENGINE=ndbcluster; INSERT INTO t1 VALUES (0,1),(17,18); select * from t1 order by a; a b 0 1 17 18 alter table t1 modify column a int not null auto_increment; select * from t1 order by a; a b 0 1 17 18 INSERT INTO t1 VALUES (0,19),(20,21); select * from t1 order by a; a b 0 1 17 18 18 19 20 21 drop table t1; CREATE TABLE t1 ( a INT NOT NULL PRIMARY KEY, b INT NOT NULL ) ENGINE=ndbcluster; INSERT INTO t1 VALUES (0,1),(17,18); select * from t1; a b 17 18 0 1 alter table t1 add c int not null unique auto_increment; select * from t1 order by a; a b c 0 1 2 17 18 1 INSERT INTO t1 VALUES (18,19,3),(20,21,0); select * from t1 order by a; a b c 0 1 2 17 18 1 18 19 3 20 21 4 drop table t1;
mysql-test/t/ndb_alter_table.test +37 −3 Original line number Diff line number Diff line Loading @@ -47,6 +47,14 @@ select * from t1 order by col1; insert into t1 values (2, NULL,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00'); show table status; select * from t1 order by col1; delete from t1; insert into t1 values (0,0,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00'); SET SQL_MODE=''; insert into t1 values (1,0,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00'); select * from t1 order by col1; alter table t1 drop column col4_5; insert into t1 values (2,0,4,3,5,"PENDING","EXTRA",'2004-01-01 00:00:00'); select * from t1 order by col1; drop table t1; Loading @@ -66,19 +74,45 @@ connect (con2,localhost,,,test); connection con1; ALTER TABLE t1 ADD COLUMN c int not null; select * from t1; select * from t1 order by a; connection con2; select * from t1; select * from t1 order by a; alter table t1 drop c; connection con1; select * from t1; select * from t1 order by a; drop table t1; connection con2; --error 1146 select * from t1 order by a; CREATE TABLE t1 ( a INT NOT NULL PRIMARY KEY, b INT NOT NULL ) ENGINE=ndbcluster; INSERT INTO t1 VALUES (0,1),(17,18); select * from t1 order by a; alter table t1 modify column a int not null auto_increment; select * from t1 order by a; INSERT INTO t1 VALUES (0,19),(20,21); select * from t1 order by a; drop table t1; CREATE TABLE t1 ( a INT NOT NULL PRIMARY KEY, b INT NOT NULL ) ENGINE=ndbcluster; INSERT INTO t1 VALUES (0,1),(17,18); select * from t1; alter table t1 add c int not null unique auto_increment; select * from t1 order by a; INSERT INTO t1 VALUES (18,19,3),(20,21,0); select * from t1 order by a; drop table t1; #--disable_warnings #DROP TABLE IF EXISTS t2; Loading
sql/ha_ndbcluster.cc +3 −1 Original line number Diff line number Diff line Loading @@ -3402,7 +3402,9 @@ longlong ha_ndbcluster::get_auto_increment() DBUG_ENTER("get_auto_increment"); DBUG_PRINT("enter", ("m_tabname: %s", m_tabname)); int cache_size= (rows_to_insert > autoincrement_prefetch) ? (rows_to_insert - rows_inserted < autoincrement_prefetch) ? rows_to_insert - rows_inserted : (rows_to_insert > autoincrement_prefetch) ? rows_to_insert : autoincrement_prefetch; Uint64 auto_value= Loading
sql/sql_table.cc +12 −0 Original line number Diff line number Diff line Loading @@ -3303,6 +3303,8 @@ copy_data_between_tables(TABLE *from,TABLE *to, List<Item> all_fields; ha_rows examined_rows; bool auto_increment_field_copied= 0; ulong old_sql_mode; bool no_auto_on_zero; DBUG_ENTER("copy_data_between_tables"); if (!(copy= new Copy_field[to->fields])) Loading Loading @@ -3361,6 +3363,11 @@ copy_data_between_tables(TABLE *from,TABLE *to, goto err; } /* Turn on NO_AUTO_VALUE_ON_ZERO if not already on */ old_sql_mode= thd->variables.sql_mode; if (!(no_auto_on_zero= thd->variables.sql_mode & MODE_NO_AUTO_VALUE_ON_ZERO)) thd->variables.sql_mode|= MODE_NO_AUTO_VALUE_ON_ZERO; /* Handler must be told explicitly to retrieve all columns, because this function does not set field->query_id in the columns to the current query id */ Loading Loading @@ -3417,6 +3424,11 @@ copy_data_between_tables(TABLE *from,TABLE *to, to->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); ha_enable_transaction(thd,TRUE); /* Turn off NO_AUTO_VALUE_ON_ZERO if it was not already off */ if (!no_auto_on_zero) thd->variables.sql_mode= old_sql_mode; /* Ensure that the new table is saved properly to disk so that we can do a rename Loading