1997-11-25 23:07:18 +01:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* analyze.h
|
2007-06-24 00:12:52 +02:00
|
|
|
* parse analysis for optimizable statements
|
1997-11-25 23:07:18 +01:00
|
|
|
*
|
|
|
|
*
|
2012-01-02 00:01:58 +01:00
|
|
|
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1997-11-25 23:07:18 +01:00
|
|
|
*
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/include/parser/analyze.h
|
1997-11-25 23:07:18 +01:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef ANALYZE_H
|
|
|
|
#define ANALYZE_H
|
|
|
|
|
1999-07-16 01:04:24 +02:00
|
|
|
#include "parser/parse_node.h"
|
1997-11-25 23:07:18 +01:00
|
|
|
|
2012-03-27 21:14:13 +02:00
|
|
|
/* Hook for plugins to get control at end of parse analysis */
|
|
|
|
typedef void (*post_parse_analyze_hook_type) (ParseState *pstate,
|
|
|
|
Query *query);
|
|
|
|
extern PGDLLIMPORT post_parse_analyze_hook_type post_parse_analyze_hook;
|
|
|
|
|
2003-04-30 00:13:11 +02:00
|
|
|
|
2007-06-24 00:12:52 +02:00
|
|
|
extern Query *parse_analyze(Node *parseTree, const char *sourceText,
|
2006-10-04 02:30:14 +02:00
|
|
|
Oid *paramTypes, int numParams);
|
2007-06-24 00:12:52 +02:00
|
|
|
extern Query *parse_analyze_varparams(Node *parseTree, const char *sourceText,
|
2006-10-04 02:30:14 +02:00
|
|
|
Oid **paramTypes, int *numParams);
|
2007-03-13 01:33:44 +01:00
|
|
|
|
2009-09-09 05:32:52 +02:00
|
|
|
extern Query *parse_sub_analyze(Node *parseTree, ParseState *parentParseState,
|
2010-02-26 03:01:40 +01: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-20 02:37:19 +01:00
|
|
|
|
|
|
|
extern Query *transformTopLevelStmt(ParseState *pstate, Node *parseTree);
|
2007-06-24 00:12:52 +02:00
|
|
|
extern Query *transformStmt(ParseState *pstate, Node *parseTree);
|
|
|
|
|
2008-12-13 03:00:20 +01:00
|
|
|
extern bool analyze_requires_snapshot(Node *parseTree);
|
|
|
|
|
2006-04-30 20:30:40 +02:00
|
|
|
extern void CheckSelectLocking(Query *qry);
|
|
|
|
extern void applyLockingClause(Query *qry, Index rtindex,
|
2009-10-28 15:55:47 +01:00
|
|
|
bool forUpdate, bool noWait, bool pushedDown);
|
2000-12-07 00:55:19 +01:00
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* ANALYZE_H */
|