summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2022-06-02 14:57:56 +0200
committerNikita Malyavin <nikitamalyavin@gmail.com>2022-10-17 15:24:44 +0300
commitb8331bb1fecc05e42e428a974b3b73eb79985426 (patch)
tree87a806278080f46eae355ccd415d352b37af5771
parenta7752813d66f016f29628df960635ac131816c84 (diff)
downloadmariadb-git-b8331bb1fecc05e42e428a974b3b73eb79985426.tar.gz
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
-rw-r--r--mysql-test/main/alter_table_online.result51
-rw-r--r--mysql-test/main/alter_table_online.test93
-rw-r--r--sql/sql_table.cc1
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 9cd0783f4b8..4f6ffc03bd7 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 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
-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 46b75dcbb1c..0bf2d7cabd4 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -10434,6 +10434,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)