Commit dd93baa0 authored by unknown's avatar unknown

fixed joincleunup to avoid double deletin tables, and too earlyfull cleanup in case of EXPLAIN

fixed cleunup of TMP_TABLE_PARAM
(BUG#6406)


mysql-test/r/subselect.result:
  primary query with temporary table and subquery with groupping
mysql-test/t/subselect.test:
  primary query with temporary table and subquery with groupping
sql/sql_class.h:
  fixed cleunup of TMP_TABLE_PARAM
sql/sql_select.cc:
  uncacheable test made simplier
  fixed joincleunup to avoid double deletin tables, and too earlyfull cleanup in case of EXPLAIN
parent b685909d
...@@ -1991,3 +1991,15 @@ ac ...@@ -1991,3 +1991,15 @@ ac
NULL NULL
drop tables t1,t2; drop tables t1,t2;
set @got_val= (SELECT 1 FROM (SELECT 'A' as my_col) as T1 ) ; set @got_val= (SELECT 1 FROM (SELECT 'A' as my_col) as T1 ) ;
create table t1 (a int, b int);
create table t2 (a int, b int);
insert into t1 values (1,1),(1,2),(1,3),(2,4),(2,5);
insert into t2 values (1,3),(2,1);
select distinct a,b, (select max(b) from t2 where t1.b=t2.a) from t1 order by t1.b;
a b (select max(b) from t2 where t1.b=t2.a)
1 1 3
1 2 1
1 3 NULL
2 4 NULL
2 5 NULL
drop table t1, t2;
...@@ -1289,3 +1289,13 @@ drop tables t1,t2; ...@@ -1289,3 +1289,13 @@ drop tables t1,t2;
connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK); connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
connection root; connection root;
set @got_val= (SELECT 1 FROM (SELECT 'A' as my_col) as T1 ) ; set @got_val= (SELECT 1 FROM (SELECT 'A' as my_col) as T1 ) ;
#
# primary query with temporary table and subquery with groupping
#
create table t1 (a int, b int);
create table t2 (a int, b int);
insert into t1 values (1,1),(1,2),(1,3),(2,4),(2,5);
insert into t2 values (1,3),(2,1);
select distinct a,b, (select max(b) from t2 where t1.b=t2.a) from t1 order by t1.b;
drop table t1, t2;
...@@ -1305,7 +1305,7 @@ class TMP_TABLE_PARAM :public Sql_alloc ...@@ -1305,7 +1305,7 @@ class TMP_TABLE_PARAM :public Sql_alloc
if (copy_field) /* Fix for Intel compiler */ if (copy_field) /* Fix for Intel compiler */
{ {
delete [] copy_field; delete [] copy_field;
copy_field=0; save_copy_field= copy_field= 0;
} }
} }
}; };
......
...@@ -936,7 +936,7 @@ JOIN::optimize() ...@@ -936,7 +936,7 @@ JOIN::optimize()
} }
} }
if (select_lex->master_unit()->uncacheable) if (select_lex->uncacheable)
{ {
if (!(tmp_join= (JOIN*)thd->alloc(sizeof(JOIN)))) if (!(tmp_join= (JOIN*)thd->alloc(sizeof(JOIN))))
DBUG_RETURN(-1); DBUG_RETURN(-1);
...@@ -3833,7 +3833,8 @@ JOIN::join_free(bool full) ...@@ -3833,7 +3833,8 @@ JOIN::join_free(bool full)
JOIN_TAB *tab,*end; JOIN_TAB *tab,*end;
DBUG_ENTER("JOIN::join_free"); DBUG_ENTER("JOIN::join_free");
full= full || !select_lex->uncacheable; full= full || (!select_lex->uncacheable &&
!thd->lex->describe);
if (table) if (table)
{ {
...@@ -3862,6 +3863,7 @@ JOIN::join_free(bool full) ...@@ -3862,6 +3863,7 @@ JOIN::join_free(bool full)
for (tab= join_tab, end= tab+tables; tab != end; tab++) for (tab= join_tab, end= tab+tables; tab != end; tab++)
tab->cleanup(); tab->cleanup();
table= 0; table= 0;
tables= 0;
} }
else else
{ {
......
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