mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 18:20:07 +01:00
now we create temporary join for all queries with subqueries to make correct cleunup of tables and avoid too early unlock (BUG#6841)
This commit is contained in:
parent
d5b21d03a5
commit
f20e7a82b7
5 changed files with 14 additions and 2 deletions
|
@ -125,3 +125,12 @@ INSERT INTO `t2` VALUES ('yy','xx');
|
|||
SELECT R.unit, R.ingredient FROM t1 R WHERE R.ingredient IN (SELECT N.ingredient FROM t2 N WHERE N.unit = R.unit);
|
||||
|
||||
drop table t1, t2;
|
||||
|
||||
#
|
||||
# possible early unlock
|
||||
#
|
||||
CREATE TABLE t1 ( id INT NOT NULL auto_increment, date1 DATE, coworkerid INT, description VARCHAR(255), sum_used DOUBLE, sum_remaining DOUBLE, comments VARCHAR(255), PRIMARY KEY(id)) engine=innodb;
|
||||
insert into t1 values (NULL, '1999-01-01', 1,'test', 22, 33, 'comment'), (NULL, '1999-01-01', 1,'test', 22, 33, 'comment'), (NULL, '1999-01-01', 1,'test', 22, 33, 'comment'), (NULL, '1998-01-01', 1,'test', 22, 33, 'comment'), (NULL, '1998-01-01', 1,'test', 22, 33, 'comment'), (NULL, '2004-01-01', 1,'test', 22, 33, 'comment'), (NULL, '2004-01-01', 1,'test', 22, 33, 'comment');
|
||||
SELECT DISTINCT (SELECT sum(sum_used) FROM t1 WHERE sum_used > 0 AND year(date1) <= '2004') as somallontvangsten, (SELECT sum(sum_used) FROM t1 WHERE sum_used < 0 AND year(date1) <= '2004') as somalluitgaven FROM t1;
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
|
|
@ -135,7 +135,7 @@ void lex_start(THD *thd, uchar *buf,uint length)
|
|||
lex->select_lex.link_prev= (st_select_lex_node**)&(lex->all_selects_list);
|
||||
lex->select_lex.options= 0;
|
||||
lex->describe= 0;
|
||||
lex->derived_tables= FALSE;
|
||||
lex->subqueries= lex->derived_tables= FALSE;
|
||||
lex->lock_option= TL_READ;
|
||||
lex->found_colon= 0;
|
||||
lex->safe_to_cache_query= 1;
|
||||
|
|
|
@ -619,6 +619,7 @@ typedef struct st_lex
|
|||
bool in_comment, ignore_space, verbose, no_write_to_binlog;
|
||||
bool derived_tables;
|
||||
bool safe_to_cache_query;
|
||||
bool subqueries;
|
||||
ALTER_INFO alter_info;
|
||||
/* Prepared statements SQL syntax:*/
|
||||
LEX_STRING prepared_stmt_name; /* Statement name (in all queries) */
|
||||
|
|
|
@ -3955,6 +3955,7 @@ mysql_new_select(LEX *lex, bool move_down)
|
|||
select_lex->init_select();
|
||||
if (move_down)
|
||||
{
|
||||
lex->subqueries= TRUE;
|
||||
/* first select_lex of subselect or derived table */
|
||||
SELECT_LEX_UNIT *unit;
|
||||
if (!(unit= new(lex->thd->mem_root) SELECT_LEX_UNIT()))
|
||||
|
|
|
@ -936,7 +936,7 @@ JOIN::optimize()
|
|||
}
|
||||
}
|
||||
|
||||
if (select_lex->uncacheable)
|
||||
if (thd->lex->subqueries)
|
||||
{
|
||||
if (!(tmp_join= (JOIN*)thd->alloc(sizeof(JOIN))))
|
||||
DBUG_RETURN(-1);
|
||||
|
@ -3834,6 +3834,7 @@ JOIN::join_free(bool full)
|
|||
DBUG_ENTER("JOIN::join_free");
|
||||
|
||||
full= full || (!select_lex->uncacheable &&
|
||||
!thd->lex->subqueries &&
|
||||
!thd->lex->describe); // do not cleanup too early on EXPLAIN
|
||||
|
||||
if (table)
|
||||
|
|
Loading…
Add table
Reference in a new issue