diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2012-08-10 11:35:33 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2012-08-10 11:36:15 -0400 |
commit | eaccfded98a9c677d3a2e849c1747ec90e8596a6 (patch) | |
tree | c341448f69a2e67484de7a0a43e12848c20eb414 /src/test/regress/expected/window.out | |
parent | b3055ab4fb5839a872bfe354b2b5ac31e6903ed6 (diff) | |
download | postgresql-eaccfded98a9c677d3a2e849c1747ec90e8596a6.tar.gz |
Centralize the logic for detecting misplaced aggregates, window funcs, etc.
Formerly we relied on checking after-the-fact to see if an expression
contained aggregates, window functions, or sub-selects when it shouldn't.
This is grotty, easily forgotten (indeed, we had forgotten to teach
DefineIndex about rejecting window functions), and none too efficient
since it requires extra traversals of the parse tree. To improve matters,
define an enum type that classifies all SQL sub-expressions, store it in
ParseState to show what kind of expression we are currently parsing, and
make transformAggregateCall, transformWindowFuncCall, and transformSubLink
check the expression type and throw error if the type indicates the
construct is disallowed. This allows removal of a large number of ad-hoc
checks scattered around the code base. The enum type is sufficiently
fine-grained that we can still produce error messages of at least the
same specificity as before.
Bringing these error checks together revealed that we'd been none too
consistent about phrasing of the error messages, so standardize the wording
a bit.
Also, rewrite checking of aggregate arguments so that it requires only one
traversal of the arguments, rather than up to three as before.
In passing, clean up some more comments left over from add_missing_from
support, and annotate some tests that I think are dead code now that that's
gone. (I didn't risk actually removing said dead code, though.)
Diffstat (limited to 'src/test/regress/expected/window.out')
-rw-r--r-- | src/test/regress/expected/window.out | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/test/regress/expected/window.out b/src/test/regress/expected/window.out index fde375cc9f..7778626625 100644 --- a/src/test/regress/expected/window.out +++ b/src/test/regress/expected/window.out @@ -958,32 +958,32 @@ SELECT rank() OVER (ORDER BY length('abc')); -- can't order by another window function SELECT rank() OVER (ORDER BY rank() OVER (ORDER BY random())); -ERROR: window functions not allowed in window definition +ERROR: window functions are not allowed in window definitions LINE 1: SELECT rank() OVER (ORDER BY rank() OVER (ORDER BY random())... ^ -- some other errors SELECT * FROM empsalary WHERE row_number() OVER (ORDER BY salary) < 10; -ERROR: window functions not allowed in WHERE clause +ERROR: window functions are not allowed in WHERE LINE 1: SELECT * FROM empsalary WHERE row_number() OVER (ORDER BY sa... ^ SELECT * FROM empsalary INNER JOIN tenk1 ON row_number() OVER (ORDER BY salary) < 10; -ERROR: window functions not allowed in JOIN conditions +ERROR: window functions are not allowed in JOIN conditions LINE 1: SELECT * FROM empsalary INNER JOIN tenk1 ON row_number() OVE... ^ SELECT rank() OVER (ORDER BY 1), count(*) FROM empsalary GROUP BY 1; -ERROR: window functions not allowed in GROUP BY clause +ERROR: window functions are not allowed in GROUP BY LINE 1: SELECT rank() OVER (ORDER BY 1), count(*) FROM empsalary GRO... ^ SELECT * FROM rank() OVER (ORDER BY random()); -ERROR: cannot use window function in function expression in FROM +ERROR: window functions are not allowed in functions in FROM LINE 1: SELECT * FROM rank() OVER (ORDER BY random()); ^ DELETE FROM empsalary WHERE (rank() OVER (ORDER BY random())) > 10; -ERROR: window functions not allowed in WHERE clause +ERROR: window functions are not allowed in WHERE LINE 1: DELETE FROM empsalary WHERE (rank() OVER (ORDER BY random())... ^ DELETE FROM empsalary RETURNING rank() OVER (ORDER BY random()); -ERROR: cannot use window function in RETURNING +ERROR: window functions are not allowed in RETURNING LINE 1: DELETE FROM empsalary RETURNING rank() OVER (ORDER BY random... ^ SELECT count(*) OVER w FROM tenk1 WINDOW w AS (ORDER BY unique1), w AS (ORDER BY unique1); |