Commit dd93baa0 authored by unknown's avatar unknown
Browse files

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
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -1991,3 +1991,15 @@ ac
NULL
drop tables t1,t2;
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;
+10 −0
Original line number Diff line number Diff line
@@ -1289,3 +1289,13 @@ drop tables t1,t2;
connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
connection root;
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;
+1 −1
Original line number Diff line number Diff line
@@ -1305,7 +1305,7 @@ class TMP_TABLE_PARAM :public Sql_alloc
    if (copy_field)				/* Fix for Intel compiler */
    {
      delete [] copy_field;
      copy_field=0;
      save_copy_field= copy_field= 0;
    }
  }
};
+4 −2
Original line number Diff line number Diff line
@@ -936,7 +936,7 @@ JOIN::optimize()
      }
    }
    
    if (select_lex->master_unit()->uncacheable)
    if (select_lex->uncacheable)
    {
      if (!(tmp_join= (JOIN*)thd->alloc(sizeof(JOIN))))
	DBUG_RETURN(-1);
@@ -3833,7 +3833,8 @@ JOIN::join_free(bool full)
  JOIN_TAB *tab,*end;
  DBUG_ENTER("JOIN::join_free");

  full= full || !select_lex->uncacheable;
  full= full || (!select_lex->uncacheable &&
                 !thd->lex->describe);

  if (table)
  {
@@ -3862,6 +3863,7 @@ JOIN::join_free(bool full)
      for (tab= join_tab, end= tab+tables; tab != end; tab++)
	tab->cleanup();
      table= 0;
      tables= 0;
    }
    else
    {