mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
Don't allow adding AS ROW START column to a not versioned table
This commit is contained in:
parent
bc0ac28f69
commit
f3a49e7020
3 changed files with 12 additions and 1 deletions
|
@ -71,6 +71,8 @@ Table Create Table
|
|||
t CREATE TABLE `t` (
|
||||
`a` int(11) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
alter table t add column trx_start timestamp(6) as row start;
|
||||
ERROR HY000: Table `t` is not system-versioned
|
||||
alter table t add system versioning;
|
||||
show create table t;
|
||||
Table Create Table
|
||||
|
|
|
@ -57,6 +57,9 @@ alter table t drop column trx_start, drop column trx_end;
|
|||
alter table t drop system versioning;
|
||||
show create table t;
|
||||
|
||||
--error ER_VERS_NOT_VERSIONED
|
||||
alter table t add column trx_start timestamp(6) as row start;
|
||||
|
||||
alter table t add system versioning;
|
||||
show create table t;
|
||||
|
||||
|
|
|
@ -3090,7 +3090,7 @@ void promote_first_timestamp_column(List<Create_field> *column_definitions)
|
|||
column_definition->default_value == NULL && // no constant default,
|
||||
column_definition->unireg_check == Field::NONE && // no function default
|
||||
column_definition->vcol_info == NULL &&
|
||||
!(column_definition->flags & (VERS_SYS_START_FLAG | VERS_SYS_END_FLAG))) // column isn't generated
|
||||
!(column_definition->flags & VERS_SYSTEM_FIELD)) // column isn't generated
|
||||
{
|
||||
DBUG_PRINT("info", ("First TIMESTAMP column '%s' was promoted to "
|
||||
"DEFAULT CURRENT_TIMESTAMP ON UPDATE "
|
||||
|
@ -8079,6 +8079,12 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
|
|||
alter_ctx->datetime_field= def;
|
||||
alter_ctx->error_if_not_empty= TRUE;
|
||||
}
|
||||
if (def->flags & VERS_SYSTEM_FIELD &&
|
||||
!(alter_info->flags & Alter_info::ALTER_ADD_SYSTEM_VERSIONING))
|
||||
{
|
||||
my_error(ER_VERS_NOT_VERSIONED, MYF(0), table->s->table_name.str);
|
||||
goto err;
|
||||
}
|
||||
if (!def->after.str)
|
||||
new_create_list.push_back(def, thd->mem_root);
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue