Commit 356005ef authored by konstantin@mysql.com's avatar konstantin@mysql.com

A fix and test case for Bug#6873 "PS, having with subquery, crash

during execute"
parent c09c1911
...@@ -471,3 +471,14 @@ select @var is null, @var is not null, @var; ...@@ -471,3 +471,14 @@ select @var is null, @var is not null, @var;
execute stmt using @var, @var, @var; execute stmt using @var, @var, @var;
? is null ? is not null ? ? is null ? is not null ?
1 0 NULL 1 0 NULL
create table t1 (pnum char(3));
create table t2 (pnum char(3));
prepare stmt from "select pnum from t2 having pnum in (select 'p1' from t1)";
execute stmt;
pnum
execute stmt;
pnum
execute stmt;
pnum
deallocate prepare stmt;
drop table t1, t2;
...@@ -471,3 +471,17 @@ execute stmt using @var, @var, @var; ...@@ -471,3 +471,17 @@ execute stmt using @var, @var, @var;
set @var=null; set @var=null;
select @var is null, @var is not null, @var; select @var is null, @var is not null, @var;
execute stmt using @var, @var, @var; execute stmt using @var, @var, @var;
#
# Bug#6873 "PS, having with subquery, crash during execute"
# check that if we modify having subtree, we update JOIN->having pointer
#
create table t1 (pnum char(3));
create table t2 (pnum char(3));
prepare stmt from "select pnum from t2 having pnum in (select 'p1' from t1)";
execute stmt;
execute stmt;
execute stmt;
deallocate prepare stmt;
drop table t1, t2;
...@@ -155,6 +155,8 @@ bool Item_subselect::fix_fields(THD *thd_param, TABLE_LIST *tables, Item **ref) ...@@ -155,6 +155,8 @@ bool Item_subselect::fix_fields(THD *thd_param, TABLE_LIST *tables, Item **ref)
// did we changed top item of WHERE condition // did we changed top item of WHERE condition
if (unit->outer_select()->where == (*ref)) if (unit->outer_select()->where == (*ref))
unit->outer_select()->where= substitution; // correct WHERE for PS unit->outer_select()->where= substitution; // correct WHERE for PS
else if (unit->outer_select()->having == (*ref))
unit->outer_select()->having= substitution; // correct HAVING for PS
(*ref)= substitution; (*ref)= substitution;
substitution->name= name; substitution->name= name;
......
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