diff --git a/mysql-test/suite/versioning/r/alter.result b/mysql-test/suite/versioning/r/alter.result index 74bf3f5b854..4f891cf4a8f 100644 --- a/mysql-test/suite/versioning/r/alter.result +++ b/mysql-test/suite/versioning/r/alter.result @@ -445,5 +445,10 @@ t CREATE TABLE `t` ( alter table t add fulltext key (c); Warnings: Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID +create or replace table t (a int) with system versioning; +alter table t drop column a; +ERROR HY000: Table `t` must have at least one temporal column +alter table t drop column a, drop column a; +ERROR 42000: Can't DROP COLUMN `a`; check that it exists drop database test; create database test; diff --git a/mysql-test/suite/versioning/t/alter.test b/mysql-test/suite/versioning/t/alter.test index bac27cb940d..cd6b5d5e59b 100644 --- a/mysql-test/suite/versioning/t/alter.test +++ b/mysql-test/suite/versioning/t/alter.test @@ -377,6 +377,12 @@ create or replace table t (c text) engine=innodb with system versioning; show create table t; alter table t add fulltext key (c); +create or replace table t (a int) with system versioning; +--error ER_VERS_TABLE_MUST_HAVE_COLUMNS +alter table t drop column a; +--error ER_CANT_DROP_FIELD_OR_KEY +alter table t drop column a, drop column a; + drop database test; create database test; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 977e622e24b..0ae2b6ff749 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -8363,6 +8363,13 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, } } + if (table->versioned() && !(alter_info->flags & Alter_info::ALTER_DROP_SYSTEM_VERSIONING) && + new_create_list.elements == VERSIONING_FIELDS) + { + my_error(ER_VERS_TABLE_MUST_HAVE_COLUMNS, MYF(0), table->s->table_name.str); + goto err; + } + if (!create_info->comment.str) { create_info->comment.str= table->s->comment.str;