From 3e7561cf35a1241083e88ed530a22aab6712335e Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Thu, 20 Jul 2023 14:14:00 +0300 Subject: [PATCH] MDEV-29357 Assertion (fixed) in Item_func_dayname on INSERT Restrict vcol_cleanup_expr() in close_thread_tables() to only simple locked tables mode. Prelocked is cleaned up like normal statement: in close_thread_table(). --- mysql-test/suite/vcol/r/vcol_syntax.result | 18 ++++++++++++++++++ mysql-test/suite/vcol/t/vcol_syntax.test | 12 ++++++++++++ sql/sql_base.cc | 7 ++++++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/vcol/r/vcol_syntax.result b/mysql-test/suite/vcol/r/vcol_syntax.result index dd38a1992e56d..f1a850e8f7c11 100644 --- a/mysql-test/suite/vcol/r/vcol_syntax.result +++ b/mysql-test/suite/vcol/r/vcol_syntax.result @@ -216,3 +216,21 @@ Warnings: Warning 1292 Truncated incorrect DOUBLE value: 'foo' Warning 1292 Truncated incorrect DOUBLE value: 'bar' drop table t, tmp; +# +# MDEV-29357 Assertion (fixed) in Item_func_dayname on INSERT +# +set sql_mode=''; +create table t (c1 blob ,c2 int,c3 char(10) as (dayname (c2))); +create trigger tr before insert on t for each row set new.c2=0; +insert into t values (0, 0, 0); +Warnings: +Warning 1906 The value specified for generated column 'c3' in table 't' has been ignored +Warning 1292 Incorrect datetime value: '0' for column `test`.`t`.`c2` at row 1 +Warning 1292 Incorrect datetime value: '0' for column `test`.`t`.`c2` at row 1 +insert into t values (1, 1, 1); +Warnings: +Warning 1906 The value specified for generated column 'c3' in table 't' has been ignored +Warning 1292 Incorrect datetime value: '1' for column `test`.`t`.`c2` at row 1 +Warning 1292 Incorrect datetime value: '0' for column `test`.`t`.`c2` at row 1 +drop trigger tr; +drop table t; diff --git a/mysql-test/suite/vcol/t/vcol_syntax.test b/mysql-test/suite/vcol/t/vcol_syntax.test index 3a0ed0270e288..cb741bc6deff3 100644 --- a/mysql-test/suite/vcol/t/vcol_syntax.test +++ b/mysql-test/suite/vcol/t/vcol_syntax.test @@ -173,3 +173,15 @@ select * from t; # cleanup drop table t, tmp; + +--echo # +--echo # MDEV-29357 Assertion (fixed) in Item_func_dayname on INSERT +--echo # +set sql_mode=''; +create table t (c1 blob ,c2 int,c3 char(10) as (dayname (c2))); +create trigger tr before insert on t for each row set new.c2=0; +insert into t values (0, 0, 0); +insert into t values (1, 1, 1); + +drop trigger tr; +drop table t; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 37336a83bfb30..47b9c4c6db997 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -913,7 +913,12 @@ void close_thread_tables(THD *thd) !thd->stmt_arena->is_stmt_prepare()) table->part_info->vers_check_limit(thd); #endif - table->vcol_cleanup_expr(thd); + /* + For simple locking we cleanup it here because we don't close thread + tables. For prelocking we close it when we do close thread tables. + */ + if (thd->locked_tables_mode != LTM_PRELOCKED) + table->vcol_cleanup_expr(thd); } /* Detach MERGE children after every statement. Even under LOCK TABLES. */