Commit 755c9aab authored by unknown's avatar unknown

fixed cleanup of result object of subqueries. (BUG#8125)


mysql-test/r/subselect.result:
  cleaning up of results of subselects test
mysql-test/t/subselect.test:
  cleaning up of results of subselects test
sql/item_subselect.cc:
  call result object cleupup on engine cleunup
sql/sql_class.cc:
  added cleanup of select_max_min_finder_subselect
sql/sql_class.h:
  added cleanup of select_max_min_finder_subselect
parent 38e664cf
...@@ -2196,3 +2196,15 @@ ERROR 42S22: Reference 'xx' not supported (forward reference in item list) ...@@ -2196,3 +2196,15 @@ ERROR 42S22: Reference 'xx' not supported (forward reference in item list)
select 1 = ALL (select 1 from t1 where 1 = xx ), 1 as xx from DUAL; select 1 = ALL (select 1 from t1 where 1 = xx ), 1 as xx from DUAL;
ERROR 42S22: Reference 'xx' not supported (forward reference in item list) ERROR 42S22: Reference 'xx' not supported (forward reference in item list)
drop table t1; drop table t1;
CREATE TABLE `t1` ( `a` char(3) NOT NULL default '', `b` char(3) NOT NULL default '', `c` char(3) NOT NULL default '', PRIMARY KEY (`a`,`b`,`c`)) ENGINE=InnoDB;
CREATE TABLE t2 LIKE t1;
INSERT INTO t1 VALUES (1,1,1);
INSERT INTO t2 VALUES (1,1,1);
PREPARE my_stmt FROM "SELECT t1.b, count(*) FROM t1 group by t1.b having
count(*) > ALL (SELECT COUNT(*) FROM t2 WHERE t2.a=1 GROUP By t2.b)";
EXECUTE my_stmt;
b count(*)
EXECUTE my_stmt;
b count(*)
deallocate prepare my_stmt;
drop table t1,t2;
...@@ -1465,3 +1465,17 @@ select 1 = ALL (select 1 from t1 where 1 = xx ), 1 as xx; ...@@ -1465,3 +1465,17 @@ select 1 = ALL (select 1 from t1 where 1 = xx ), 1 as xx;
-- error 1247 -- error 1247
select 1 = ALL (select 1 from t1 where 1 = xx ), 1 as xx from DUAL; select 1 = ALL (select 1 from t1 where 1 = xx ), 1 as xx from DUAL;
drop table t1; drop table t1;
#
# cleaning up of results of subselects (BUG#8125)
#
CREATE TABLE `t1` ( `a` char(3) NOT NULL default '', `b` char(3) NOT NULL default '', `c` char(3) NOT NULL default '', PRIMARY KEY (`a`,`b`,`c`)) ENGINE=InnoDB;
CREATE TABLE t2 LIKE t1;
INSERT INTO t1 VALUES (1,1,1);
INSERT INTO t2 VALUES (1,1,1);
PREPARE my_stmt FROM "SELECT t1.b, count(*) FROM t1 group by t1.b having
count(*) > ALL (SELECT COUNT(*) FROM t2 WHERE t2.a=1 GROUP By t2.b)";
EXECUTE my_stmt;
EXECUTE my_stmt;
deallocate prepare my_stmt;
drop table t1,t2;
...@@ -1127,6 +1127,7 @@ void subselect_single_select_engine::cleanup() ...@@ -1127,6 +1127,7 @@ void subselect_single_select_engine::cleanup()
DBUG_ENTER("subselect_single_select_engine::cleanup"); DBUG_ENTER("subselect_single_select_engine::cleanup");
prepared= optimized= executed= 0; prepared= optimized= executed= 0;
join= 0; join= 0;
result->cleanup();
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -1135,6 +1136,7 @@ void subselect_union_engine::cleanup() ...@@ -1135,6 +1136,7 @@ void subselect_union_engine::cleanup()
{ {
DBUG_ENTER("subselect_union_engine::cleanup"); DBUG_ENTER("subselect_union_engine::cleanup");
unit->reinit_exec_mechanism(); unit->reinit_exec_mechanism();
result->cleanup();
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -1142,6 +1144,10 @@ void subselect_union_engine::cleanup() ...@@ -1142,6 +1144,10 @@ void subselect_union_engine::cleanup()
void subselect_uniquesubquery_engine::cleanup() void subselect_uniquesubquery_engine::cleanup()
{ {
DBUG_ENTER("subselect_uniquesubquery_engine::cleanup"); DBUG_ENTER("subselect_uniquesubquery_engine::cleanup");
/*
subselect_uniquesubquery_engine have not 'result' assigbed, so we do not
cleanup() it
*/
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
......
...@@ -1240,6 +1240,14 @@ bool select_singlerow_subselect::send_data(List<Item> &items) ...@@ -1240,6 +1240,14 @@ bool select_singlerow_subselect::send_data(List<Item> &items)
} }
void select_max_min_finder_subselect::cleanup()
{
DBUG_ENTER("select_max_min_finder_subselect::cleanup");
cache= 0;
DBUG_VOID_RETURN;
}
bool select_max_min_finder_subselect::send_data(List<Item> &items) bool select_max_min_finder_subselect::send_data(List<Item> &items)
{ {
DBUG_ENTER("select_max_min_finder_subselect::send_data"); DBUG_ENTER("select_max_min_finder_subselect::send_data");
......
...@@ -1381,6 +1381,7 @@ class select_max_min_finder_subselect :public select_subselect ...@@ -1381,6 +1381,7 @@ class select_max_min_finder_subselect :public select_subselect
select_max_min_finder_subselect(Item_subselect *item, bool mx) select_max_min_finder_subselect(Item_subselect *item, bool mx)
:select_subselect(item), cache(0), fmax(mx) :select_subselect(item), cache(0), fmax(mx)
{} {}
void cleanup();
bool send_data(List<Item> &items); bool send_data(List<Item> &items);
bool cmp_real(); bool cmp_real();
bool cmp_int(); bool cmp_int();
......
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