* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.321 2006/08/10 02:36:29 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.335 2006/12/23 00:43:12 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#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 */
Node *utilityStmt; /* non-null if this is 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 */
+ List *intoOptions; /* options from WITH clause */
OnCommitAction intoOnCommit; /* what do we do at COMMIT? */
- char *intoTableSpaceName; /* table space to use, or NULL */
+ char *intoTableSpaceName; /* table space to use, or NULL */
bool hasAggs; /* has aggregates in tlist or havingQual */
bool hasSubLinks; /* has subquery SubLink */
List *targetList; /* target list (of TargetEntry) */
+ List *returningList; /* return-values list (of TargetEntry) */
+
List *groupClause; /* a list of GroupClause's */
Node *havingQual; /* qualifications applied to groups */
* 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
+ * exact set of child tables at parse time. XXX 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 */
+
+ /*
+ * If the query has a returningList then the planner will store a list of
+ * processed targetlists (one per result relation) here. We must have a
+ * separate RETURNING targetlist for each result rel because column
+ * numbers may vary within an inheritance tree. In the targetlists, Vars
+ * referencing the result relation will have their original varno and
+ * varattno, while Vars referencing other rels will be converted to have
+ * varno OUTER and varattno referencing a resjunk entry in the top plan
+ * node's targetlist. XXX This field ought to go in some sort of TopPlan
+ * plan node, not in the Query.
+ */
+ List *returningLists; /* list of lists of TargetEntry, or NIL */
} Query;
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)
*
*/
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):
RangeVar *relation; /* relation to insert into */
List *cols; /* optional: names of the target columns */
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;
/* ----------------------
/*
* These fields are used only in "leaf" SelectStmts.
*
- * into, intoColNames, intoOptions, intoOnCommit, and
- * intoTableSpaceName are a kluge; they belong somewhere else...
+ * 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? */
+ OnCommitAction intoOnCommit; /* what do we do at COMMIT? */
char *intoTableSpaceName; /* table space to use, or NULL */
List *targetList; /* the target list (of ResTarget) */
List *fromClause; /* the FROM clause */
/*
* 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.
+ * 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 */
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_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. Note: "query" is a SelectStmt before
+ * parse analysis, and a Query afterwards.
* ----------------------
*/
typedef struct CopyStmt
{
NodeTag type;
RangeVar *relation; /* the relation to copy */
+ Query *query; /* the 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;
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
*
{
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 */
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;
/* ----------------------
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 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 */
+ 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 */
} ExecuteStmt;