summaryrefslogtreecommitdiff
path: root/mysql-test/r/group_by.result
diff options
context:
space:
mode:
authorunknown <mhansson/martin@linux-st28.site>2008-01-11 18:50:54 +0100
committerunknown <mhansson/martin@linux-st28.site>2008-01-11 18:50:54 +0100
commitdf8e9fc234234958ee0cb6195b724657b2cd128c (patch)
tree608f9c994a905ae94f78085e3eee34d8a81a5815 /mysql-test/r/group_by.result
parent62a7e160bc0e960ec1374a546dde4a7f26120ceb (diff)
downloadmariadb-git-df8e9fc234234958ee0cb6195b724657b2cd128c.tar.gz
Bug#31797: error while parsing subqueries -- WHERE is parsed as HAVING
The name resolution for correlated subqueries and HAVING clauses failed to distinguish which of two was being performed when there was a reference to an outer aliased field. Fixed by adding the condition that HAVING clause name resulotion is being performed. mysql-test/r/group_by.result: Bug#31797: Test result mysql-test/t/group_by.test: Bug#31797: Test case sql/item.cc: Bug#31797: Corrected function comment. The fix, raising the error is restricted to HAVING name resolution.
Diffstat (limited to 'mysql-test/r/group_by.result')
-rw-r--r--mysql-test/r/group_by.result36
1 files changed, 36 insertions, 0 deletions
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result
index 053c2901509..97c550fcab4 100644
--- a/mysql-test/r/group_by.result
+++ b/mysql-test/r/group_by.result
@@ -1113,3 +1113,39 @@ c b
3 1
3 2
DROP TABLE t1;
+CREATE TABLE t1 ( a INT, b INT );
+SELECT b c, (SELECT a FROM t1 WHERE b = c)
+FROM t1;
+c (SELECT a FROM t1 WHERE b = c)
+SELECT b c, (SELECT a FROM t1 WHERE b = c)
+FROM t1
+HAVING b = 10;
+c (SELECT a FROM t1 WHERE b = c)
+SELECT MAX(b) c, (SELECT a FROM t1 WHERE b = c)
+FROM t1
+HAVING b = 10;
+ERROR 42S22: Reference 'c' not supported (reference to group function)
+SET @old_sql_mode = @@sql_mode;
+SET @@sql_mode='ONLY_FULL_GROUP_BY';
+SELECT b c, (SELECT a FROM t1 WHERE b = c)
+FROM t1;
+c (SELECT a FROM t1 WHERE b = c)
+SELECT b c, (SELECT a FROM t1 WHERE b = c)
+FROM t1
+HAVING b = 10;
+ERROR 42000: non-grouping field 'b' is used in HAVING clause
+SELECT MAX(b) c, (SELECT a FROM t1 WHERE b = c)
+FROM t1
+HAVING b = 10;
+ERROR 42S22: Reference 'c' not supported (reference to group function)
+INSERT INTO t1 VALUES (1, 1);
+SELECT b c, (SELECT a FROM t1 WHERE b = c)
+FROM t1;
+c (SELECT a FROM t1 WHERE b = c)
+1 1
+INSERT INTO t1 VALUES (2, 1);
+SELECT b c, (SELECT a FROM t1 WHERE b = c)
+FROM t1;
+ERROR 21000: Subquery returns more than 1 row
+DROP TABLE t1;
+SET @@sql_mode = @old_sql_mode;