1997-11-25 22:07:18 +00:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* parse_clause.h
|
2003-03-22 01:49:38 +00:00
|
|
|
* handle clauses in parser
|
1997-11-25 22:07:18 +00:00
|
|
|
*
|
|
|
|
*
|
2013-01-01 17:15:01 -05:00
|
|
|
* Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
|
2000-01-26 05:58:53 +00:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1997-11-25 22:07:18 +00:00
|
|
|
*
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/include/parser/parse_clause.h
|
1997-11-25 22:07:18 +00:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef PARSE_CLAUSE_H
|
|
|
|
#define PARSE_CLAUSE_H
|
|
|
|
|
1999-07-15 23:04:24 +00:00
|
|
|
#include "parser/parse_node.h"
|
1997-11-25 22:07:18 +00:00
|
|
|
|
2001-02-14 21:35:07 +00:00
|
|
|
extern void transformFromClause(ParseState *pstate, List *frmList);
|
2002-03-22 02:56:37 +00:00
|
|
|
extern int setTargetTable(ParseState *pstate, RangeVar *relation,
|
2004-01-14 23:01:55 +00:00
|
|
|
bool inh, bool alsoSource, AclMode requiredPerms);
|
2001-01-05 06:34:23 +00:00
|
|
|
extern bool interpretInhOption(InhOption inhOpt);
|
Clean up the mess around EXPLAIN and materialized views.
Revert the matview-related changes in explain.c's API, as per recent
complaint from Robert Haas. The reason for these appears to have been
principally some ill-considered choices around having intorel_startup do
what ought to be parse-time checking, plus a poor arrangement for passing
it the view parsetree it needs to store into pg_rewrite when creating a
materialized view. Do the latter by having parse analysis stick a copy
into the IntoClause, instead of doing it at runtime. (On the whole,
I seriously question the choice to represent CREATE MATERIALIZED VIEW as a
variant of SELECT INTO/CREATE TABLE AS, because that means injecting even
more complexity into what was already a horrid legacy kluge. However,
I didn't go so far as to rethink that choice ... yet.)
I also moved several error checks into matview parse analysis, and
made the check for external Params in a matview more accurate.
In passing, clean things up a bit more around interpretOidsOption(),
and fix things so that we can use that to force no-oids for views,
sequences, etc, thereby eliminating the need to cons up "oids = false"
options when creating them.
catversion bump due to change in IntoClause. (I wonder though if we
really need readfuncs/outfuncs support for IntoClause anymore.)
2013-04-12 19:25:20 -04:00
|
|
|
extern bool interpretOidsOption(List *defList, bool allowOids);
|
2003-06-16 02:03:38 +00:00
|
|
|
|
2003-07-03 19:07:54 +00:00
|
|
|
extern Node *transformWhereClause(ParseState *pstate, Node *clause,
|
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.)
2012-08-10 11:35:33 -04:00
|
|
|
ParseExprKind exprKind, const char *constructName);
|
2003-07-03 19:07:54 +00:00
|
|
|
extern Node *transformLimitClause(ParseState *pstate, Node *clause,
|
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.)
2012-08-10 11:35:33 -04:00
|
|
|
ParseExprKind exprKind, const char *constructName);
|
1998-09-01 04:40:42 +00:00
|
|
|
extern List *transformGroupClause(ParseState *pstate, List *grouplist,
|
2008-12-28 18:54:01 +00:00
|
|
|
List **targetlist, List *sortClause,
|
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.)
2012-08-10 11:35:33 -04:00
|
|
|
ParseExprKind exprKind, bool useSQL99);
|
1999-08-21 03:49:17 +00:00
|
|
|
extern List *transformSortClause(ParseState *pstate, List *orderlist,
|
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.)
2012-08-10 11:35:33 -04:00
|
|
|
List **targetlist, ParseExprKind exprKind,
|
|
|
|
bool resolveUnknown, bool useSQL99);
|
2008-12-28 18:54:01 +00:00
|
|
|
|
|
|
|
extern List *transformWindowDefinitions(ParseState *pstate,
|
2009-06-11 14:49:15 +00:00
|
|
|
List *windowdefs,
|
|
|
|
List **targetlist);
|
2008-12-28 18:54:01 +00:00
|
|
|
|
2008-08-02 21:32:01 +00:00
|
|
|
extern List *transformDistinctClause(ParseState *pstate,
|
2009-12-15 17:57:48 +00:00
|
|
|
List **targetlist, List *sortClause, bool is_agg);
|
2008-08-02 21:32:01 +00:00
|
|
|
extern List *transformDistinctOnClause(ParseState *pstate, List *distinctlist,
|
2009-06-11 14:49:15 +00:00
|
|
|
List **targetlist, List *sortClause);
|
1999-08-21 03:49:17 +00:00
|
|
|
|
|
|
|
extern Index assignSortGroupRef(TargetEntry *tle, List *tlist);
|
2007-01-09 02:14:16 +00:00
|
|
|
extern bool targetIsInSortList(TargetEntry *tle, Oid sortop, List *sortList);
|
2001-10-28 06:26:15 +00:00
|
|
|
|
2001-11-05 17:46:40 +00:00
|
|
|
#endif /* PARSE_CLAUSE_H */
|