summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorunknown <vva@eagle.mysql.r18.ru>2004-08-13 02:25:50 +0500
committerunknown <vva@eagle.mysql.r18.ru>2004-08-13 02:25:50 +0500
commita88902033a494fc68682645c636c03c789da040b (patch)
tree5376a714034ed1d67fb5d68a1313de944a944994 /mysql-test
parent5ee446d9d0337f7c35ad8cb2b90f0a6aeac20a3c (diff)
parent7e5247aadeeaddc08f0d2c4405095e3c19e3a0a4 (diff)
downloadmariadb-git-a88902033a494fc68682645c636c03c789da040b.tar.gz
Merge eagle.mysql.r18.ru:/home/vva/work/mysql.orig/clear/mysql-4.0
into eagle.mysql.r18.ru:/home/vva/work/BUG_4358/mysql-4.0 sql/sql_select.cc: Auto merged
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/having.result40
-rw-r--r--mysql-test/t/having.test46
2 files changed, 86 insertions, 0 deletions
diff --git a/mysql-test/r/having.result b/mysql-test/r/having.result
index d643070f7f9..f0e9172991c 100644
--- a/mysql-test/r/having.result
+++ b/mysql-test/r/having.result
@@ -78,3 +78,43 @@ sqty
5
9
drop table t1;
+CREATE TABLE t1 (
+`id` bigint(20) NOT NULL default '0',
+`description` text
+) TYPE=MyISAM;
+CREATE TABLE t2 (
+`id` bigint(20) NOT NULL default '0',
+`description` varchar(20)
+) TYPE=MyISAM;
+INSERT INTO t1 VALUES (1, 'test');
+INSERT INTO t2 VALUES (1, 'test');
+CREATE TABLE t3 (
+`id` bigint(20) NOT NULL default '0',
+`order_id` bigint(20) NOT NULL default '0'
+) TYPE=MyISAM;
+select
+a.id, a.description,
+count(b.id) as c
+from t1 a left join t3 b on a.id=b.order_id
+group by a.id, a.description
+having (a.description is not null) and (c=0);
+id description c
+1 test 0
+select
+a.*,
+count(b.id) as c
+from t2 a left join t3 b on a.id=b.order_id
+group by a.id, a.description
+having (a.description is not null) and (c=0);
+id description c
+1 test 0
+INSERT INTO t1 VALUES (2, 'test2');
+select
+a.id, a.description,
+count(b.id) as c
+from t1 a left join t3 b on a.id=b.order_id
+group by a.id, a.description
+having (a.description is not null) and (c=0);
+id description c
+1 test 0
+2 test2 0
diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test
index cb6fa85ffde..c8835bf1613 100644
--- a/mysql-test/t/having.test
+++ b/mysql-test/t/having.test
@@ -66,3 +66,49 @@ select id, sum(qty) as sqty from t1 group by id having sqty>2;
select sum(qty) as sqty from t1 group by id having count(id) > 0;
select sum(qty) as sqty from t1 group by id having count(distinct id) > 0;
drop table t1;
+
+#
+# Test case for Bug #4358 Problem with HAVING clause that uses alias from the
+# select list and TEXT field
+#
+
+CREATE TABLE t1 (
+ `id` bigint(20) NOT NULL default '0',
+ `description` text
+) TYPE=MyISAM;
+
+CREATE TABLE t2 (
+ `id` bigint(20) NOT NULL default '0',
+ `description` varchar(20)
+) TYPE=MyISAM;
+
+INSERT INTO t1 VALUES (1, 'test');
+INSERT INTO t2 VALUES (1, 'test');
+
+CREATE TABLE t3 (
+ `id` bigint(20) NOT NULL default '0',
+ `order_id` bigint(20) NOT NULL default '0'
+) TYPE=MyISAM;
+
+select
+ a.id, a.description,
+ count(b.id) as c
+from t1 a left join t3 b on a.id=b.order_id
+group by a.id, a.description
+having (a.description is not null) and (c=0);
+
+select
+ a.*,
+ count(b.id) as c
+from t2 a left join t3 b on a.id=b.order_id
+group by a.id, a.description
+having (a.description is not null) and (c=0);
+
+INSERT INTO t1 VALUES (2, 'test2');
+
+select
+ a.id, a.description,
+ count(b.id) as c
+from t1 a left join t3 b on a.id=b.order_id
+group by a.id, a.description
+having (a.description is not null) and (c=0);