From a04a283469adf135c84a7985818dc99b633e0357 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Thu, 21 Dec 2017 10:14:25 +0300 Subject: [PATCH] MDEV-14692 Server crash in MDL_ticket::has_stronger_or_equal_type SQL: disable system-versioning stuff on TEMPORARY tables --- mysql-test/suite/versioning/r/alter.result | 6 ++++++ mysql-test/suite/versioning/r/create.result | 2 +- mysql-test/suite/versioning/t/alter.test | 8 ++++++++ mysql-test/suite/versioning/t/create.test | 2 +- sql/handler.cc | 9 +++++++-- sql/share/errmsg-utf8.txt | 3 +++ sql/sql_yacc.yy | 3 +-- 7 files changed, 27 insertions(+), 6 deletions(-) diff --git a/mysql-test/suite/versioning/r/alter.result b/mysql-test/suite/versioning/r/alter.result index 40d090ec72a..566c76dfe36 100644 --- a/mysql-test/suite/versioning/r/alter.result +++ b/mysql-test/suite/versioning/r/alter.result @@ -426,5 +426,11 @@ create or replace table t1 (pk int auto_increment unique) with system versioning insert into t1 values (1); delete from t1; alter table t1 engine=myisam; +# MDEV-14692 crash in MDL_context::upgrade_shared_lock() +create or replace temporary table t (a int); +alter table t change column if exists b c bigint unsigned generated always as row start; +ERROR HY000: GENERATED AS ROW START prohibited for TEMPORARY tables +alter table t change column if exists b c bigint unsigned generated always as row end; +ERROR HY000: GENERATED AS ROW END prohibited for TEMPORARY tables drop database test; create database test; diff --git a/mysql-test/suite/versioning/r/create.result b/mysql-test/suite/versioning/r/create.result index 629434f7518..ce6e7ad3e78 100644 --- a/mysql-test/suite/versioning/r/create.result +++ b/mysql-test/suite/versioning/r/create.result @@ -344,7 +344,7 @@ create or replace table t (sys_trx_end int); alter table t with system versioning; ERROR 42S21: Duplicate column name 'sys_trx_end' create or replace temporary table t (x28 int) with system versioning; -ERROR HY000: Incorrect usage of TEMPORARY and WITH SYSTEM VERSIONING +ERROR HY000: WITH SYSTEM VERSIONING prohibited for TEMPORARY tables create or replace table t1 ( x29 int unsigned, Sys_start0 timestamp(6) as row start invisible, diff --git a/mysql-test/suite/versioning/t/alter.test b/mysql-test/suite/versioning/t/alter.test index db0b63682a9..baa3f61c077 100644 --- a/mysql-test/suite/versioning/t/alter.test +++ b/mysql-test/suite/versioning/t/alter.test @@ -362,5 +362,13 @@ insert into t1 values (1); delete from t1; alter table t1 engine=myisam; +--echo # MDEV-14692 crash in MDL_context::upgrade_shared_lock() +create or replace temporary table t (a int); +--error ER_VERS_TEMPORARY +alter table t change column if exists b c bigint unsigned generated always as row start; +--error ER_VERS_TEMPORARY +alter table t change column if exists b c bigint unsigned generated always as row end; + + drop database test; create database test; diff --git a/mysql-test/suite/versioning/t/create.test b/mysql-test/suite/versioning/t/create.test index 9b78dccf00b..3e9a850644b 100644 --- a/mysql-test/suite/versioning/t/create.test +++ b/mysql-test/suite/versioning/t/create.test @@ -313,7 +313,7 @@ create or replace table t (sys_trx_end int); --error ER_DUP_FIELDNAME alter table t with system versioning; ---error ER_WRONG_USAGE +--error ER_VERS_TEMPORARY create or replace temporary table t (x28 int) with system versioning; --error ER_VERS_DUPLICATE_ROW_START_END diff --git a/sql/handler.cc b/sql/handler.cc index 17e93ad7346..5b8aaa99c5a 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -7188,9 +7188,14 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info, List_iterator_fast it(alter_info->create_list); while (Create_field *f= it++) { - if (f->change.length && - f->flags & (VERS_SYS_START_FLAG | VERS_SYS_END_FLAG)) + if (f->change.length && f->flags & VERS_SYSTEM_FIELD) { + if (share->table_category == TABLE_CATEGORY_TEMPORARY) { + my_error(ER_VERS_TEMPORARY, MYF(0), + f->flags & VERS_SYS_START_FLAG ? "GENERATED AS ROW START" + : "GENERATED AS ROW END"); + return true; + } if (thd->mdl_context.upgrade_shared_lock( table->mdl_ticket, MDL_EXCLUSIVE, thd->variables.lock_wait_timeout)) diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index 3fe0d33dc03..730910ed111 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -7932,3 +7932,6 @@ WARN_VERS_TRT_EXPERIMENTAL ER_VERS_TRUNCATE_VIEW eng "DELETE HISTORY from VIEW is prohibited" + +ER_VERS_TEMPORARY + eng "%s prohibited for TEMPORARY tables" diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 8d3a57ed411..9513ed2391e 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -6235,8 +6235,7 @@ versioning_option: { if (!thd->variables.vers_force) { - my_error(ER_WRONG_USAGE, MYF(0), - "TEMPORARY", "WITH SYSTEM VERSIONING"); + my_error(ER_VERS_TEMPORARY, MYF(0), "WITH SYSTEM VERSIONING"); MYSQL_YYABORT; } }