Commit 7069071d authored by Aleksey Midenkov's avatar Aleksey Midenkov

MDEV-14786 Server crashes in Item_cond::transform on 2nd execution of SP...

MDEV-14786 Server crashes in Item_cond::transform on 2nd execution of SP querying from a view [fixes #436]
parent 19f0b512
...@@ -232,6 +232,19 @@ called_bad ...@@ -232,6 +232,19 @@ called_bad
called_bad called_bad
called_bad called_bad
# bad() is good. # bad() is good.
# MDEV-14786 Server crashes in Item_cond::transform on 2nd execution of SP querying from a view [#436]
create or replace table t1 (called_bad int) with system versioning;
create or replace view v1 as select called_bad from t1 where called_bad < 5;
create or replace procedure bad() select called_bad from v1;
called_bad
called_bad
called_bad
called_bad
called_bad
called_bad
called_bad
called_bad
# bad() is good.
# wildcard expansion on hidden fields. # wildcard expansion on hidden fields.
create or replace table t1( create or replace table t1(
A int A int
...@@ -255,7 +268,7 @@ create or replace table t1 (a int) with system versioning; ...@@ -255,7 +268,7 @@ create or replace table t1 (a int) with system versioning;
create or replace table t2 (a int) with system versioning; create or replace table t2 (a int) with system versioning;
insert into t1 values(1); insert into t1 values(1);
insert into t2 values(1); insert into t2 values(1);
create view v1 as select * from t2 inner join t1 using (a); create or replace view v1 as select * from t2 inner join t1 using (a);
select * from v1; select * from v1;
a a
1 1
......
...@@ -125,6 +125,16 @@ drop procedure bad; ...@@ -125,6 +125,16 @@ drop procedure bad;
--enable_query_log --enable_query_log
--echo # bad() is good. --echo # bad() is good.
--echo # MDEV-14786 Server crashes in Item_cond::transform on 2nd execution of SP querying from a view [#436]
create or replace table t1 (called_bad int) with system versioning;
create or replace view v1 as select called_bad from t1 where called_bad < 5;
create or replace procedure bad() select called_bad from v1;
--disable_query_log
call bad; call bad; call bad; call bad; call bad; call bad; call bad; call bad;
drop procedure bad;
--enable_query_log
--echo # bad() is good.
--echo # wildcard expansion on hidden fields. --echo # wildcard expansion on hidden fields.
create or replace table t1( create or replace table t1(
A int A int
...@@ -149,7 +159,7 @@ create or replace table t1 (a int) with system versioning; ...@@ -149,7 +159,7 @@ create or replace table t1 (a int) with system versioning;
create or replace table t2 (a int) with system versioning; create or replace table t2 (a int) with system versioning;
insert into t1 values(1); insert into t1 values(1);
insert into t2 values(1); insert into t2 values(1);
create view v1 as select * from t2 inner join t1 using (a); create or replace view v1 as select * from t2 inner join t1 using (a);
select * from v1; select * from v1;
drop view v1; drop view v1;
......
...@@ -14904,6 +14904,8 @@ static COND* substitute_for_best_equal_field(THD *thd, JOIN_TAB *context_tab, ...@@ -14904,6 +14904,8 @@ static COND* substitute_for_best_equal_field(THD *thd, JOIN_TAB *context_tab,
Item_equal *item_equal; Item_equal *item_equal;
COND *org_cond= cond; // Return this in case of fatal error COND *org_cond= cond; // Return this in case of fatal error
Query_arena_stmt on_stmt_arena(thd);
if (cond->type() == Item::COND_ITEM) if (cond->type() == Item::COND_ITEM)
{ {
List<Item> *cond_list= ((Item_cond*) cond)->argument_list(); List<Item> *cond_list= ((Item_cond*) cond)->argument_list();
...@@ -16025,6 +16027,8 @@ optimize_cond(JOIN *join, COND *conds, ...@@ -16025,6 +16027,8 @@ optimize_cond(JOIN *join, COND *conds,
THD *thd= join->thd; THD *thd= join->thd;
DBUG_ENTER("optimize_cond"); DBUG_ENTER("optimize_cond");
Query_arena_stmt on_stmt_arena(thd);
if (!conds) if (!conds)
{ {
*cond_value= Item::COND_TRUE; *cond_value= Item::COND_TRUE;
......
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