summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormonty@narttu.mysql.fi <>2003-03-25 13:07:02 +0200
committermonty@narttu.mysql.fi <>2003-03-25 13:07:02 +0200
commita71abe822d895ba591caeb9aed65c37bed90350a (patch)
treeea2e0a0a8dadfdb68e520eeb48e6da58534a0a1e
parent33934323900b339644c06006b29ea3c34272e7fb (diff)
parent9a7b0ef83d9c9cd2fcd8b50a6a6e0689702dbe9f (diff)
downloadmariadb-git-a71abe822d895ba591caeb9aed65c37bed90350a.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-4.0
into narttu.mysql.fi:/my/mysql-4.0
-rw-r--r--mysql-test/r/group_by.result19
-rw-r--r--mysql-test/t/group_by.test12
-rw-r--r--sql/item.cc1
3 files changed, 32 insertions, 0 deletions
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result
index 0694e284115..f73c4d7f8af 100644
--- a/mysql-test/r/group_by.result
+++ b/mysql-test/r/group_by.result
@@ -569,3 +569,22 @@ a MAX(b) MAKE_SET(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h')
1 4 c
10 43 a,b,d,f
drop table t1;
+create table t1 (id int not null, qty int not null);
+insert into t1 values (1,2),(1,3),(2,4),(2,5);
+select id, sum(qty) as sqty, count(qty) as cqty from t1 group by id having sum(qty)>2 and cqty>1;
+id sqty cqty
+1 5 2
+2 9 2
+select id, sum(qty) as sqty from t1 group by id having sqty>2 and count(qty)>1;
+id sqty
+1 5
+2 9
+select id, sum(qty) as sqty, count(qty) as cqty from t1 group by id having sqty>2 and cqty>1;
+id sqty cqty
+1 5 2
+2 9 2
+select id, sum(qty) as sqty, count(qty) as cqty from t1 group by id having sum(qty)>2 and count(qty)>1;
+id sqty cqty
+1 5 2
+2 9 2
+drop table t1;
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test
index 5875f9a9ba9..9e5ee4b8b2a 100644
--- a/mysql-test/t/group_by.test
+++ b/mysql-test/t/group_by.test
@@ -417,3 +417,15 @@ select a, MAX(b), CONCAT_WS(MAX(b), '43', '4', '5') from t1 group by a;
select a, MAX(b), ELT(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f') from t1 group by a;
select a, MAX(b), MAKE_SET(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h') from t1 group by a;
drop table t1;
+
+#
+# Problem with group by and alias
+#
+
+create table t1 (id int not null, qty int not null);
+insert into t1 values (1,2),(1,3),(2,4),(2,5);
+select id, sum(qty) as sqty, count(qty) as cqty from t1 group by id having sum(qty)>2 and cqty>1;
+select id, sum(qty) as sqty from t1 group by id having sqty>2 and count(qty)>1;
+select id, sum(qty) as sqty, count(qty) as cqty from t1 group by id having sqty>2 and cqty>1;
+select id, sum(qty) as sqty, count(qty) as cqty from t1 group by id having sum(qty)>2 and count(qty)>1;
+drop table t1;
diff --git a/sql/item.cc b/sql/item.cc
index 0046f53c6fb..4fefae7358f 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -665,6 +665,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables)
maybe_null= (*ref)->maybe_null;
decimals= (*ref)->decimals;
binary= (*ref)->binary;
+ with_sum_func= (*ref)->with_sum_func;
}
return 0;
}