* definitions for parse tree nodes
*
*
- * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.319 2006/07/31 01:16:38 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.371 2008/08/07 01:11:51 tgl Exp $
*
*-------------------------------------------------------------------------
*/
typedef enum QuerySource
{
QSRC_ORIGINAL, /* original parsetree (explicit query) */
- QSRC_PARSER, /* added by parse analysis */
+ QSRC_PARSER, /* added by parse analysis (now unused) */
QSRC_INSTEAD_RULE, /* added by unconditional INSTEAD rule */
QSRC_QUAL_INSTEAD_RULE, /* added by conditional INSTEAD rule */
QSRC_NON_INSTEAD_RULE /* added by non-INSTEAD rule */
} QuerySource;
-/* What to do at commit time for temporary relations */
-typedef enum OnCommitAction
+/* Sort ordering options for ORDER BY and CREATE INDEX */
+typedef enum SortByDir
{
- ONCOMMIT_NOOP, /* No ON COMMIT clause (do nothing) */
- ONCOMMIT_PRESERVE_ROWS, /* ON COMMIT PRESERVE ROWS (do nothing) */
- ONCOMMIT_DELETE_ROWS, /* ON COMMIT DELETE ROWS */
- ONCOMMIT_DROP /* ON COMMIT DROP */
-} OnCommitAction;
+ SORTBY_DEFAULT,
+ SORTBY_ASC,
+ SORTBY_DESC,
+ SORTBY_USING /* not allowed in CREATE INDEX ... */
+} SortByDir;
+
+typedef enum SortByNulls
+{
+ SORTBY_NULLS_DEFAULT,
+ SORTBY_NULLS_FIRST,
+ SORTBY_NULLS_LAST
+} SortByNulls;
/*
#define ACL_SELECT (1<<1)
#define ACL_UPDATE (1<<2)
#define ACL_DELETE (1<<3)
-#define ACL_RULE (1<<4)
+/* #define ACL_RULE (1<<4) unused, available */
#define ACL_REFERENCES (1<<5)
#define ACL_TRIGGER (1<<6)
#define ACL_EXECUTE (1<<7) /* for functions */
#define ACL_USAGE (1<<8) /* for languages and namespaces */
#define ACL_CREATE (1<<9) /* for namespaces and databases */
#define ACL_CREATE_TEMP (1<<10) /* for databases */
-#define ACL_CONNECT (1<<11) /* for databases */
+#define ACL_CONNECT (1<<11) /* for databases */
#define N_ACL_RIGHTS 12 /* 1 plus the last 1<<x */
#define ACL_NO_RIGHTS 0
/* Currently, SELECT ... FOR UPDATE/FOR SHARE requires UPDATE privileges */
/*
* Query -
- * all statements are turned into a Query tree (via transformStmt)
- * for further processing by the optimizer
+ * Parse analysis turns all statements into a Query tree (via transformStmt)
+ * for further processing by the rewriter and planner.
*
- * utility statements (i.e. non-optimizable statements) have the
+ * Utility statements (i.e. non-optimizable statements) have the
* utilityStmt field set, and the Query itself is mostly dummy.
+ * DECLARE CURSOR is a special case: it is represented like a SELECT,
+ * but the original DeclareCursorStmt is stored in utilityStmt.
+ *
+ * Planning converts a Query tree into a Plan tree headed by a PlannedStmt
+ * node --- the Query structure is not used by the executor.
*/
typedef struct Query
{
bool canSetTag; /* do I set the command result tag? */
- Node *utilityStmt; /* non-null if this is a non-optimizable
- * statement */
+ Node *utilityStmt; /* non-null if this is DECLARE CURSOR or a
+ * non-optimizable statement */
- int resultRelation; /* target relation (index into rtable) */
+ int resultRelation; /* rtable index of target relation for
+ * INSERT/UPDATE/DELETE; 0 for SELECT */
- RangeVar *into; /* target relation for SELECT INTO */
- List *intoOptions; /* options from WITH clause */
- OnCommitAction intoOnCommit; /* what do we do at COMMIT? */
- char *intoTableSpaceName; /* table space to use, or NULL */
+ IntoClause *intoClause; /* target for SELECT INTO / CREATE TABLE AS */
bool hasAggs; /* has aggregates in tlist or havingQual */
bool hasSubLinks; /* has subquery SubLink */
+ bool hasDistinctOn; /* distinctClause is from DISTINCT ON */
List *rtable; /* list of range table entries */
FromExpr *jointree; /* table join tree (FROM and WHERE clauses) */
List *targetList; /* target list (of TargetEntry) */
- List *groupClause; /* a list of GroupClause's */
+ List *returningList; /* return-values list (of TargetEntry) */
+
+ List *groupClause; /* a list of SortGroupClause's */
Node *havingQual; /* qualifications applied to groups */
- List *distinctClause; /* a list of SortClause's */
+ List *distinctClause; /* a list of SortGroupClause's */
- List *sortClause; /* a list of SortClause's */
+ List *sortClause; /* a list of SortGroupClause's */
Node *limitOffset; /* # of result tuples to skip (int8 expr) */
Node *limitCount; /* # of result tuples to return (int8 expr) */
Node *setOperations; /* set-operation tree if this is top level of
* a UNION/INTERSECT/EXCEPT query */
-
- /*
- * If the resultRelation turns out to be the parent of an inheritance
- * tree, the planner will add all the child tables to the rtable and store
- * a list of the rtindexes of all the result relations here. This is done
- * at plan time, not parse time, since we don't want to commit to the
- * exact set of child tables at parse time. This field ought to go in
- * some sort of TopPlan plan node, not in the Query.
- */
- List *resultRelations; /* integer list of RT indexes, or NIL */
} Query;
* For TypeName structures generated internally, it is often easier to
* specify the type by OID than by name. If "names" is NIL then the
* actual type OID is given by typeid, otherwise typeid is unused.
+ * Similarly, if "typmods" is NIL then the actual typmod is expected to
+ * be prespecified in typemod, otherwise typemod is unused.
*
* If pct_type is TRUE, then names is actually a field name and we look up
* the type of that field. Otherwise (the normal case), names is a type
NodeTag type;
List *names; /* qualified name (list of Value strings) */
Oid typeid; /* type identified by OID */
- bool timezone; /* timezone specified? */
bool setof; /* is a set? */
bool pct_type; /* %TYPE specified? */
- int32 typmod; /* type modifier */
+ List *typmods; /* type modifier expression(s) */
+ int32 typemod; /* prespecified type modifier */
List *arrayBounds; /* array bounds */
int location; /* token location, or -1 if unknown */
} TypeName;
} A_Expr;
/*
- * A_Const - a constant expression
+ * A_Const - a literal constant
*/
typedef struct A_Const
{
NodeTag type;
- Value val; /* the value (with the tag) */
- TypeName *typename; /* typecast, or NULL if none */
+ Value val; /* value (includes type info, see value.h) */
} A_Const;
/*
* TypeCast - a CAST expression
- *
- * NOTE: for mostly historical reasons, A_Const parsenodes contain
- * room for a TypeName; we only generate a separate TypeCast node if the
- * argument to be casted is not a constant. In theory either representation
- * would work, but the combined representation saves a bit of code in many
- * productions in gram.y.
*/
typedef struct TypeCast
{
List *args; /* the arguments (list of exprs) */
bool agg_star; /* argument was really '*' */
bool agg_distinct; /* arguments were labeled DISTINCT */
+ bool func_variadic; /* last argument was labeled VARIADIC */
int location; /* token location, or -1 if unknown */
} FuncCall;
List *indirection; /* subscripts and/or field names */
} A_Indirection;
+/*
+ * A_ArrayExpr - an ARRAY[] construct
+ */
+typedef struct A_ArrayExpr
+{
+ NodeTag type;
+ List *elements; /* array element expressions */
+} A_ArrayExpr;
+
/*
* ResTarget -
* result target (used in target list of pre-transformed parse trees)
*
- * In a SELECT or INSERT target list, 'name' is the column label from an
+ * In a SELECT target list, 'name' is the column label from an
* 'AS ColumnLabel' clause, or NULL if there was none, and 'val' is the
* value expression itself. The 'indirection' field is not used.
*
- * INSERT has a second ResTarget list which is the target-column-names list.
- * Here, 'val' is not used, 'name' is the name of the destination column,
- * and 'indirection' stores any subscripts attached to the destination.
+ * INSERT uses ResTarget in its target-column-names list. Here, 'name' is
+ * the name of the destination column, 'indirection' stores any subscripts
+ * attached to the destination, and 'val' is not used.
*
* In an UPDATE target list, 'name' is the name of the destination column,
* 'indirection' stores any subscripts attached to the destination, and
/*
* SortBy - for ORDER BY clause
*/
-#define SORTBY_ASC 1
-#define SORTBY_DESC 2
-#define SORTBY_USING 3
-
typedef struct SortBy
{
NodeTag type;
- int sortby_kind; /* see codes above */
+ SortByDir sortby_dir; /* ASC/DESC/USING */
+ SortByNulls sortby_nulls; /* NULLS FIRST/LAST */
List *useOp; /* name of op to use, if SORTBY_USING */
Node *node; /* expression to sort on */
} SortBy;
NodeTag type;
Node *funccallnode; /* untransformed function call tree */
Alias *alias; /* table alias & optional column aliases */
- List *coldeflist; /* list of ColumnDef nodes to describe
- * result of function returning RECORD */
+ List *coldeflist; /* list of ColumnDef nodes to describe result
+ * of function returning RECORD */
} RangeFunction;
/*
* parsetree produced by gram.y, but transformCreateStmt will remove
* the item and set raw_default instead. CONSTR_DEFAULT items
* should not appear in any subsequent processing.
- *
- * The "support" field, if not null, denotes a supporting relation that
- * should be linked by an internal dependency to the column. Currently
- * this is only used to link a SERIAL column's sequence to the column.
*/
typedef struct ColumnDef
{
Node *raw_default; /* default value (untransformed parse tree) */
char *cooked_default; /* nodeToString representation */
List *constraints; /* other constraints on column */
- RangeVar *support; /* supporting relation, if any */
} ColumnDef;
/*
{
NodeTag type;
RangeVar *relation;
- List *options;
+ List *options; /* integer List of CreateStmtLikeOption */
} InhRelation;
+typedef enum CreateStmtLikeOption
+{
+ CREATE_TABLE_LIKE_INCLUDING_DEFAULTS,
+ CREATE_TABLE_LIKE_EXCLUDING_DEFAULTS,
+ CREATE_TABLE_LIKE_INCLUDING_CONSTRAINTS,
+ CREATE_TABLE_LIKE_EXCLUDING_CONSTRAINTS,
+ CREATE_TABLE_LIKE_INCLUDING_INDEXES,
+ CREATE_TABLE_LIKE_EXCLUDING_INDEXES
+} CreateStmtLikeOption;
+
/*
* IndexElem - index parameters (used in CREATE INDEX)
*
char *name; /* name of attribute to index, or NULL */
Node *expr; /* expression to index, or NULL */
List *opclass; /* name of desired opclass; NIL = default */
+ SortByDir ordering; /* ASC/DESC/default */
+ SortByNulls nulls_ordering; /* FIRST/LAST/default */
} IndexElem;
/*
bool noWait; /* NOWAIT option */
} LockingClause;
+/*
+ * XMLSERIALIZE
+ */
+typedef struct XmlSerialize
+{
+ NodeTag type;
+ XmlOptionType xmloption;
+ Node *expr;
+ TypeName *typename;
+} XmlSerialize;
+
/****************************************************************************
* Nodes for a Query tree
RTE_SUBQUERY, /* subquery in FROM */
RTE_JOIN, /* join */
RTE_SPECIAL, /* special rule relation (NEW or OLD) */
- RTE_FUNCTION /* function in FROM */
+ RTE_FUNCTION, /* function in FROM */
+ RTE_VALUES /* VALUES (<exprlist>), (<exprlist>), ... */
} RTEKind;
typedef struct RangeTblEntry
*/
Node *funcexpr; /* expression tree for func call */
List *funccoltypes; /* OID list of column type OIDs */
- List *funccoltypmods; /* integer list of column typmods */
+ List *funccoltypmods; /* integer list of column typmods */
+
+ /*
+ * Fields valid for a values RTE (else NIL):
+ */
+ List *values_lists; /* list of expression lists */
/*
* Fields valid for a join RTE (else NULL/zero):
} RangeTblEntry;
/*
- * SortClause -
- * representation of ORDER BY clauses
+ * SortGroupClause -
+ * representation of ORDER BY, GROUP BY, DISTINCT, DISTINCT ON items
+ *
+ * You might think that ORDER BY is only interested in defining ordering,
+ * and GROUP/DISTINCT are only interested in defining equality. However,
+ * one way to implement grouping is to sort and then apply a "uniq"-like
+ * filter. So it's also interesting to keep track of possible sort operators
+ * for GROUP/DISTINCT, and in particular to try to sort for the grouping
+ * in a way that will also yield a requested ORDER BY ordering. So we need
+ * to be able to compare ORDER BY and GROUP/DISTINCT lists, which motivates
+ * the decision to give them the same representation.
*
* tleSortGroupRef must match ressortgroupref of exactly one entry of the
- * associated targetlist; that is the expression to be sorted (or grouped) by.
- * sortop is the OID of the ordering operator.
+ * query's targetlist; that is the expression to be sorted or grouped by.
+ * eqop is the OID of the equality operator.
+ * sortop is the OID of the ordering operator (a "<" or ">" operator),
+ * or InvalidOid if not available.
+ * nulls_first means about what you'd expect. If sortop is InvalidOid
+ * then nulls_first is meaningless and should be set to false.
+ *
+ * In an ORDER BY item, all fields must be valid. (The eqop isn't essential
+ * here, but it's cheap to get it along with the sortop, and requiring it
+ * to be valid eases comparisons to grouping items.)
*
- * SortClauses are also used to identify targets that we will do a "Unique"
- * filter step on (for SELECT DISTINCT and SELECT DISTINCT ON). The
- * distinctClause list is simply a copy of the relevant members of the
- * sortClause list. Note that distinctClause can be a subset of sortClause,
- * but cannot have members not present in sortClause; and the members that
- * do appear must be in the same order as in sortClause.
+ * In a grouping item, eqop must be valid. If the eqop is a btree equality
+ * operator, then sortop should be set to a compatible ordering operator.
+ * We prefer to set eqop/sortop/nulls_first to match any ORDER BY item that
+ * the query presents for the same tlist item. If there is none, we just
+ * use the default ordering op for the datatype.
+ *
+ * If the tlist item's type has a hash opclass but no btree opclass, then
+ * we will set eqop to the hash equality operator, sortop to InvalidOid,
+ * and nulls_first to false. A grouping item of this kind can only be
+ * implemented by hashing, and of course it'll never match an ORDER BY item.
+ *
+ * A query might have both ORDER BY and DISTINCT (or DISTINCT ON) clauses.
+ * In SELECT DISTINCT, the distinctClause list is as long or longer than the
+ * sortClause list, while in SELECT DISTINCT ON it's typically shorter.
+ * The two lists must match up to the end of the shorter one --- the parser
+ * rearranges the distinctClause if necessary to make this true. (This
+ * restriction ensures that only one sort step is needed to both satisfy the
+ * ORDER BY and set up for the Unique step. This is semantically necessary
+ * for DISTINCT ON, and presents no real drawback for DISTINCT.)
*/
-typedef struct SortClause
+typedef struct SortGroupClause
{
NodeTag type;
Index tleSortGroupRef; /* reference into targetlist */
- Oid sortop; /* the sort operator to use */
-} SortClause;
-
-/*
- * GroupClause -
- * representation of GROUP BY clauses
- *
- * GroupClause is exactly like SortClause except for the nodetag value
- * (it's probably not even really necessary to have two different
- * nodetags...). We have routines that operate interchangeably on both.
- */
-typedef SortClause GroupClause;
+ Oid eqop; /* the equality operator ('=' op) */
+ Oid sortop; /* the ordering operator ('<' op), or 0 */
+ bool nulls_first; /* do NULLs come before normal values? */
+} SortGroupClause;
/*
* RowMarkClause -
/* ----------------------
* Insert Statement
+ *
+ * The source expression is represented by SelectStmt for both the
+ * SELECT and VALUES cases. If selectStmt is NULL, then the query
+ * is INSERT ... DEFAULT VALUES.
* ----------------------
*/
typedef struct InsertStmt
NodeTag type;
RangeVar *relation; /* relation to insert into */
List *cols; /* optional: names of the target columns */
-
- /*
- * An INSERT statement has *either* VALUES or SELECT, never both. If
- * VALUES, a targetList is supplied (empty for DEFAULT VALUES). If SELECT,
- * a complete SelectStmt (or set-operation tree) is supplied.
- */
- List *targetList; /* the target list (of ResTarget) */
- Node *selectStmt; /* the source SELECT */
+ Node *selectStmt; /* the source SELECT/VALUES, or NULL */
+ List *returningList; /* list of expressions to return */
} InsertStmt;
/* ----------------------
{
NodeTag type;
RangeVar *relation; /* relation to delete from */
- Node *whereClause; /* qualifications */
List *usingClause; /* optional using clause for more tables */
+ Node *whereClause; /* qualifications */
+ List *returningList; /* list of expressions to return */
} DeleteStmt;
/* ----------------------
List *targetList; /* the target list (of ResTarget) */
Node *whereClause; /* qualifications */
List *fromClause; /* optional from clause for more tables */
+ List *returningList; /* list of expressions to return */
} UpdateStmt;
/* ----------------------
* Select Statement
*
* A "simple" SELECT is represented in the output of gram.y by a single
- * SelectStmt node. A SELECT construct containing set operators (UNION,
- * INTERSECT, EXCEPT) is represented by a tree of SelectStmt nodes, in
- * which the leaf nodes are component SELECTs and the internal nodes
+ * SelectStmt node; so is a VALUES construct. A query containing set
+ * operators (UNION, INTERSECT, EXCEPT) is represented by a tree of SelectStmt
+ * nodes, in which the leaf nodes are component SELECTs and the internal nodes
* represent UNION, INTERSECT, or EXCEPT operators. Using the same node
* type for both leaf and internal nodes allows gram.y to stick ORDER BY,
* LIMIT, etc, clause values into a SELECT statement without worrying
/*
* These fields are used only in "leaf" SelectStmts.
- *
- * into, intoColNames, intoOptions, intoOnCommit, and
- * intoTableSpaceName are a kluge; they belong somewhere else...
*/
List *distinctClause; /* NULL, list of DISTINCT ON exprs, or
* lcons(NIL,NIL) for all (SELECT DISTINCT) */
- RangeVar *into; /* target table (for select into table) */
- List *intoColNames; /* column names for into table */
- List *intoOptions; /* options from WITH clause */
- OnCommitAction intoOnCommit; /* what do we do at COMMIT? */
- char *intoTableSpaceName; /* table space to use, or NULL */
+ IntoClause *intoClause; /* target for SELECT INTO / CREATE TABLE AS */
List *targetList; /* the target list (of ResTarget) */
List *fromClause; /* the FROM clause */
Node *whereClause; /* WHERE qualification */
List *groupClause; /* GROUP BY clauses */
Node *havingClause; /* HAVING conditional-expression */
+ /*
+ * In a "leaf" node representing a VALUES list, the above fields are all
+ * null, and instead this field is set. Note that the elements of the
+ * sublists are just expressions, without ResTarget decoration. Also note
+ * that a list element can be DEFAULT (represented as a SetToDefault
+ * node), regardless of the context of the VALUES list. It's up to parse
+ * analysis to reject that where not valid.
+ */
+ List *valuesLists; /* untransformed list of expression lists */
+
/*
* These fields are used in both "leaf" SelectStmts and upper-level
* SelectStmts.
* top-level Query node containing the leaf SELECTs as subqueries in its
* range table. Its setOperations field shows the tree of set operations,
* with leaf SelectStmt nodes replaced by RangeTblRef nodes, and internal
- * nodes replaced by SetOperationStmt nodes.
+ * nodes replaced by SetOperationStmt nodes. Information about the output
+ * column types is added, too. (Note that the child nodes do not necessarily
+ * produce these types directly, but we've checked that their output types
+ * can be coerced to the output column type.) Also, if it's not UNION ALL,
+ * information about the types' sort/group semantics is provided in the form
+ * of a SortGroupClause list (same representation as, eg, DISTINCT).
* ----------------------
*/
typedef struct SetOperationStmt
/* Eventually add fields for CORRESPONDING spec here */
/* Fields derived during parse analysis: */
- List *colTypes; /* list of OIDs of output column types */
+ List *colTypes; /* OID list of output column type OIDs */
+ List *colTypmods; /* integer list of output column typmods */
+ List *groupClauses; /* a list of SortGroupClause's */
+ /* groupClauses is NIL if UNION ALL, but must be set otherwise */
} SetOperationStmt;
/*****************************************************************************
* Other Statements (no optimizations required)
*
- * Some of them require a little bit of transformation (which is also
- * done by transformStmt). The whole structure is then passed on to
- * ProcessUtility (by-passing the optimization step) as the utilityStmt
- * field in Query.
+ * These are not touched by parser/analyze.c except to put them into
+ * the utilityStmt field of a Query. This is eventually passed to
+ * ProcessUtility (by-passing rewriting and planning). Some of the
+ * statements do need attention from parse analysis, and this is
+ * done by routines in parser/parse_utilcmd.c after ProcessUtility
+ * receives the command for execution.
*****************************************************************************/
/*
OBJECT_LARGEOBJECT,
OBJECT_OPCLASS,
OBJECT_OPERATOR,
+ OBJECT_OPFAMILY,
OBJECT_ROLE,
OBJECT_RULE,
OBJECT_SCHEMA,
OBJECT_TABLE,
OBJECT_TABLESPACE,
OBJECT_TRIGGER,
+ OBJECT_TSCONFIGURATION,
+ OBJECT_TSDICTIONARY,
+ OBJECT_TSPARSER,
+ OBJECT_TSTEMPLATE,
OBJECT_TYPE,
OBJECT_VIEW
} ObjectType;
AT_AddIndex, /* add index */
AT_ReAddIndex, /* internal to commands/tablecmds.c */
AT_AddConstraint, /* add constraint */
+ AT_AddConstraintRecurse, /* internal to commands/tablecmds.c */
AT_ProcessedConstraint, /* pre-processed add constraint (local in
- * parser/analyze.c) */
+ * parser/parse_utilcmd.c) */
AT_DropConstraint, /* drop constraint */
- AT_DropConstraintQuietly, /* drop constraint, no error/warning (local in
- * commands/tablecmds.c) */
+ AT_DropConstraintRecurse, /* internal to commands/tablecmds.c */
AT_AlterColumnType, /* alter column type */
AT_ChangeOwner, /* change owner */
AT_ClusterOn, /* CLUSTER ON */
AT_SetRelOptions, /* SET (...) -- AM specific parameters */
AT_ResetRelOptions, /* RESET (...) -- AM specific parameters */
AT_EnableTrig, /* ENABLE TRIGGER name */
+ AT_EnableAlwaysTrig, /* ENABLE ALWAYS TRIGGER name */
+ AT_EnableReplicaTrig, /* ENABLE REPLICA TRIGGER name */
AT_DisableTrig, /* DISABLE TRIGGER name */
AT_EnableTrigAll, /* ENABLE TRIGGER ALL */
AT_DisableTrigAll, /* DISABLE TRIGGER ALL */
AT_EnableTrigUser, /* ENABLE TRIGGER USER */
AT_DisableTrigUser, /* DISABLE TRIGGER USER */
- AT_AddInherits, /* ADD INHERITS parent */
- AT_DropInherits /* DROP INHERITS parent */
+ AT_EnableRule, /* ENABLE RULE name */
+ AT_EnableAlwaysRule, /* ENABLE ALWAYS RULE name */
+ AT_EnableReplicaRule, /* ENABLE REPLICA RULE name */
+ AT_DisableRule, /* DISABLE RULE name */
+ AT_AddInherit, /* INHERIT parent */
+ AT_DropInherit /* NO INHERIT parent */
} AlterTableType;
typedef struct AlterTableCmd /* one subcommand of an ALTER TABLE */
AlterTableType subtype; /* Type of table alteration to apply */
char *name; /* column, constraint, or trigger to act on,
* or new owner or tablespace */
- RangeVar *parent; /* Parent table for add/drop inherits */
Node *def; /* definition of new column, column type,
- * index, or constraint */
+ * index, constraint, or parent table */
Node *transform; /* transformation expr for ALTER TYPE */
DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */
} AlterTableCmd;
/* ----------------------
* Copy Statement
+ *
+ * We support "COPY relation FROM file", "COPY relation TO file", and
+ * "COPY (query) TO file". In any given CopyStmt, exactly one of "relation"
+ * and "query" must be non-NULL.
* ----------------------
*/
typedef struct CopyStmt
{
NodeTag type;
RangeVar *relation; /* the relation to copy */
+ Node *query; /* the SELECT query to copy */
List *attlist; /* List of column names (as Strings), or NIL
* for all columns */
bool is_from; /* TO or FROM */
- char *filename; /* if NULL, use stdin/stdout */
+ char *filename; /* filename, or NULL for STDIN/STDOUT */
List *options; /* List of DefElem nodes */
} CopyStmt;
+/* ----------------------
+ * SET Statement (includes RESET)
+ *
+ * "SET var TO DEFAULT" and "RESET var" are semantically equivalent, but we
+ * preserve the distinction in VariableSetKind for CreateCommandTag().
+ * ----------------------
+ */
+typedef enum
+{
+ VAR_SET_VALUE, /* SET var = value */
+ VAR_SET_DEFAULT, /* SET var TO DEFAULT */
+ VAR_SET_CURRENT, /* SET var FROM CURRENT */
+ VAR_SET_MULTI, /* special case for SET TRANSACTION ... */
+ VAR_RESET, /* RESET var */
+ VAR_RESET_ALL /* RESET ALL */
+} VariableSetKind;
+
+typedef struct VariableSetStmt
+{
+ NodeTag type;
+ VariableSetKind kind;
+ char *name; /* variable to be set */
+ List *args; /* List of A_Const nodes */
+ bool is_local; /* SET LOCAL? */
+} VariableSetStmt;
+
+/* ----------------------
+ * Show Statement
+ * ----------------------
+ */
+typedef struct VariableShowStmt
+{
+ NodeTag type;
+ char *name;
+} VariableShowStmt;
+
/* ----------------------
* Create Table Statement
*
char *tablespacename; /* table space to use, or NULL */
} CreateStmt;
-typedef enum CreateStmtLikeOption {
- CREATE_TABLE_LIKE_INCLUDING_DEFAULTS,
- CREATE_TABLE_LIKE_EXCLUDING_DEFAULTS,
- CREATE_TABLE_LIKE_INCLUDING_CONSTRAINTS,
- CREATE_TABLE_LIKE_EXCLUDING_CONSTRAINTS,
- CREATE_TABLE_LIKE_INCLUDING_INDEXES,
- CREATE_TABLE_LIKE_EXCLUDING_INDEXES
-} CreateStmtLikeOption;
-
/* ----------
* Definitions for plain (non-FOREIGN KEY) constraints in CreateStmt
*
* relation). We should never have both in the same node!
*
* Constraint attributes (DEFERRABLE etc) are initially represented as
- * separate Constraint nodes for simplicity of parsing. analyze.c makes
+ * separate Constraint nodes for simplicity of parsing. parse_utilcmd.c makes
* a pass through the constraints list to attach the info to the appropriate
* FkConstraint node (and, perhaps, someday to other kinds of constraints).
* ----------
{
NodeTag type;
char *tablespacename;
- bool missing_ok; /* skip error if a missing? */
+ bool missing_ok; /* skip error if missing? */
} DropTableSpaceStmt;
/* ----------------------
{
NodeTag type;
char *role; /* role name */
- char *variable; /* GUC variable name */
- List *value; /* value for variable, or NIL for Reset */
+ VariableSetStmt *setstmt; /* SET or RESET subcommand */
} AlterRoleSetStmt;
typedef struct DropRoleStmt
{
NodeTag type;
List *opclassname; /* qualified name (list of Value strings) */
+ List *opfamilyname; /* qualified name (ditto); NIL if omitted */
char *amname; /* name of index AM opclass is for */
TypeName *datatype; /* datatype of indexed column */
List *items; /* List of CreateOpClassItem nodes */
List *name; /* operator or function name */
List *args; /* argument types */
int number; /* strategy num or support proc num */
- bool recheck; /* only used for operators */
+ List *class_args; /* only used for functions */
/* fields used for a storagetype item: */
TypeName *storedtype; /* datatype stored in index */
} CreateOpClassItem;
+/* ----------------------
+ * Create Operator Family Statement
+ * ----------------------
+ */
+typedef struct CreateOpFamilyStmt
+{
+ NodeTag type;
+ List *opfamilyname; /* qualified name (list of Value strings) */
+ char *amname; /* name of index AM opfamily is for */
+} CreateOpFamilyStmt;
+
+/* ----------------------
+ * Alter Operator Family Statement
+ * ----------------------
+ */
+typedef struct AlterOpFamilyStmt
+{
+ NodeTag type;
+ List *opfamilyname; /* qualified name (list of Value strings) */
+ char *amname; /* name of index AM opfamily is for */
+ bool isDrop; /* ADD or DROP the items? */
+ List *items; /* List of CreateOpClassItem nodes */
+} AlterOpFamilyStmt;
+
/* ----------------------
* Drop Table|Sequence|View|Index|Type|Domain|Conversion|Schema Statement
* ----------------------
char *property; /* name of rule, trigger, etc */
ObjectType removeType; /* OBJECT_RULE or OBJECT_TRIGGER */
DropBehavior behavior; /* RESTRICT or CASCADE behavior */
- bool missing_ok; /* skip error if a missing? */
+ bool missing_ok; /* skip error if missing? */
} DropPropertyStmt;
/* ----------------------
{
NodeTag type;
List *relations; /* relations (RangeVars) to be truncated */
+ bool restart_seqs; /* restart owned sequences? */
DropBehavior behavior; /* RESTRICT or CASCADE behavior */
} TruncateStmt;
/* ----------------------
* Declare Cursor Statement
+ *
+ * Note: the "query" field of DeclareCursorStmt is only used in the raw grammar
+ * output. After parse analysis it's set to null, and the Query points to the
+ * DeclareCursorStmt, not vice versa.
* ----------------------
*/
-#define CURSOR_OPT_BINARY 0x0001
-#define CURSOR_OPT_SCROLL 0x0002
-#define CURSOR_OPT_NO_SCROLL 0x0004
-#define CURSOR_OPT_INSENSITIVE 0x0008
-#define CURSOR_OPT_HOLD 0x0010
+#define CURSOR_OPT_BINARY 0x0001 /* BINARY */
+#define CURSOR_OPT_SCROLL 0x0002 /* SCROLL explicitly given */
+#define CURSOR_OPT_NO_SCROLL 0x0004 /* NO SCROLL explicitly given */
+#define CURSOR_OPT_INSENSITIVE 0x0008 /* INSENSITIVE */
+#define CURSOR_OPT_HOLD 0x0010 /* WITH HOLD */
+#define CURSOR_OPT_FAST_PLAN 0x0020 /* prefer fast-start plan */
typedef struct DeclareCursorStmt
{
NodeTag type;
char *portalname; /* name of the portal (cursor) */
int options; /* bitmask of options (see above) */
- Node *query; /* the SELECT query */
+ Node *query; /* the raw SELECT query */
} DeclareCursorStmt;
/* ----------------------
{
NodeTag type;
char *portalname; /* name of the portal (cursor) */
+ /* NULL means CLOSE ALL */
} ClosePortalStmt;
/* ----------------------
char *idxname; /* name of new index, or NULL for default */
RangeVar *relation; /* relation to build index on */
char *accessMethod; /* name of access method (eg. btree) */
- char *tableSpace; /* tablespace, or NULL to use parent's */
+ char *tableSpace; /* tablespace, or NULL for default */
List *indexParams; /* a list of IndexElem */
List *options; /* options from WITH clause */
Node *whereClause; /* qualification (partial-index predicate) */
- List *rangetable; /* range table for qual and/or expressions,
- * filled in by transformStmt() */
bool unique; /* is index unique? */
bool primary; /* is index on primary key? */
bool isconstraint; /* is it from a CONSTRAINT clause? */
+ bool concurrent; /* should this be a concurrent index build? */
} IndexStmt;
/* ----------------------
/* the assigned enum values appear in pg_proc, don't change 'em! */
FUNC_PARAM_IN = 'i', /* input only */
FUNC_PARAM_OUT = 'o', /* output only */
- FUNC_PARAM_INOUT = 'b' /* both */
+ FUNC_PARAM_INOUT = 'b', /* both */
+ FUNC_PARAM_VARIADIC = 'v', /* variadic */
+ FUNC_PARAM_TABLE = 't' /* table function output column */
} FunctionParameterMode;
typedef struct FunctionParameter
List *name; /* qualified name of object to drop */
List *args; /* types of the arguments */
DropBehavior behavior; /* RESTRICT or CASCADE behavior */
- bool missing_ok; /* skip error if a missing? */
+ bool missing_ok; /* skip error if missing? */
} RemoveFuncStmt;
/* ----------------------
List *opclassname; /* qualified name (list of Value strings) */
char *amname; /* name of index AM opclass is for */
DropBehavior behavior; /* RESTRICT or CASCADE behavior */
- bool missing_ok; /* skip error if a missing? */
+ bool missing_ok; /* skip error if missing? */
} RemoveOpClassStmt;
+/* ----------------------
+ * Drop Operator Family Statement
+ * ----------------------
+ */
+typedef struct RemoveOpFamilyStmt
+{
+ NodeTag type;
+ List *opfamilyname; /* qualified name (list of Value strings) */
+ char *amname; /* name of index AM opfamily is for */
+ DropBehavior behavior; /* RESTRICT or CASCADE behavior */
+ bool missing_ok; /* skip error if missing? */
+} RemoveOpFamilyStmt;
+
/* ----------------------
* Alter Object Rename Statement
* ----------------------
List *coldeflist; /* list of ColumnDef nodes */
} CompositeTypeStmt;
+/* ----------------------
+ * Create Type Statement, enum types
+ * ----------------------
+ */
+typedef struct CreateEnumStmt
+{
+ NodeTag type;
+ List *typename; /* qualified name (list of Value strings) */
+ List *vals; /* enum values (list of Value strings) */
+} CreateEnumStmt;
+
/* ----------------------
* Create View Statement
NodeTag type;
RangeVar *view; /* the view to be created */
List *aliases; /* target column names */
- Query *query; /* the SQL statement */
+ Node *query; /* the SELECT query */
bool replace; /* replace an existing view? */
} ViewStmt;
typedef struct AlterDatabaseSetStmt
{
NodeTag type;
- char *dbname;
- char *variable;
- List *value;
+ char *dbname; /* database name */
+ VariableSetStmt *setstmt; /* SET or RESET subcommand */
} AlterDatabaseSetStmt;
/* ----------------------
bool vacuum; /* do VACUUM step */
bool full; /* do FULL (non-concurrent) vacuum */
bool analyze; /* do ANALYZE step */
- bool freeze; /* early-freeze option */
bool verbose; /* print progress info */
+ int freeze_min_age; /* min freeze age, or -1 to use default */
RangeVar *relation; /* single table to process, or NULL */
List *va_cols; /* list of column names, or NIL for all */
} VacuumStmt;
typedef struct ExplainStmt
{
NodeTag type;
- Query *query; /* the query */
+ Node *query; /* the query (as a raw parse tree) */
bool verbose; /* print plan info */
bool analyze; /* get statistics by executing plan */
} ExplainStmt;
} CheckPointStmt;
/* ----------------------
- * Set Statement
+ * Discard Statement
* ----------------------
*/
-typedef struct VariableSetStmt
+typedef enum DiscardMode
{
- NodeTag type;
- char *name;
- List *args;
- bool is_local; /* SET LOCAL */
-} VariableSetStmt;
-
-/* ----------------------
- * Show Statement
- * ----------------------
- */
+ DISCARD_ALL,
+ DISCARD_PLANS,
+ DISCARD_TEMP
+} DiscardMode;
-typedef struct VariableShowStmt
+typedef struct DiscardStmt
{
NodeTag type;
- char *name;
-} VariableShowStmt;
-
-/* ----------------------
- * Reset Statement
- * ----------------------
- */
-
-typedef struct VariableResetStmt
-{
- NodeTag type;
- char *name;
-} VariableResetStmt;
+ DiscardMode target;
+} DiscardStmt;
/* ----------------------
* LOCK Statement
TypeName *sourcetype;
TypeName *targettype;
DropBehavior behavior;
- bool missing_ok; /* skip error if a missing? */
+ bool missing_ok; /* skip error if missing? */
} DropCastStmt;
{
NodeTag type;
char *name; /* Name of plan, arbitrary */
- List *argtypes; /* Types of parameters (TypeNames) */
- List *argtype_oids; /* Types of parameters (OIDs) */
- Query *query; /* The query itself */
+ List *argtypes; /* Types of parameters (List of TypeName) */
+ Node *query; /* The query itself (as a raw parsetree) */
} PrepareStmt;
typedef struct ExecuteStmt
{
- NodeTag type;
- char *name; /* The name of the plan to execute */
- RangeVar *into; /* Optional table to store results in */
- List *intoOptions; /* Options from WITH clause */
- OnCommitAction into_on_commit; /* What do we do at COMMIT? */
- char *into_tbl_space; /* Tablespace to use, or NULL */
- List *params; /* Values to assign to parameters */
+ NodeTag type;
+ char *name; /* The name of the plan to execute */
+ IntoClause *into; /* Optional table to store results in */
+ List *params; /* Values to assign to parameters */
} ExecuteStmt;
{
NodeTag type;
char *name; /* The name of the plan to remove */
+ /* NULL means DEALLOCATE ALL */
} DeallocateStmt;
/*
char *newrole;
} ReassignOwnedStmt;
+/*
+ * TS Dictionary stmts: DefineStmt, RenameStmt and DropStmt are default
+ */
+typedef struct AlterTSDictionaryStmt
+{
+ NodeTag type;
+ List *dictname; /* qualified name (list of Value strings) */
+ List *options; /* List of DefElem nodes */
+} AlterTSDictionaryStmt;
+
+/*
+ * TS Configuration stmts: DefineStmt, RenameStmt and DropStmt are default
+ */
+typedef struct AlterTSConfigurationStmt
+{
+ NodeTag type;
+ List *cfgname; /* qualified name (list of Value strings) */
+
+ /*
+ * dicts will be non-NIL if ADD/ALTER MAPPING was specified. If dicts is
+ * NIL, but tokentype isn't, DROP MAPPING was specified.
+ */
+ List *tokentype; /* list of Value strings */
+ List *dicts; /* list of list of Value strings */
+ bool override; /* if true - remove old variant */
+ bool replace; /* if true - replace dictionary by another */
+ bool missing_ok; /* for DROP - skip error if missing? */
+} AlterTSConfigurationStmt;
+
#endif /* PARSENODES_H */