summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/group_by.result21
-rw-r--r--mysql-test/r/information_schema.result5
-rw-r--r--mysql-test/t/group_by.test23
-rw-r--r--mysql-test/t/information_schema.test11
4 files changed, 60 insertions, 0 deletions
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result
index a56cfd4492a..7cbd8c7d095 100644
--- a/mysql-test/r/group_by.result
+++ b/mysql-test/r/group_by.result
@@ -723,6 +723,27 @@ WHERE hostname LIKE '%aol%'
hostname no
cache-dtc-af05.proxy.aol.com 1
DROP TABLE t1;
+create table t1 (c1 char(3), c2 char(3));
+create table t2 (c3 char(3), c4 char(3));
+insert into t1 values ('aaa', 'bb1'), ('aaa', 'bb2');
+insert into t2 values ('aaa', 'bb1'), ('aaa', 'bb2');
+select t1.c1 as c2 from t1, t2 where t1.c2 = t2.c4
+group by c2;
+c2
+aaa
+aaa
+Warnings:
+Warning 1052 Column 'c2' in group statement is ambiguous
+show warnings;
+Level Code Message
+Warning 1052 Column 'c2' in group statement is ambiguous
+select t1.c1 as c2 from t1, t2 where t1.c2 = t2.c4
+group by t1.c1;
+c2
+aaa
+show warnings;
+Level Code Message
+drop table t1, t2;
CREATE TABLE t1 (a int, b int);
INSERT INTO t1 VALUES (1,2), (1,3);
SELECT a, b FROM t1 GROUP BY 'const';
diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result
index c6090bc663d..908082afd65 100644
--- a/mysql-test/r/information_schema.result
+++ b/mysql-test/r/information_schema.result
@@ -227,6 +227,9 @@ latin1_bin latin1
latin1_general_ci latin1
latin1_general_cs latin1
latin1_spanish_ci latin1
+drop procedure if exists sel2;
+drop function if exists sub1;
+drop function if exists sub2;
create function sub1(i int) returns int
return i+1;
create procedure sel2()
@@ -823,6 +826,8 @@ GRANT SELECT ON *.* TO 'user4'@'localhost'
drop user user1@localhost, user2@localhost, user3@localhost, user4@localhost;
use test;
drop database mysqltest;
+drop procedure if exists p1;
+drop procedure if exists p2;
create procedure p1 () modifies sql data set @a = 5;
create procedure p2 () set @a = 5;
select sql_data_access from information_schema.routines
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test
index 9f920a1dd83..5d84098a84a 100644
--- a/mysql-test/t/group_by.test
+++ b/mysql-test/t/group_by.test
@@ -543,6 +543,29 @@ SELECT hostname, COUNT(DISTINCT user_id) as no FROM t1
DROP TABLE t1;
#
+# Bug#11211: Ambiguous column reference in GROUP BY.
+#
+
+create table t1 (c1 char(3), c2 char(3));
+create table t2 (c3 char(3), c4 char(3));
+insert into t1 values ('aaa', 'bb1'), ('aaa', 'bb2');
+insert into t2 values ('aaa', 'bb1'), ('aaa', 'bb2');
+
+# query with ambiguous column reference 'c2'
+--disable_ps_protocol
+select t1.c1 as c2 from t1, t2 where t1.c2 = t2.c4
+group by c2;
+show warnings;
+--enable_ps_protocol
+
+# this query has no ambiguity
+select t1.c1 as c2 from t1, t2 where t1.c2 = t2.c4
+group by t1.c1;
+
+show warnings;
+drop table t1, t2;
+
+#
# Test for bug #8614: GROUP BY 'const' with DISTINCT
#
diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test
index e03bea5899a..15785a067df 100644
--- a/mysql-test/t/information_schema.test
+++ b/mysql-test/t/information_schema.test
@@ -101,6 +101,12 @@ where COLLATION_NAME like 'latin1%';
# Test for information_schema.ROUTINES &
#
+--disable_warnings
+drop procedure if exists sel2;
+drop function if exists sub1;
+drop function if exists sub2;
+--enable_warnings
+
create function sub1(i int) returns int
return i+1;
delimiter |;
@@ -546,6 +552,11 @@ drop database mysqltest;
#
# Bug #11055 information_schema: routines.sql_data_access has wrong value
#
+--disable_warnings
+drop procedure if exists p1;
+drop procedure if exists p2;
+--enable_warnings
+
create procedure p1 () modifies sql data set @a = 5;
create procedure p2 () set @a = 5;
select sql_data_access from information_schema.routines