Skip to content

Commit 647a388

Browse files
committed
MDEV-16130 wrong error message adding AS ROW START to versioned table
1 parent 75ba5c8 commit 647a388

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,17 @@ t CREATE TABLE `t` (
8080
`a` int(11) DEFAULT NULL
8181
) ENGINE=MyISAM DEFAULT CHARSET=latin1
8282
alter table t add column trx_start timestamp(6) as row start;
83-
ERROR HY000: Table `t` is not system-versioned
83+
ERROR HY000: Duplicate ROW START column `trx_start`
8484
alter table t add system versioning;
8585
show create table t;
8686
Table Create Table
8787
t CREATE TABLE `t` (
8888
`a` int(11) DEFAULT NULL
8989
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
90+
alter table t add column trx_start timestamp(6) as row start;
91+
ERROR HY000: Duplicate ROW START column `trx_start`
92+
alter table t modify a int as row start;
93+
ERROR HY000: Duplicate ROW START column `a`
9094
alter table t add column b int;
9195
show create table t;
9296
Table Create Table
@@ -531,7 +535,7 @@ use test;
531535
# MDEV-15956 Strange ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN upon ALTER on versioning column
532536
create or replace table t1 (i int, j int as (i), s timestamp(6) as row start, e timestamp(6) as row end, period for system_time(s,e)) with system versioning;
533537
alter table t1 modify s timestamp(6) as row start;
534-
ERROR HY000: Can not change system versioning field `s`
538+
ERROR HY000: Duplicate ROW START column `s`
535539
# ignore CHECK for historical rows
536540
create or replace table t (a int) with system versioning;
537541
insert into t values (0), (1);

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,17 @@ select row_start from t;
6868
alter table t drop system versioning;
6969
show create table t;
7070

71-
--error ER_VERS_NOT_VERSIONED
71+
--error ER_VERS_DUPLICATE_ROW_START_END
7272
alter table t add column trx_start timestamp(6) as row start;
7373

7474
alter table t add system versioning;
7575
show create table t;
7676

77+
--error ER_VERS_DUPLICATE_ROW_START_END
78+
alter table t add column trx_start timestamp(6) as row start;
79+
--error ER_VERS_DUPLICATE_ROW_START_END
80+
alter table t modify a int as row start;
81+
7782
alter table t add column b int;
7883
show create table t;
7984

@@ -457,7 +462,7 @@ use test;
457462

458463
--echo # MDEV-15956 Strange ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN upon ALTER on versioning column
459464
create or replace table t1 (i int, j int as (i), s timestamp(6) as row start, e timestamp(6) as row end, period for system_time(s,e)) with system versioning;
460-
--error ER_VERS_ALTER_SYSTEM_FIELD
465+
--error ER_VERS_DUPLICATE_ROW_START_END
461466
alter table t1 modify s timestamp(6) as row start;
462467

463468
--echo # ignore CHECK for historical rows

sql/handler.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7301,13 +7301,15 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info,
73017301
return false;
73027302
}
73037303

7304+
if (!(alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING))
73047305
{
73057306
List_iterator_fast<Create_field> it(alter_info->create_list);
73067307
while (Create_field *f= it++)
73077308
{
7308-
if (f->change.length && f->flags & VERS_SYSTEM_FIELD)
7309+
if (f->flags & VERS_SYSTEM_FIELD)
73097310
{
7310-
my_error(ER_VERS_ALTER_SYSTEM_FIELD, MYF(0), f->field_name.str);
7311+
my_error(ER_VERS_DUPLICATE_ROW_START_END, MYF(0),
7312+
f->flags & VERS_SYS_START_FLAG ? "START" : "END", f->field_name.str);
73117313
return true;
73127314
}
73137315
}

sql/sql_table.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8159,12 +8159,6 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
81598159
alter_ctx->datetime_field= def;
81608160
alter_ctx->error_if_not_empty= TRUE;
81618161
}
8162-
if (def->flags & VERS_SYSTEM_FIELD &&
8163-
!(alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING))
8164-
{
8165-
my_error(ER_VERS_NOT_VERSIONED, MYF(0), table->s->table_name.str);
8166-
goto err;
8167-
}
81688162
if (!def->after.str)
81698163
new_create_list.push_back(def, thd->mem_root);
81708164
else

0 commit comments

Comments
 (0)