Skip to content

Commit

Permalink
MDEV-25172 Wrong error message for ADD COLUMN .. AS ROW START
Browse files Browse the repository at this point in the history
Handle one more condition in fix_alter_info() for non-versioned table
and produce ER_VERS_NOT_VERSIONED error.
  • Loading branch information
midenok committed Mar 31, 2021
1 parent 0c99e6e commit 77ffbbc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
9 changes: 8 additions & 1 deletion mysql-test/suite/versioning/r/alter.result
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ 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: Duplicate ROW START column `trx_start`
ERROR HY000: Table `t` is not system-versioned
alter table t add system versioning;
show create table t;
Table Create Table
Expand Down Expand Up @@ -735,3 +735,10 @@ t1 CREATE TABLE `t1` (
alter table t1 drop column b;
ERROR 42000: Key column 'b' doesn't exist in table
drop table t1;
#
# MDEV-25172 Wrong error message for ADD COLUMN .. AS ROW START
#
create or replace table t1 (x int);
alter table t1 add column y timestamp(6) as row start;
ERROR HY000: Table `t1` is not system-versioned
drop table t1;
11 changes: 10 additions & 1 deletion mysql-test/suite/versioning/t/alter.test
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ select row_start from t;
alter table t drop system versioning;
show create table t;

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

alter table t add system versioning;
Expand Down Expand Up @@ -621,3 +621,12 @@ alter table t1 drop column b;

# cleanup
drop table t1;

--echo #
--echo # MDEV-25172 Wrong error message for ADD COLUMN .. AS ROW START
--echo #
create or replace table t1 (x int);
--error ER_VERS_NOT_VERSIONED
alter table t1 add column y timestamp(6) as row start;
# cleanup
drop table t1;
5 changes: 5 additions & 0 deletions sql/handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7340,6 +7340,11 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info,
{
if (f->flags & VERS_SYSTEM_FIELD)
{
if (!table->versioned())
{
my_error(ER_VERS_NOT_VERSIONED, MYF(0), table->s->table_name.str);
return true;
}
my_error(ER_VERS_DUPLICATE_ROW_START_END, MYF(0),
f->flags & VERS_SYS_START_FLAG ? "START" : "END", f->field_name.str);
return true;
Expand Down

0 comments on commit 77ffbbc

Please sign in to comment.