mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
don't do DROP SYSTEM VERSIONING online
because ALTER TABLE ... DROP SYSTEM VERSIONING is not just a change in the table structure, it also deletes all historical rows
This commit is contained in:
@ -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
|
||||
#
|
||||
|
@ -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
|
||||
|
@ -10028,6 +10028,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)
|
||||
|
Reference in New Issue
Block a user