Commit be92dce6 authored by Aleksey Midenkov's avatar Aleksey Midenkov

MDEV-21234 Server crashes in in setup_on_expr upon 3rd execution of SP

Versioned conditions in on_expr can not be rebuilt at optimization
stage on non-conventional arena.
parent 1fbd9bb2
...@@ -586,6 +586,30 @@ call p; ...@@ -586,6 +586,30 @@ call p;
i i
drop procedure p; drop procedure p;
drop table t1; drop table t1;
#
# MDEV-21234 Server crashes in in setup_on_expr upon 3rd execution of SP
#
create table t1 (a varchar(8));
insert into t1 values ('foo'),('bar');
create table t2 (b date);
create procedure pr() insert into t2 select * from t1;
call pr;
ERROR 22007: Incorrect date value: 'foo' for column `test`.`t2`.`b` at row 1
prepare stmt from 'insert into t2 select * from t1';
execute stmt;
ERROR 22007: Incorrect date value: 'foo' for column `test`.`t2`.`b` at row 1
alter table t1 add system versioning;
call pr;
ERROR 22007: Incorrect date value: 'foo' for column `test`.`t2`.`b` at row 1
call pr;
ERROR 22007: Incorrect date value: 'foo' for column `test`.`t2`.`b` at row 1
execute stmt;
ERROR 22007: Incorrect date value: 'foo' for column `test`.`t2`.`b` at row 1
execute stmt;
ERROR 22007: Incorrect date value: 'foo' for column `test`.`t2`.`b` at row 1
drop prepare stmt;
drop procedure pr;
drop table t1, t2;
call verify_trt_dummy(34); call verify_trt_dummy(34);
No A B C D No A B C D
1 1 1 1 1 1 1 1 1 1
......
...@@ -392,6 +392,35 @@ call p; ...@@ -392,6 +392,35 @@ call p;
drop procedure p; drop procedure p;
drop table t1; drop table t1;
--echo #
--echo # MDEV-21234 Server crashes in in setup_on_expr upon 3rd execution of SP
--echo #
create table t1 (a varchar(8));
insert into t1 values ('foo'),('bar');
create table t2 (b date);
create procedure pr() insert into t2 select * from t1;
--error ER_TRUNCATED_WRONG_VALUE
call pr;
prepare stmt from 'insert into t2 select * from t1';
--error ER_TRUNCATED_WRONG_VALUE
execute stmt;
alter table t1 add system versioning;
--error ER_TRUNCATED_WRONG_VALUE
call pr;
--error ER_TRUNCATED_WRONG_VALUE
call pr;
--error ER_TRUNCATED_WRONG_VALUE
execute stmt;
--error ER_TRUNCATED_WRONG_VALUE
execute stmt;
drop prepare stmt;
# cleanup
drop procedure pr;
drop table t1, t2;
call verify_trt_dummy(34); call verify_trt_dummy(34);
-- source suite/versioning/common_finish.inc -- source suite/versioning/common_finish.inc
...@@ -1713,7 +1713,20 @@ JOIN::optimize_inner() ...@@ -1713,7 +1713,20 @@ JOIN::optimize_inner()
} }
} }
conds= optimize_cond(this, conds, join_list, FALSE, bool ignore_on_expr= false;
/*
PS/SP note: on_expr of versioned table can not be reallocated
(see build_equal_items() below) because it can be not rebuilt
at second invocation.
*/
if (!thd->stmt_arena->is_conventional() && thd->mem_root != thd->stmt_arena->mem_root)
for (TABLE_LIST *tbl= tables_list; tbl; tbl= tbl->next_local)
if (tbl->table && tbl->on_expr && tbl->table->versioned())
{
ignore_on_expr= true;
break;
}
conds= optimize_cond(this, conds, join_list, ignore_on_expr,
&cond_value, &cond_equal, OPT_LINK_EQUAL_FIELDS); &cond_value, &cond_equal, OPT_LINK_EQUAL_FIELDS);
if (thd->is_error()) if (thd->is_error())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment