From 6da897e04b3da790dfd0eed9d26dddf558e000dc Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 14 Mar 2003 14:16:09 +0200 Subject: [PATCH] fixed uncachable union (bug #150) mysql-test/r/union.result: sect of uncachable union mysql-test/t/union.test: sect of uncachable union sql/sql_lex.h: fixed uncachable union --- mysql-test/r/union.result | 4 ++++ mysql-test/t/union.test | 2 ++ sql/sql_lex.h | 10 ++++++---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index bf79af2831a..0edf5df7ae1 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -269,3 +269,7 @@ id select_type table type possible_keys key key_len ref rows Extra drop table t1,t2; (select 1) union (select 2) order by 0; Unknown column '0' in 'order clause' +SELECT @a:=1 UNION SELECT @a:=@a+1; +@a:=1 +1 +2 diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index d41860c1b72..d2f35b59f54 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -144,3 +144,5 @@ explain (select * from t1 where a=1) union (select * from t1 where b=1); drop table t1,t2; --error 1054 (select 1) union (select 2) order by 0; + +SELECT @a:=1 UNION SELECT @a:=@a+1; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 21c151d33b2..2d79feeaf2b 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -501,11 +501,13 @@ typedef struct st_lex but we should merk all subselects as uncacheable from current till most upper */ - for (SELECT_LEX_NODE *sl= current_select; - sl != &select_lex; - sl= sl->outer_select()) + SELECT_LEX_NODE *sl; + SELECT_LEX_UNIT *un; + for (sl= current_select, un= sl->master_unit(); + un != &unit; + sl= sl->outer_select(), un= sl->master_unit()) { - sl->uncacheable = sl->master_unit()->uncacheable= 1; + sl->uncacheable = un->uncacheable= 1; } } } LEX;