1997-11-25 17:07:18 -05:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* analyze.h
|
2007-06-23 18:12:52 -04:00
|
|
|
* parse analysis for optimizable statements
|
1997-11-25 17:07:18 -05:00
|
|
|
*
|
|
|
|
|
*
|
2017-01-03 13:48:53 -05:00
|
|
|
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
|
2000-01-26 00:58:53 -05:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1997-11-25 17:07:18 -05:00
|
|
|
*
|
2010-09-20 16:08:53 -04:00
|
|
|
* src/include/parser/analyze.h
|
1997-11-25 17:07:18 -05:00
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
#ifndef ANALYZE_H
|
|
|
|
|
#define ANALYZE_H
|
|
|
|
|
|
1999-07-15 19:04:24 -04:00
|
|
|
#include "parser/parse_node.h"
|
1997-11-25 17:07:18 -05:00
|
|
|
|
2012-03-27 15:14:13 -04:00
|
|
|
/* Hook for plugins to get control at end of parse analysis */
|
|
|
|
|
typedef void (*post_parse_analyze_hook_type) (ParseState *pstate,
|
2012-06-10 15:20:04 -04:00
|
|
|
Query *query);
|
2012-03-27 15:14:13 -04:00
|
|
|
extern PGDLLIMPORT post_parse_analyze_hook_type post_parse_analyze_hook;
|
|
|
|
|
|
2003-04-29 18:13:11 -04:00
|
|
|
|
2007-06-23 18:12:52 -04:00
|
|
|
extern Query *parse_analyze(Node *parseTree, const char *sourceText,
|
2006-10-03 20:30:14 -04:00
|
|
|
Oid *paramTypes, int numParams);
|
2007-06-23 18:12:52 -04:00
|
|
|
extern Query *parse_analyze_varparams(Node *parseTree, const char *sourceText,
|
2006-10-03 20:30:14 -04:00
|
|
|
Oid **paramTypes, int *numParams);
|
2007-03-12 20:33:44 -04:00
|
|
|
|
2009-09-08 23:32:52 -04:00
|
|
|
extern Query *parse_sub_analyze(Node *parseTree, ParseState *parentParseState,
|
2010-02-25 21:01:40 -05:00
|
|
|
CommonTableExpr *parentCTE,
|
|
|
|
|
bool locked_from_parent);
|
Restructure SELECT INTO's parsetree representation into CreateTableAsStmt.
Making this operation look like a utility statement seems generally a good
idea, and particularly so in light of the desire to provide command
triggers for utility statements. The original choice of representing it as
SELECT with an IntoClause appendage had metastasized into rather a lot of
places, unfortunately, so that this patch is a great deal more complicated
than one might at first expect.
In particular, keeping EXPLAIN working for SELECT INTO and CREATE TABLE AS
subcommands required restructuring some EXPLAIN-related APIs. Add-on code
that calls ExplainOnePlan or ExplainOneUtility, or uses
ExplainOneQuery_hook, will need adjustment.
Also, the cases PREPARE ... SELECT INTO and CREATE RULE ... SELECT INTO,
which formerly were accepted though undocumented, are no longer accepted.
The PREPARE case can be replaced with use of CREATE TABLE AS EXECUTE.
The CREATE RULE case doesn't seem to have much real-world use (since the
rule would work only once before failing with "table already exists"),
so we'll not bother with that one.
Both SELECT INTO and CREATE TABLE AS still return a command tag of
"SELECT nnnn". There was some discussion of returning "CREATE TABLE nnnn",
but for the moment backwards compatibility wins the day.
Andres Freund and Tom Lane
2012-03-19 21:37:19 -04:00
|
|
|
|
|
|
|
|
extern Query *transformTopLevelStmt(ParseState *pstate, Node *parseTree);
|
2007-06-23 18:12:52 -04:00
|
|
|
extern Query *transformStmt(ParseState *pstate, Node *parseTree);
|
|
|
|
|
|
2008-12-12 21:00:20 -05:00
|
|
|
extern bool analyze_requires_snapshot(Node *parseTree);
|
|
|
|
|
|
Improve representation of PlanRowMark.
This patch fixes two inadequacies of the PlanRowMark representation.
First, that the original LockingClauseStrength isn't stored (and cannot be
inferred for foreign tables, which always get ROW_MARK_COPY). Since some
PlanRowMarks are created out of whole cloth and don't actually have an
ancestral RowMarkClause, this requires adding a dummy LCS_NONE value to
enum LockingClauseStrength, which is fairly annoying but the alternatives
seem worse. This fix allows getting rid of the use of get_parse_rowmark()
in FDWs (as per the discussion around commits 462bd95705a0c23b and
8ec8760fc87ecde0), and it simplifies some things elsewhere.
Second, that the representation assumed that all child tables in an
inheritance hierarchy would use the same RowMarkType. That's true today
but will soon not be true. We add an "allMarkTypes" field that identifies
the union of mark types used in all a parent table's children, and use
that where appropriate (currently, only in preprocess_targetlist()).
In passing fix a couple of minor infelicities left over from the SKIP
LOCKED patch, notably that _outPlanRowMark still thought waitPolicy
is a bool.
Catversion bump is required because the numeric values of enum
LockingClauseStrength can appear in on-disk rules.
Extracted from a much larger patch to support foreign table inheritance;
it seemed worth breaking this out, since it's a separable concern.
Shigeru Hanada and Etsuro Fujita, somewhat modified by me
2015-03-15 18:41:47 -04:00
|
|
|
extern const char *LCS_asString(LockClauseStrength strength);
|
2013-08-02 12:49:03 -04:00
|
|
|
extern void CheckSelectLocking(Query *qry, LockClauseStrength strength);
|
2006-04-30 14:30:40 -04:00
|
|
|
extern void applyLockingClause(Query *qry, Index rtindex,
|
2014-10-07 16:23:34 -04:00
|
|
|
LockClauseStrength strength,
|
|
|
|
|
LockWaitPolicy waitPolicy, bool pushedDown);
|
2000-12-06 18:55:19 -05:00
|
|
|
|
2001-11-05 12:46:40 -05:00
|
|
|
#endif /* ANALYZE_H */
|