Skip to content

Commit c847089

Browse files
committed
Cannot DROP VERSIONING without dropping all visible AS ROW fields
1 parent f3a49e7 commit c847089

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

mysql-test/suite/versioning/r/alter.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ t CREATE TABLE `t` (
6464
`trx_end` timestamp(6) GENERATED ALWAYS AS ROW END INVISIBLE,
6565
PERIOD FOR SYSTEM_TIME (`trx_start`, `trx_end`)
6666
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
67+
alter table t drop system versioning;
68+
ERROR HY000: System versioning field `trx_start` exists
6769
alter table t drop column trx_start, drop column trx_end;
6870
alter table t drop system versioning;
6971
show create table t;

mysql-test/suite/versioning/t/alter.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ alter table t
5353
add system versioning;
5454
show create table t;
5555

56+
--error ER_VERS_SYS_FIELD_EXISTS
57+
alter table t drop system versioning;
58+
5659
alter table t drop column trx_start, drop column trx_end;
5760
alter table t drop system versioning;
5861
show create table t;

sql/sql_table.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8009,6 +8009,13 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
80098009
def_it.remove();
80108010
}
80118011
}
8012+
else if (alter_info->flags & Alter_info::ALTER_DROP_SYSTEM_VERSIONING &&
8013+
field->flags & VERS_SYSTEM_FIELD &&
8014+
field->invisible < INVISIBLE_SYSTEM)
8015+
{
8016+
my_error(ER_VERS_SYS_FIELD_EXISTS, MYF(0), field->field_name.str);
8017+
goto err;
8018+
}
80128019
else
80138020
{
80148021
/*

0 commit comments

Comments
 (0)