Commit 0c4929ff authored by Tom Lane's avatar Tom Lane

Parser no longer considers

SELECT a/2, a/2 FROM test_missing_target GROUP BY a/2;
to be ambiguous ... which I think is correct behavior.
parent 7f76eab1
...@@ -133,7 +133,15 @@ QUERY: SELECT a/2, a/2 FROM test_missing_target ...@@ -133,7 +133,15 @@ QUERY: SELECT a/2, a/2 FROM test_missing_target
QUERY: SELECT a/2, a/2 FROM test_missing_target QUERY: SELECT a/2, a/2 FROM test_missing_target
GROUP BY a/2; GROUP BY a/2;
ERROR: GROUP BY has ambiguous expression ?column?|?column?
--------+--------
0| 0
1| 1
2| 2
3| 3
4| 4
(5 rows)
QUERY: SELECT x.b, count(*) FROM test_missing_target x, test_missing_target y QUERY: SELECT x.b, count(*) FROM test_missing_target x, test_missing_target y
WHERE x.a = y.a WHERE x.a = y.a
GROUP BY x.b; GROUP BY x.b;
...@@ -169,19 +177,14 @@ count ...@@ -169,19 +177,14 @@ count
4 4
(4 rows) (4 rows)
QUERY: SELECT a%2, count(a) FROM test_missing_target GROUP BY test_missing_target.a%2; QUERY: SELECT a%2, count(b) FROM test_missing_target GROUP BY test_missing_target.a%2;
?column?|count ?column?|count
--------+----- --------+-----
0| 5 0| 5
1| 5 1| 5
(2 rows) (2 rows)
QUERY: /* QUERY: SELECT count(c) FROM test_missing_target GROUP BY lower(test_missing_target.c);
NOTE: as of 1998-08-01 a bug was detected unrelated to this feature which
requires the aggragate function argument to be the same as some non-agragate
in the target list. (i.e. count(*) and count(b) crash the backend.)
*/
SELECT count(c) FROM test_missing_target GROUP BY lower(test_missing_target.c);
count count
----- -----
2 2
......
...@@ -53,38 +53,38 @@ SELECT c, count(*) FROM test_missing_target GROUP BY 1; ...@@ -53,38 +53,38 @@ SELECT c, count(*) FROM test_missing_target GROUP BY 1;
-- failure expected -- failure expected
SELECT c, count(*) FROM test_missing_target GROUP BY 3; SELECT c, count(*) FROM test_missing_target GROUP BY 3;
-- group w/o existing GROUP BY and ORDER BY target under ambigious condition -- group w/o existing GROUP BY and ORDER BY target under ambiguous condition
-- failure expected -- failure expected
SELECT count(*) FROM test_missing_target x, test_missing_target y SELECT count(*) FROM test_missing_target x, test_missing_target y
WHERE x.a = y.a WHERE x.a = y.a
GROUP BY b ORDER BY b; GROUP BY b ORDER BY b;
-- order w/ target under ambigious condition -- order w/ target under ambiguous condition
-- failure NOT expected -- failure NOT expected
SELECT a, a FROM test_missing_target SELECT a, a FROM test_missing_target
ORDER BY a; ORDER BY a;
-- order expression w/ target under ambigious condition -- order expression w/ target under ambiguous condition
-- failure NOT expected -- failure NOT expected
SELECT a/2, a/2 FROM test_missing_target SELECT a/2, a/2 FROM test_missing_target
ORDER BY a/2; ORDER BY a/2;
-- group expression w/ target under ambigious condition -- group expression w/ target under ambiguous condition
-- failure expected -- failure NOT expected
SELECT a/2, a/2 FROM test_missing_target SELECT a/2, a/2 FROM test_missing_target
GROUP BY a/2; GROUP BY a/2;
-- group w/ existing GROUP BY target under ambigious condition -- group w/ existing GROUP BY target under ambiguous condition
SELECT x.b, count(*) FROM test_missing_target x, test_missing_target y SELECT x.b, count(*) FROM test_missing_target x, test_missing_target y
WHERE x.a = y.a WHERE x.a = y.a
GROUP BY x.b; GROUP BY x.b;
-- group w/o existing GROUP BY target under ambigious condition -- group w/o existing GROUP BY target under ambiguous condition
SELECT count(*) FROM test_missing_target x, test_missing_target y SELECT count(*) FROM test_missing_target x, test_missing_target y
WHERE x.a = y.a WHERE x.a = y.a
GROUP BY x.b; GROUP BY x.b;
-- group w/o existing GROUP BY target under ambigious condition -- group w/o existing GROUP BY target under ambiguous condition
-- into a table -- into a table
SELECT count(*) INTO TABLE test_missing_target2 SELECT count(*) INTO TABLE test_missing_target2
FROM test_missing_target x, test_missing_target y FROM test_missing_target x, test_missing_target y
...@@ -96,12 +96,7 @@ SELECT * FROM test_missing_target2; ...@@ -96,12 +96,7 @@ SELECT * FROM test_missing_target2;
-- Functions and expressions -- Functions and expressions
-- w/ existing GROUP BY target -- w/ existing GROUP BY target
SELECT a%2, count(a) FROM test_missing_target GROUP BY test_missing_target.a%2; SELECT a%2, count(b) FROM test_missing_target GROUP BY test_missing_target.a%2;
/*
NOTE: as of 1998-08-01 a bug was detected unrelated to this feature which
requires the aggragate function argument to be the same as some non-agragate
in the target list. (i.e. count(*) and count(b) crash the backend.)
*/
-- w/o existing GROUP BY target using a relation name in GROUP BY clause -- w/o existing GROUP BY target using a relation name in GROUP BY clause
SELECT count(c) FROM test_missing_target GROUP BY lower(test_missing_target.c); SELECT count(c) FROM test_missing_target GROUP BY lower(test_missing_target.c);
...@@ -124,23 +119,24 @@ SELECT a FROM test_missing_target ORDER BY upper(d); ...@@ -124,23 +119,24 @@ SELECT a FROM test_missing_target ORDER BY upper(d);
SELECT count(b) FROM test_missing_target SELECT count(b) FROM test_missing_target
GROUP BY (b + 1) / 2 ORDER BY (b + 1) / 2 desc; GROUP BY (b + 1) / 2 ORDER BY (b + 1) / 2 desc;
-- group w/o existing GROUP BY and ORDER BY target under ambigious condition -- group w/o existing GROUP BY and ORDER BY target under ambiguous condition
-- failure expected -- failure expected
SELECT count(x.a) FROM test_missing_target x, test_missing_target y SELECT count(x.a) FROM test_missing_target x, test_missing_target y
WHERE x.a = y.a WHERE x.a = y.a
GROUP BY b/2 ORDER BY b/2; GROUP BY b/2 ORDER BY b/2;
-- group w/ existing GROUP BY target under ambigious condition -- group w/ existing GROUP BY target under ambiguous condition
SELECT x.b/2, count(x.b) FROM test_missing_target x, test_missing_target y SELECT x.b/2, count(x.b) FROM test_missing_target x, test_missing_target y
WHERE x.a = y.a WHERE x.a = y.a
GROUP BY x.b/2; GROUP BY x.b/2;
-- group w/o existing GROUP BY target under ambigious condition -- group w/o existing GROUP BY target under ambiguous condition
-- failure expected due to ambiguous b in count(b)
SELECT count(b) FROM test_missing_target x, test_missing_target y SELECT count(b) FROM test_missing_target x, test_missing_target y
WHERE x.a = y.a WHERE x.a = y.a
GROUP BY x.b/2; GROUP BY x.b/2;
-- group w/o existing GROUP BY target under ambigious condition -- group w/o existing GROUP BY target under ambiguous condition
-- into a table -- into a table
SELECT count(x.b) INTO TABLE test_missing_target3 SELECT count(x.b) INTO TABLE test_missing_target3
FROM test_missing_target x, test_missing_target y FROM test_missing_target x, test_missing_target y
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment