From 2ebfb836ab62ccf3cb45d2e527c0635b9bb64094 Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Mon, 17 Mar 2003 15:16:26 +0200 Subject: [PATCH 1/2] A fix for a bug reported by Per Erik Martin, partaining to usage of expressions whose result are to be saved into user vars. --- sql/item.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sql/item.cc b/sql/item.cc index 3c6b85e933b..becda6751bc 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1192,7 +1192,16 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference) } } - if (((*ref)->with_sum_func && +/* + * The following conditional is changed as to correctly identify + * incorrect references in group functions or forward references + * with sub-select's / derived tables, while it prevents this + * check when Item_ref is created in an expression involving + * summing function, which is to be placed in the user variable. + * + */ + + if (((*ref)->with_sum_func && name && (depended_from || !(thd->lex.current_select->linkage != GLOBAL_OPTIONS_TYPE && thd->lex.current_select->select_lex()->having_fix_field))) || From 07c96e1ea74cf6ed6e046512d449e5663ee39ecf Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Thu, 20 Mar 2003 20:44:56 +0200 Subject: [PATCH 2/2] A test case for the bug fix as per PEM's reported bug #118. Patch is already commited and approved by Sanja ..;o) --- mysql-test/r/variables.result | 1 + mysql-test/t/variables.test | 1 + 2 files changed, 2 insertions(+) diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index 822fab5ae47..4b3046770dc 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -333,4 +333,5 @@ check table t1,t2; Table Op Msg_type Msg_text test.t1 check status OK test.t2 check status OK +select max(a) +1, max(a) +2 into @xx,@yy from t1; drop table t1,t2; diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 4bde54f868a..7671b663738 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -241,5 +241,6 @@ select @@key_buffer_size; select * from t1 where a=2; select * from t2 where a=3; check table t1,t2; +select max(a) +1, max(a) +2 into @xx,@yy from t1; drop table t1,t2;