mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-21 05:46:59 +08:00
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
39 lines
1.2 KiB
C
39 lines
1.2 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* analyze.h
|
|
* parse analysis for optimizable statements
|
|
*
|
|
*
|
|
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* src/include/parser/analyze.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef ANALYZE_H
|
|
#define ANALYZE_H
|
|
|
|
#include "parser/parse_node.h"
|
|
|
|
|
|
extern Query *parse_analyze(Node *parseTree, const char *sourceText,
|
|
Oid *paramTypes, int numParams);
|
|
extern Query *parse_analyze_varparams(Node *parseTree, const char *sourceText,
|
|
Oid **paramTypes, int *numParams);
|
|
|
|
extern Query *parse_sub_analyze(Node *parseTree, ParseState *parentParseState,
|
|
CommonTableExpr *parentCTE,
|
|
bool locked_from_parent);
|
|
|
|
extern Query *transformTopLevelStmt(ParseState *pstate, Node *parseTree);
|
|
extern Query *transformStmt(ParseState *pstate, Node *parseTree);
|
|
|
|
extern bool analyze_requires_snapshot(Node *parseTree);
|
|
|
|
extern void CheckSelectLocking(Query *qry);
|
|
extern void applyLockingClause(Query *qry, Index rtindex,
|
|
bool forUpdate, bool noWait, bool pushedDown);
|
|
|
|
#endif /* ANALYZE_H */
|