Skip to content

Commit

Permalink
MDEV-29357 Assertion (fixed) in Item_func_dayname on INSERT
Browse files Browse the repository at this point in the history
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().
  • Loading branch information
midenok committed Jul 20, 2023
1 parent 14cc7e7 commit 3e7561c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
18 changes: 18 additions & 0 deletions mysql-test/suite/vcol/r/vcol_syntax.result
Expand Up @@ -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;
12 changes: 12 additions & 0 deletions mysql-test/suite/vcol/t/vcol_syntax.test
Expand Up @@ -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;
7 changes: 6 additions & 1 deletion sql/sql_base.cc
Expand Up @@ -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. */
Expand Down

0 comments on commit 3e7561c

Please sign in to comment.