git.postgresql.org Git - postgresql.git/commit

git projects / postgresql.git / commit
? search:
summary | shortlog | log | commit | commitdiff | tree
(parent: b3055ab) | patch
Centralize the logic for detecting misplaced aggregates, window funcs, etc.
2012年8月10日 15:35:33 +0000 (11:35 -0400)
2012年8月10日 15:36:15 +0000 (11:36 -0400)
commit eaccfded98a9c677d3a2e849c1747ec90e8596a6
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.)
29 files changed:
src/backend/catalog/heap.c diff | blob | blame | history
src/backend/commands/functioncmds.c diff | blob | blame | history
src/backend/commands/indexcmds.c diff | blob | blame | history
src/backend/commands/prepare.c diff | blob | blame | history
src/backend/commands/tablecmds.c diff | blob | blame | history
src/backend/commands/trigger.c diff | blob | blame | history
src/backend/commands/typecmds.c diff | blob | blame | history
src/backend/optimizer/util/clauses.c diff | blob | blame | history
src/backend/optimizer/util/var.c diff | blob | blame | history
src/backend/parser/analyze.c diff | blob | blame | history
src/backend/parser/parse_agg.c diff | blob | blame | history
src/backend/parser/parse_clause.c diff | blob | blame | history
src/backend/parser/parse_expr.c diff | blob | blame | history
src/backend/parser/parse_node.c diff | blob | blame | history
src/backend/parser/parse_target.c diff | blob | blame | history
src/backend/parser/parse_utilcmd.c diff | blob | blame | history
src/backend/rewrite/rewriteManip.c diff | blob | blame | history
src/include/optimizer/var.h diff | blob | blame | history
src/include/parser/parse_agg.h diff | blob | blame | history
src/include/parser/parse_clause.h diff | blob | blame | history
src/include/parser/parse_expr.h diff | blob | blame | history
src/include/parser/parse_node.h diff | blob | blame | history
src/include/parser/parse_target.h diff | blob | blame | history
src/include/rewrite/rewriteManip.h diff | blob | blame | history
src/test/regress/expected/aggregates.out diff | blob | blame | history
src/test/regress/expected/join.out diff | blob | blame | history
src/test/regress/expected/window.out diff | blob | blame | history
src/test/regress/expected/with.out diff | blob | blame | history
src/test/regress/sql/aggregates.sql diff | blob | blame | history
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /