summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Midenkov <midenok@gmail.com>2019-04-11 10:04:34 +0300
committerAleksey Midenkov <midenok@gmail.com>2019-08-11 12:32:08 +0300
commit0b74c8832d45340a455f27c3b4aa20db5d8313db (patch)
treeb0d81bb973c5918b3a4ca273e7e07c2a5e02c385
parent638e78853f8d7c0e2c1cf580f3847c5789f165e1 (diff)
downloadmariadb-git-0b74c8832d45340a455f27c3b4aa20db5d8313db.tar.gz
MDEV-19127 Assertion `row_start_field' failed in vers_prepare_keys upon ALTER TABLE
Prevent conflicting clauses at parser level. Clear HA_VERSIONED_TABLE flag for DROP SYSTEM VERSIONING (for the sake of strictness).
-rw-r--r--mysql-test/suite/versioning/r/alter.result9
-rw-r--r--mysql-test/suite/versioning/t/alter.test10
-rw-r--r--sql/sql_yacc.yy6
-rw-r--r--sql/sql_yacc_ora.yy6
4 files changed, 31 insertions, 0 deletions
diff --git a/mysql-test/suite/versioning/r/alter.result b/mysql-test/suite/versioning/r/alter.result
index 0c79e6d4a39..2afd3921154 100644
--- a/mysql-test/suite/versioning/r/alter.result
+++ b/mysql-test/suite/versioning/r/alter.result
@@ -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;
diff --git a/mysql-test/suite/versioning/t/alter.test b/mysql-test/suite/versioning/t/alter.test
index ea699104eac..c04c2020460 100644
--- a/mysql-test/suite/versioning/t/alter.test
+++ b/mysql-test/suite/versioning/t/alter.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;
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index d5e579e9df5..c1b2fd2294b 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -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
{
diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy
index 45f770b0c88..28d3d1bf90b 100644
--- a/sql/sql_yacc_ora.yy
+++ b/sql/sql_yacc_ora.yy
@@ -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
{