diff options
-rw-r--r-- | mysql-test/main/alter_table_online.result | 51 | ||||
-rw-r--r-- | mysql-test/main/alter_table_online.test | 93 | ||||
-rw-r--r-- | sql/sql_table.cc | 1 |
3 files changed, 50 insertions, 95 deletions
diff --git a/mysql-test/main/alter_table_online.result b/mysql-test/main/alter_table_online.result index 0791c5c04bc..01ee3c97888 100644 --- a/mysql-test/main/alter_table_online.result +++ b/mysql-test/main/alter_table_online.result @@ -408,55 +408,8 @@ a b UNIX_TIMESTAMP(row_start) UNIX_TIMESTAMP(row_end) 1 55 1.000000 2147483647.999999 3 44 1.000000 2147483647.999999 6 77 1.000000 2147483647.999999 -connection con2; -set debug_sync= 'now WAIT_FOR ended'; -connection default; -set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end'; -alter table t1 drop system versioning, -algorithm= copy, lock= none; -connection con2; -update t1 set b= 88 where a = 1; -set debug_sync= 'now SIGNAL end'; -connection default; -# Can't UPDATE versioned -> plain (and can't DELETE) -ERROR 23000: Duplicate entry '1' for key 'PRIMARY' -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) NOT NULL, - `b` int(11) DEFAULT NULL, - PRIMARY KEY (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING -select *, UNIX_TIMESTAMP(row_start), UNIX_TIMESTAMP(row_end) from t1 for system_time all; -a b UNIX_TIMESTAMP(row_start) UNIX_TIMESTAMP(row_end) -1 55 1.000000 3.000000 -1 88 3.000000 2147483647.999999 -3 44 1.000000 2147483647.999999 -6 77 1.000000 2147483647.999999 -connection con2; -set debug_sync= 'now WAIT_FOR ended'; -connection default; -set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end'; -alter table t1 drop system versioning, -algorithm= copy, lock= none; -connection con2; -insert into t1 values (8, 99); -set debug_sync= 'now SIGNAL end'; -connection default; -# INSERT versioned -> plain works fine since it is a single versioned op. -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) NOT NULL, - `b` int(11) DEFAULT NULL, - PRIMARY KEY (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -select * from t1; -a b -1 88 -3 44 -6 77 -8 99 +alter table t1 drop system versioning, algorithm= copy, lock= none; +ERROR 0A000: LOCK=NONE is not supported. Reason: COPY algorithm requires a lock. Try LOCK=SHARED # # Test ROLLBACK TO SAVEPOINT # diff --git a/mysql-test/main/alter_table_online.test b/mysql-test/main/alter_table_online.test index d0cbf958004..bcc401541bf 100644 --- a/mysql-test/main/alter_table_online.test +++ b/mysql-test/main/alter_table_online.test @@ -492,52 +492,53 @@ set debug_sync= 'now SIGNAL end'; show create table t1; select *, UNIX_TIMESTAMP(row_start), UNIX_TIMESTAMP(row_end) from t1 for system_time all; ---connection con2 ---send -set debug_sync= 'now WAIT_FOR ended'; - ---connection default -set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end'; - ---send -alter table t1 drop system versioning, - algorithm= copy, lock= none; - ---connection con2 ---reap -update t1 set b= 88 where a = 1; - -set debug_sync= 'now SIGNAL end'; - ---connection default ---echo # Can't UPDATE versioned -> plain (and can't DELETE) ---error ER_DUP_ENTRY ---reap -show create table t1; -select *, UNIX_TIMESTAMP(row_start), UNIX_TIMESTAMP(row_end) from t1 for system_time all; - ---connection con2 ---send -set debug_sync= 'now WAIT_FOR ended'; - ---connection default -set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end'; - ---send -alter table t1 drop system versioning, - algorithm= copy, lock= none; - ---connection con2 ---reap -insert into t1 values (8, 99); - -set debug_sync= 'now SIGNAL end'; - ---connection default ---echo # INSERT versioned -> plain works fine since it is a single versioned op. ---reap -show create table t1; -select * from t1; +## at the moment DROP SYSTEM VERSIONING cannot be done online +## because it not only alters the structure, but also deletes history rows +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +alter table t1 drop system versioning, algorithm= copy, lock= none; +#--connection con2 +#--send +#set debug_sync= 'now WAIT_FOR ended'; +# +#--connection default +#set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end'; +# +#--send +#alter table t1 drop system versioning, +# algorithm= copy, lock= none; +# +#--connection con2 +#--reap +#update t1 set b= 88 where a = 1; +# +#set debug_sync= 'now SIGNAL end'; +# +#--connection default +#--reap +#show create table t1; +#select *, UNIX_TIMESTAMP(row_start), UNIX_TIMESTAMP(row_end) from t1 for system_time all; +# +#--connection con2 +#--send +#set debug_sync= 'now WAIT_FOR ended'; +# +#--connection default +#set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end'; +# +#--send +#alter table t1 drop system versioning, +# algorithm= copy, lock= none; +# +#--connection con2 +#--reap +#insert into t1 values (8, 99); +# +#set debug_sync= 'now SIGNAL end'; +# +#--connection default +#--reap +#show create table t1; +#select * from t1; --echo # --echo # Test ROLLBACK TO SAVEPOINT diff --git a/sql/sql_table.cc b/sql/sql_table.cc index c42c45ed03c..2620a14d382 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -10026,6 +10026,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, if (alter_info->requested_lock == Alter_info::ALTER_TABLE_LOCK_SHARED || alter_info->requested_lock > Alter_info::ALTER_TABLE_LOCK_NONE + || alter_info->flags & ALTER_DROP_SYSTEM_VERSIONING || thd->locked_tables_mode == LTM_LOCK_TABLES || thd->lex->sql_command == SQLCOM_OPTIMIZE || alter_info->algorithm(thd) > Alter_info::ALTER_TABLE_ALGORITHM_COPY) |