Skip to content
Permalink
Browse files

MDEV-19127 Assertion `row_start_field' failed in vers_prepare_keys up…

…on ALTER TABLE

Prevent conflicting clauses at parser level.

Clear HA_VERSIONED_TABLE flag for DROP SYSTEM VERSIONING (for the sake
of strictness).
  • Loading branch information...
midenok committed Apr 11, 2019
1 parent 638e788 commit 0b74c8832d45340a455f27c3b4aa20db5d8313db
Showing with 31 additions and 0 deletions.
  1. +9 −0 mysql-test/suite/versioning/r/alter.result
  2. +10 −0 mysql-test/suite/versioning/t/alter.test
  3. +6 −0 sql/sql_yacc.yy
  4. +6 −0 sql/sql_yacc_ora.yy
@@ -629,5 +629,14 @@ alter table t1 drop column `row_start`, drop column `row_end`, drop system versi
ERROR 42000: Can't DROP COLUMN `row_start`; check that it exists
alter table t1 drop column `row_end`;
ERROR 42000: Can't DROP COLUMN `row_end`; check that it exists
#
# MDEV-19127 Assertion `row_start_field' failed in vers_prepare_keys upon ALTER TABLE
#
set system_versioning_alter_history=keep;
create or replace table t1 (f1 int) with system versioning;
alter table t1 add f2 int with system versioning, drop system versioning;
create or replace table t1 (f1 int) with system versioning;
alter table t1 drop system versioning, add f2 int with system versioning;
ERROR HY000: Table `t1` is not system-versioned
drop database test;
create database test;
@@ -528,5 +528,15 @@ alter table t1 drop column `row_start`, drop column `row_end`, drop system versi
--error ER_CANT_DROP_FIELD_OR_KEY
alter table t1 drop column `row_end`;

--echo #
--echo # MDEV-19127 Assertion `row_start_field' failed in vers_prepare_keys upon ALTER TABLE
--echo #
set system_versioning_alter_history=keep;
create or replace table t1 (f1 int) with system versioning;
alter table t1 add f2 int with system versioning, drop system versioning;
create or replace table t1 (f1 int) with system versioning;
--error ER_VERS_NOT_VERSIONED
alter table t1 drop system versioning, add f2 int with system versioning;

drop database test;
create database test;
@@ -7368,6 +7368,11 @@ serial_attribute:
{
Lex->last_field->versioning= $1;
Lex->create_info.options|= HA_VERSIONED_TABLE;
if (Lex->alter_info.flags & ALTER_DROP_SYSTEM_VERSIONING)
{
my_yyabort_error((ER_VERS_NOT_VERSIONED, MYF(0),
Lex->create_last_non_select_table->table_name.str));
}
}
;

@@ -8498,6 +8503,7 @@ alter_list_item:
| DROP SYSTEM VERSIONING_SYM
{
Lex->alter_info.flags|= ALTER_DROP_SYSTEM_VERSIONING;
Lex->create_info.options&= ~HA_VERSIONED_TABLE;
}
| DROP PERIOD_SYM FOR_SYSTEM_TIME_SYM
{
@@ -7292,6 +7292,11 @@ serial_attribute:
{
Lex->last_field->versioning= $1;
Lex->create_info.options|= HA_VERSIONED_TABLE;
if (Lex->alter_info.flags & ALTER_DROP_SYSTEM_VERSIONING)
{
my_yyabort_error((ER_VERS_NOT_VERSIONED, MYF(0),
Lex->create_last_non_select_table->table_name.str));
}
}
;

@@ -8435,6 +8440,7 @@ alter_list_item:
| DROP SYSTEM VERSIONING_SYM
{
Lex->alter_info.flags|= ALTER_DROP_SYSTEM_VERSIONING;
Lex->create_info.options&= ~HA_VERSIONED_TABLE;
}
| DROP PERIOD_SYM FOR_SYSTEM_TIME_SYM
{

0 comments on commit 0b74c88

Please sign in to comment.
You can’t perform that action at this time.