parsenodes.h 42.1 KB
Newer Older
1 2
/*-------------------------------------------------------------------------
 *
3
 * parsenodes.h
4
 *	  definitions for parse tree nodes
5 6
 *
 *
7
 * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
B
Add:  
Bruce Momjian 已提交
8
 * Portions Copyright (c) 1994, Regents of the University of California
9
 *
10
 * $Id: parsenodes.h,v 1.163 2002/03/21 16:01:46 tgl Exp $
11 12 13
 *
 *-------------------------------------------------------------------------
 */
14 15
#ifndef PARSENODES_H
#define PARSENODES_H
16

17
#include "nodes/primnodes.h"
18

19 20 21 22 23 24 25 26 27

typedef enum InhOption
{
	INH_NO,						/* Do NOT scan child tables */
	INH_YES,					/* DO scan child tables */
	INH_DEFAULT					/* Use current SQL_inheritance option */
} InhOption;


28
/*****************************************************************************
29
 *	Query Tree
30 31 32 33
 *****************************************************************************/

/*
 * Query -
34 35 36 37
 *	  all statments are turned into a Query tree (via transformStmt)
 *	  for further processing by the optimizer
 *	  utility statements (i.e. non-optimizable statements)
 *	  have the *utilityStmt field set.
38 39 40 41
 *
 * we need the isPortal flag because portal names can be null too; can
 * get rid of it if we support CURSOR as a commandType.
 */
42 43
typedef struct Query
{
44
	NodeTag		type;
45

46
	CmdType		commandType;	/* select|insert|update|delete|utility */
47

48
	Node	   *utilityStmt;	/* non-null if this is a non-optimizable
49 50
								 * statement */

51
	int			resultRelation; /* target relation (index into rtable) */
52 53
	struct RangeVar *into;		/* target relation or portal (cursor) 
								 * for portal just name is meaningful */
54 55
	bool		isPortal;		/* is this a retrieve into portal? */
	bool		isBinary;		/* binary portal? */
56

57
	bool		hasAggs;		/* has aggregates in tlist or havingQual */
58
	bool		hasSubLinks;	/* has subquery SubLink */
59

60 61
	bool		originalQuery;	/* marks original query through rewriting */

62
	List	   *rtable;			/* list of range table entries */
B
Bruce Momjian 已提交
63 64
	FromExpr   *jointree;		/* table join tree (FROM and WHERE
								 * clauses) */
65

66 67
	List	   *rowMarks;		/* integer list of RT indexes of relations
								 * that are selected FOR UPDATE */
68

69
	List	   *targetList;		/* target list (of TargetEntry) */
70

71 72 73
	List	   *groupClause;	/* a list of GroupClause's */

	Node	   *havingQual;		/* qualifications applied to groups */
B
Hi!  
Bruce Momjian 已提交
74

75 76 77
	List	   *distinctClause; /* a list of SortClause's */

	List	   *sortClause;		/* a list of SortClause's */
78

B
Bruce Momjian 已提交
79 80
	Node	   *limitOffset;	/* # of result tuples to skip */
	Node	   *limitCount;		/* # of result tuples to return */
B
Bruce Momjian 已提交
81

82 83 84
	Node	   *setOperations;	/* set-operation tree if this is top level
								 * of a UNION/INTERSECT/EXCEPT query */

85 86 87 88 89 90 91 92
	/*
	 * 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.
	 */
93
	List	   *resultRelations;	/* integer list of RT indexes, or NIL */
94

95
	/* internal to planner */
96
	List	   *base_rel_list;	/* list of base-relation RelOptInfos */
97
	List	   *other_rel_list; /* list of other 1-relation RelOptInfos */
98
	List	   *join_rel_list;	/* list of join-relation RelOptInfos */
99 100
	List	   *equi_key_list;	/* list of lists of equijoined
								 * PathKeyItems */
101
	List	   *query_pathkeys; /* pathkeys for query_planner()'s result */
102
} Query;
103 104


105 106
/****************************************************************************
 *	Supporting data structures for Parse Trees
107
 *
108 109 110 111
 *	Most of these node types appear in raw parsetrees output by the grammar,
 *	and get transformed to something else by the analyzer.	A few of them
 *	are used as-is in transformed querytrees.
 ****************************************************************************/
112

113 114
/*
 * TypeName - specifies a type in definitions
115
 */
116
typedef struct TypeName
117
{
118
	NodeTag		type;
119 120 121 122 123 124 125
	char	   *name;			/* name of the type */
	bool		timezone;		/* timezone specified? */
	bool		setof;			/* is a set? */
	int32		typmod;			/* type modifier */
	List	   *arrayBounds;	/* array bounds */
	char	   *attrname;		/* field name when using %TYPE */
} TypeName;
126

127
/*
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
 * ColumnRef - specifies a reference to a column, or possibly a whole tuple
 *
 *		The "fields" list must be nonempty; its last component may be "*"
 *		instead of a field name.  Subscripts are optional.
 */
typedef struct ColumnRef
{
	NodeTag		type;
	List	   *fields;			/* field names (list of Value strings) */
	List	   *indirection;	/* subscripts (list of A_Indices) */
} ColumnRef;

/*
 * ParamRef - specifies a parameter reference
 *
 *		The parameter could be qualified with field names and/or subscripts
144
 */
145
typedef struct ParamRef
146 147
{
	NodeTag		type;
148
	int			number;			/* the number of the parameter */
149 150 151
	List	   *fields;			/* field names (list of Value strings) */
	List	   *indirection;	/* subscripts (list of A_Indices) */
} ParamRef;
152

153 154 155 156
/*
 * A_Expr - binary expressions
 */
typedef struct A_Expr
157
{
158
	NodeTag		type;
159 160 161 162 163
	int			oper;			/* type of operation (OP,OR,AND,NOT) */
	char	   *opname;			/* name of operator */
	Node	   *lexpr;			/* left argument */
	Node	   *rexpr;			/* right argument */
} A_Expr;
164

165 166 167 168
/*
 * A_Const - a constant expression
 */
typedef struct A_Const
169 170
{
	NodeTag		type;
171 172 173
	Value		val;			/* the value (with the tag) */
	TypeName   *typename;		/* typecast */
} A_Const;
174

175 176 177
/*
 * TypeCast - a CAST expression
 *
178
 * NOTE: for mostly historical reasons, A_Const parsenodes contain
179
 * room for a TypeName; we only generate a separate TypeCast node if the
180 181 182
 * argument to be casted is not a constant.  In theory either representation
 * would work, but it is convenient to have the target type immediately
 * available while resolving a constant's datatype.
183
 */
184
typedef struct TypeCast
185
{
186
	NodeTag		type;
187 188 189
	Node	   *arg;			/* the expression being casted */
	TypeName   *typename;		/* the target type */
} TypeCast;
190

191 192
/*
 * CaseExpr - a CASE expression
193
 */
194
typedef struct CaseExpr
195
{
196
	NodeTag		type;
197 198 199 200 201
	Oid			casetype;
	Node	   *arg;			/* implicit equality comparison argument */
	List	   *args;			/* the arguments (list of WHEN clauses) */
	Node	   *defresult;		/* the default result (ELSE clause) */
} CaseExpr;
202

203 204
/*
 * CaseWhen - an argument to a CASE expression
205
 */
206
typedef struct CaseWhen
207
{
208
	NodeTag		type;
209 210 211
	Node	   *expr;			/* comparison expression */
	Node	   *result;			/* substitution result */
} CaseWhen;
212

213 214
/* ----------------
 * NullTest
215
 *
216 217 218 219 220
 * NullTest represents the operation of testing a value for NULLness.
 * Currently, we only support scalar input values, but eventually a
 * row-constructor input should be supported.
 * The appropriate test is performed and returned as a boolean Datum.
 * ----------------
221 222
 */

223
typedef enum NullTestType
224
{
225 226
	IS_NULL, IS_NOT_NULL
} NullTestType;
227

228
typedef struct NullTest
229
{
230
	NodeTag		type;
231 232 233
	Node	   *arg;			/* input expression */
	NullTestType nulltesttype;	/* IS NULL, IS NOT NULL */
} NullTest;
J
Jan Wieck 已提交
234

235 236 237 238 239 240 241 242
/* ----------------
 * BooleanTest
 *
 * BooleanTest represents the operation of determining whether a boolean
 * is TRUE, FALSE, or UNKNOWN (ie, NULL).  All six meaningful combinations
 * are supported.  Note that a NULL input does *not* cause a NULL result.
 * The appropriate test is performed and returned as a boolean Datum.
 * ----------------
J
Jan Wieck 已提交
243 244
 */

245
typedef enum BoolTestType
J
Jan Wieck 已提交
246
{
247 248
	IS_TRUE, IS_NOT_TRUE, IS_FALSE, IS_NOT_FALSE, IS_UNKNOWN, IS_NOT_UNKNOWN
} BoolTestType;
249

250
typedef struct BooleanTest
251
{
252
	NodeTag		type;
253 254 255
	Node	   *arg;			/* input expression */
	BoolTestType booltesttype;	/* test type */
} BooleanTest;
256

257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
/*
 * ColumnDef - column definition (used in various creates)
 *
 * If the column has a default value, we may have the value expression
 * in either "raw" form (an untransformed parse tree) or "cooked" form
 * (the nodeToString representation of an executable expression tree),
 * depending on how this ColumnDef node was created (by parsing, or by
 * inheritance from an existing relation).	We should never have both
 * in the same node!
 *
 * The constraints list may contain a CONSTR_DEFAULT item in a raw
 * 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.
 */
typedef struct ColumnDef
273
{
274
	NodeTag		type;
275 276 277 278 279 280 281 282
	char	   *colname;		/* name of column */
	TypeName   *typename;		/* type of column */
	bool		is_not_null;	/* NOT NULL constraint specified? */
	Node	   *raw_default;	/* default value (untransformed parse
								 * tree) */
	char	   *cooked_default; /* nodeToString representation */
	List	   *constraints;	/* other constraints on column */
} ColumnDef;
283

284 285
/*
 * Ident -
286 287
 *	  an unqualified identifier.  This is currently used only in the context
 *	  of column name lists.
288
 */
289
typedef struct Ident
290 291
{
	NodeTag		type;
292 293
	char	   *name;			/* its name */
} Ident;
294

295 296 297 298 299 300 301 302 303
/*
 * FuncCall - a function or aggregate invocation
 *
 * agg_star indicates we saw a 'foo(*)' construct, while agg_distinct
 * indicates we saw 'foo(DISTINCT ...)'.  In either case, the construct
 * *must* be an aggregate call.  Otherwise, it might be either an
 * aggregate or some other kind of function.
 */
typedef struct FuncCall
304 305
{
	NodeTag		type;
306 307 308 309 310
	char	   *funcname;		/* name of function */
	List	   *args;			/* the arguments (list of exprs) */
	bool		agg_star;		/* argument was really '*' */
	bool		agg_distinct;	/* arguments were labeled DISTINCT */
} FuncCall;
311

312 313
/*
 * A_Indices - array reference or bounds ([lidx:uidx] or [uidx])
314
 */
315
typedef struct A_Indices
316
{
317
	NodeTag		type;
318 319 320
	Node	   *lidx;			/* could be NULL */
	Node	   *uidx;
} A_Indices;
321

322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
/*
 * ExprFieldSelect - select a field and/or array element from an expression
 *
 *		This is used in the raw parsetree to represent selection from an
 *		arbitrary expression (not a column or param reference).  Either
 *		fields or indirection may be NIL if not used.
 */
typedef struct ExprFieldSelect
{
	NodeTag		type;
	Node	   *arg;			/* the thing being selected from */
	List	   *fields;			/* field names (list of Value strings) */
	List	   *indirection;	/* subscripts (list of A_Indices) */
} ExprFieldSelect;

337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
/*
 * ResTarget -
 *	  result target (used in target list of pre-transformed Parse trees)
 *
 * In a SELECT or INSERT target list, 'name' is either NULL or
 * the column name assigned to the value.  (If there is an 'AS ColumnLabel'
 * clause, the grammar sets 'name' from it; otherwise 'name' is initially NULL
 * and is filled in during the parse analysis phase.)
 * The 'indirection' field is not used at all.
 *
 * In an UPDATE target list, 'name' is the name of the destination column,
 * and 'indirection' stores any subscripts attached to the destination.
 * That is, our representation is UPDATE table SET name [indirection] = val.
 */
typedef struct ResTarget
352 353
{
	NodeTag		type;
354 355 356 357 358 359
	char	   *name;			/* column name or NULL */
	List	   *indirection;	/* subscripts for destination column, or
								 * NIL */
	Node	   *val;			/* the value expression to compute or
								 * assign */
} ResTarget;
360

361 362 363 364
/*
 * SortGroupBy - for ORDER BY clause
 */
typedef struct SortGroupBy
365 366
{
	NodeTag		type;
367 368 369
	char	   *useOp;			/* operator to use */
	Node	   *node;			/* Expression  */
} SortGroupBy;
370

371 372 373 374 375 376 377 378 379 380 381 382 383
/*
 * Alias -
 *	  specifies an alias for a range variable; the alias might also
 *	  specify renaming of columns within the table.
 */
typedef struct Alias
{
	NodeTag		type;
	char	   *aliasname;		/* aliased rel name (never qualified) */
	List	   *colnames;		/* optional list of column aliases */
	/* Note: colnames is a list of Value nodes (always strings) */
} Alias;

384 385
/*
 * RangeVar - range variable, used in FROM clauses
386 387 388 389 390
 *
 * Also used to represent table names in utility statements; there, the alias
 * field is not used, and inhOpt shows whether to apply the operation
 * recursively to child tables.  In some contexts it is also useful to carry
 * a TEMP table indication here.
391 392
 */
typedef struct RangeVar
393
{
394
	NodeTag		type;
395 396 397 398 399 400 401
	char	   *catalogname;	/* the catalog (database) name, or NULL */
	char	   *schemaname;		/* the schema name, or NULL */
	char	   *relname;		/* the relation/sequence name */
	InhOption	inhOpt;			/* expand rel by inheritance? 
								 * recursively act on children? */
	bool		istemp;			/* is this a temp relation/sequence? */
	Alias	   *alias;			/* table alias & optional column aliases */
402
} RangeVar;
403

404 405
/*
 * RangeSubselect - subquery appearing in a FROM clause
406
 */
407
typedef struct RangeSubselect
408
{
409
	NodeTag		type;
410
	Node	   *subquery;		/* the untransformed sub-select clause */
411
	Alias	   *alias;			/* table alias & optional column aliases */
412
} RangeSubselect;
413

414 415 416 417 418 419 420 421 422
/*
 * IndexElem - index parameters (used in CREATE INDEX)
 *
 * For a plain index, each 'name' is an attribute name in the heap relation,
 * and 'args' is NIL.  For a functional index, only one IndexElem is allowed.
 * It has name = name of function and args = list of attribute names that
 * are the function's arguments.
 */
typedef struct IndexElem
423
{
424
	NodeTag		type;
425 426 427 428
	char	   *name;			/* name of attribute to index, or function */
	List	   *args;			/* list of names of function arguments */
	char	   *class;			/* name of desired opclass; NULL = default */
} IndexElem;
429

430 431 432 433 434
/*
 * DefElem -
 *	  a definition (used in definition lists in the form of defname = arg)
 */
typedef struct DefElem
435
{
436
	NodeTag		type;
437 438 439
	char	   *defname;
	Node	   *arg;			/* a (Value *) or a (TypeName *) */
} DefElem;
440

V
Vadim B. Mikheev 已提交
441

442 443 444
/****************************************************************************
 *	Nodes for a Query tree
 ****************************************************************************/
V
Vadim B. Mikheev 已提交
445

446 447 448 449 450 451
/*
 * TargetEntry -
 *	   a target  entry (used in the transformed target list)
 *
 * one of resdom or fjoin is not NULL. a target list is
 *		((<resdom | fjoin> expr) (<resdom | fjoin> expr) ...)
452
 */
453
typedef struct TargetEntry
454
{
455
	NodeTag		type;
456 457 458 459
	Resdom	   *resdom;			/* fjoin overload this to be a list?? */
	Fjoin	   *fjoin;
	Node	   *expr;
} TargetEntry;
460

461 462 463 464
/*--------------------
 * RangeTblEntry -
 *	  A range table is a List of RangeTblEntry nodes.
 *
465 466 467 468 469 470
 *	  A range table entry may represent a plain relation, a sub-select in
 *	  FROM, or the result of a JOIN clause.  (Only explicit JOIN syntax
 *	  produces an RTE, not the implicit join resulting from multiple FROM
 *	  items.  This is because we only need the RTE to deal with SQL features
 *	  like outer joins and join-output-column aliasing.)  Other special
 *	  RTE types also exist, as indicated by RTEKind.
471
 *
472
 *	  alias is an Alias node representing the AS alias-clause attached to the
473 474 475 476 477 478 479 480 481 482
 *	  FROM expression, or NULL if no clause.
 *
 *	  eref is the table reference name and column reference names (either
 *	  real or aliases).  Note that system columns (OID etc) are not included
 *	  in the column list.
 *	  eref->relname is required to be present, and should generally be used
 *	  to identify the RTE for error messages etc.
 *
 *	  inh is TRUE for relation references that should be expanded to include
 *	  inheritance children, if the rel has any.  This *must* be FALSE for
483
 *	  RTEs other than RTE_RELATION entries.
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501
 *
 *	  inFromCl marks those range variables that are listed in the FROM clause.
 *	  In SQL, the query can only refer to range variables listed in the
 *	  FROM clause, but POSTQUEL allows you to refer to tables not listed,
 *	  in which case a range table entry will be generated.	We still support
 *	  this POSTQUEL feature, although there is some doubt whether it's
 *	  convenient or merely confusing.  The flag is needed since an
 *	  implicitly-added RTE shouldn't change the namespace for unqualified
 *	  column names processed later, and it also shouldn't affect the
 *	  expansion of '*'.
 *
 *	  checkForRead, checkForWrite, and checkAsUser control run-time access
 *	  permissions checks.  A rel will be checked for read or write access
 *	  (or both, or neither) per checkForRead and checkForWrite.  If
 *	  checkAsUser is not InvalidOid, then do the permissions checks using
 *	  the access rights of that user, not the current effective user ID.
 *	  (This allows rules to act as setuid gateways.)
 *--------------------
502
 */
503 504 505 506 507 508 509 510
typedef enum RTEKind
{
	RTE_RELATION,				/* ordinary relation reference */
	RTE_SUBQUERY,				/* subquery in FROM */
	RTE_JOIN,					/* join */
	RTE_SPECIAL					/* special rule relation (NEW or OLD) */
} RTEKind;

511
typedef struct RangeTblEntry
512
{
513
	NodeTag		type;
514

515 516
	RTEKind		rtekind;		/* see above */

517
	/*
518 519 520 521 522 523
	 * XXX the fields applicable to only some rte kinds should be merged
	 * into a union.  I didn't do this yet because the diffs would impact
	 * a lot of code that is being actively worked on.  FIXME later.
	 */

	/*
524
	 * Fields valid for a plain relation RTE (else NULL/zero):
525 526 527
	 */
	char	   *relname;		/* real name of the relation */
	Oid			relid;			/* OID of the relation */
528

529 530 531 532
	/*
	 * Fields valid for a subquery RTE (else NULL):
	 */
	Query	   *subquery;		/* the sub-query */
533

534 535 536 537 538 539 540 541 542 543 544 545 546 547 548
	/*
	 * Fields valid for a join RTE (else NULL):
	 *
	 * joincoltypes/joincoltypmods identify the column datatypes of the
	 * join result.  joinleftcols and joinrightcols identify the source
	 * columns from the join's inputs: each entry is either a source column
	 * AttrNumber or zero.  For normal columns exactly one is nonzero,
	 * but both are nonzero for a column "merged" by USING or NATURAL.
	 */
	JoinType	jointype;		/* type of join */
	List	   *joincoltypes;	/* integer list of column type OIDs */
	List	   *joincoltypmods;	/* integer list of column typmods */
	List	   *joinleftcols;	/* integer list of left-side column #s */
	List	   *joinrightcols;	/* integer list of right-side column #s */

549 550 551
	/*
	 * Fields valid in all RTEs:
	 */
552 553
	Alias	   *alias;			/* user-written alias clause, if any */
	Alias	   *eref;			/* expanded reference names */
554 555 556 557 558 559
	bool		inh;			/* inheritance requested? */
	bool		inFromCl;		/* present in FROM clause */
	bool		checkForRead;	/* check rel for read access */
	bool		checkForWrite;	/* check rel for write access */
	Oid			checkAsUser;	/* if not zero, check access as this user */
} RangeTblEntry;
560

561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576
/*
 * SortClause -
 *	   representation of ORDER BY clauses
 *
 * tleSortGroupRef must match ressortgroupref of exactly one Resdom of the
 * associated targetlist; that is the expression to be sorted (or grouped) by.
 * sortop is the OID of the ordering operator.
 *
 * SortClauses are also used to identify Resdoms 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.
 */
typedef struct SortClause
577
{
578
	NodeTag		type;
579 580 581
	Index		tleSortGroupRef;	/* reference into targetlist */
	Oid			sortop;			/* the sort operator to use */
} SortClause;
582

583 584 585 586 587 588 589
/*
 * 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.
590
 */
591 592 593 594 595 596
typedef SortClause GroupClause;


/*****************************************************************************
 *		Optimizable Statements
 *****************************************************************************/
597 598

/* ----------------------
599
 *		Insert Statement
600 601
 * ----------------------
 */
602
typedef struct InsertStmt
603
{
604
	NodeTag		type;
605
	RangeVar   *relation;		/* relation to insert into */
606 607 608 609 610 611 612 613 614 615
	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 */
} InsertStmt;
616

617
/* ----------------------
618
 *		Delete Statement
619 620
 * ----------------------
 */
621
typedef struct DeleteStmt
622
{
623
	NodeTag		type;
624
	RangeVar   *relation;		/* relation to delete from */
625 626
	Node	   *whereClause;	/* qualifications */
} DeleteStmt;
627 628

/* ----------------------
629
 *		Update Statement
630 631
 * ----------------------
 */
632
typedef struct UpdateStmt
633
{
634
	NodeTag		type;
635
	RangeVar   *relation;		/* relation to update */
636 637
	List	   *targetList;		/* the target list (of ResTarget) */
	Node	   *whereClause;	/* qualifications */
638
	List	   *fromClause;		/* optional from clause for more tables */
639
} UpdateStmt;
640 641

/* ----------------------
642 643 644 645 646 647 648 649 650 651
 *		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
 * 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
 * whether it is a simple or compound SELECT.
652 653
 * ----------------------
 */
654 655 656 657 658 659 660 661 662
typedef enum SetOperation
{
	SETOP_NONE = 0,
	SETOP_UNION,
	SETOP_INTERSECT,
	SETOP_EXCEPT
} SetOperation;

typedef struct SelectStmt
663
{
664
	NodeTag		type;
665 666 667 668 669 670 671

	/*
	 * These fields are used only in "leaf" SelectStmts.
	 */
	List	   *distinctClause; /* NULL, list of DISTINCT ON exprs, or
								 * lcons(NIL,NIL) for all (SELECT
								 * DISTINCT) */
672
	RangeVar   *into;			/* target table (for select into table) */
673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699
	List	   *intoColNames;	/* column names for into table */
	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 */

	/*
	 * These fields are used in both "leaf" SelectStmts and upper-level
	 * SelectStmts.  portalname/binary may only be set at the top level.
	 */
	List	   *sortClause;		/* sort clause (a list of SortGroupBy's) */
	char	   *portalname;		/* the portal (cursor) to create */
	bool		binary;			/* a binary (internal) portal? */
	Node	   *limitOffset;	/* # of result tuples to skip */
	Node	   *limitCount;		/* # of result tuples to return */
	List	   *forUpdate;		/* FOR UPDATE clause */

	/*
	 * These fields are used only in upper-level SelectStmts.
	 */
	SetOperation op;			/* type of set op */
	bool		all;			/* ALL specified? */
	struct SelectStmt *larg;	/* left child */
	struct SelectStmt *rarg;	/* right child */
	/* Eventually add fields for CORRESPONDING spec here */
} SelectStmt;
700 701

/* ----------------------
702 703 704 705 706 707 708
 *		Set Operation node for post-analysis query trees
 *
 * After parse analysis, a SELECT with set operations is represented by a
 * 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.
709 710
 * ----------------------
 */
711
typedef struct SetOperationStmt
712
{
713
	NodeTag		type;
714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733
	SetOperation op;			/* type of set op */
	bool		all;			/* ALL specified? */
	Node	   *larg;			/* left child */
	Node	   *rarg;			/* right child */
	/* Eventually add fields for CORRESPONDING spec here */

	/* Fields derived during parse analysis: */
	List	   *colTypes;		/* integer list of OIDs of output column
								 * types */
} 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.
 *****************************************************************************/
734

735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750
/* ----------------------
 *		Create Schema Statement
 *
 * NOTE: the schemaElts list contains raw parsetrees for component statements
 * of the schema, such as CREATE TABLE, GRANT, etc.  These are analyzed and
 * executed after the schema itself is created.
 * ----------------------
 */
typedef struct CreateSchemaStmt
{
	NodeTag		type;
	char	   *schemaname;		/* the name of the schema to create */
	char	   *authid;			/* the owner of the created schema */
	List	   *schemaElts;		/* schema components (list of parsenodes) */
} CreateSchemaStmt;

751
/* ----------------------
752 753 754 755
 *	Alter Table
 *
 * The fields are used in different ways by the different variants of
 * this command.
756 757
 * ----------------------
 */
758
typedef struct AlterTableStmt
759
{
760
	NodeTag		type;
761 762 763 764 765 766 767 768 769 770 771 772
	char		subtype;		/*------------
								 *	A = add column
								 *	T = alter column default
								 *	S = alter column statistics
								 *  M = alter column storage
								 *	D = drop column
								 *	C = add constraint
								 *	X = drop constraint
								 *	E = create toast table
								 *	U = change owner
								 *------------
								 */
773
	RangeVar   *relation;		/* table to work on */
774 775 776 777 778
	char	   *name;			/* column or constraint name to act on, or
								 * new owner */
	Node	   *def;			/* definition of new column or constraint */
	int			behavior;		/* CASCADE or RESTRICT drop behavior */
} AlterTableStmt;
779

780
/* ----------------------
781
 *		Grant Statement
782 783
 * ----------------------
 */
784 785

typedef struct GrantStmt
786
{
787
	NodeTag		type;
788 789
	bool		is_grant;		/* not revoke */
	int			objtype;
790 791
	List	   *objects;		/* list of names (as Value strings)
								 * or relations (as RangeVar's) */
792 793 794
	List	   *privileges;		/* integer list of privilege codes */
	List	   *grantees;		/* list of PrivGrantee nodes */
} GrantStmt;
795

796
typedef struct PrivGrantee
797
{
798
	NodeTag		type;
799 800 801
	char	   *username;		/* if both are NULL then PUBLIC */
	char	   *groupname;
} PrivGrantee;
802

803
typedef struct FuncWithArgs
804
{
805
	NodeTag		type;
806 807 808
	char	   *funcname;
	List	   *funcargs;		/* list of Typename nodes */
} FuncWithArgs;
809

810 811
/* This is only used internally in gram.y. */
typedef struct PrivTarget
812
{
813
	NodeTag		type;
814 815 816 817
	int			objtype;
	List	   *objs;
} PrivTarget;

818
/* ----------------------
819
 *		Close Portal Statement
820 821
 * ----------------------
 */
822
typedef struct ClosePortalStmt
823
{
824
	NodeTag		type;
825 826
	char	   *portalname;		/* name of the portal (cursor) */
} ClosePortalStmt;
827 828

/* ----------------------
829
 *		Copy Statement
830 831
 * ----------------------
 */
832
typedef struct CopyStmt
833
{
834
	NodeTag		type;
835
	bool		binary;			/* is a binary copy? */
836
	RangeVar   *relation;		/* the relation to copy */
837 838 839 840 841 842
	bool		oids;			/* copy oid's? */
	int			direction;		/* TO or FROM */
	char	   *filename;		/* if NULL, use stdin/stdout */
	char	   *delimiter;		/* delimiter character, \t by default */
	char	   *null_print;		/* how to print NULLs, `\N' by default */
} CopyStmt;
M
 
Marc G. Fournier 已提交
843 844

/* ----------------------
845 846 847 848 849 850 851
 *		Create Table Statement
 *
 * NOTE: in the raw gram.y output, ColumnDef, Constraint, and FkConstraint
 * nodes are intermixed in tableElts, and constraints is NIL.  After parse
 * analysis, tableElts contains just ColumnDefs, and constraints contains
 * just Constraint nodes (in fact, only CONSTR_CHECK nodes, in the present
 * implementation).
M
 
Marc G. Fournier 已提交
852 853
 * ----------------------
 */
854
typedef struct CreateStmt
M
 
Marc G. Fournier 已提交
855 856
{
	NodeTag		type;
857
	RangeVar   *relation;		/* relation to create */
858
	List	   *tableElts;		/* column definitions (list of ColumnDef) */
859
	List	   *inhRelations;	/* relations to inherit from */
860 861 862
	List	   *constraints;	/* constraints (list of Constraint nodes) */
	bool		hasoids;		/* should it have OIDs? */
} CreateStmt;
863

864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880
/* ----------
 * Definitions for plain (non-FOREIGN KEY) constraints in CreateStmt
 *
 * XXX probably these ought to be unified with FkConstraints at some point?
 *
 * For constraints that use expressions (CONSTR_DEFAULT, CONSTR_CHECK)
 * we may have the expression in either "raw" form (an untransformed
 * parse tree) or "cooked" form (the nodeToString representation of
 * an executable expression tree), depending on how this Constraint
 * node was created (by parsing, or by inheritance from an existing
 * 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
 * a pass through the constraints list to attach the info to the appropriate
 * FkConstraint node (and, perhaps, someday to other kinds of constraints).
 * ----------
881
 */
882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898

typedef enum ConstrType			/* types of constraints */
{
	CONSTR_NULL,				/* not SQL92, but a lot of people expect
								 * it */
	CONSTR_NOTNULL,
	CONSTR_DEFAULT,
	CONSTR_CHECK,
	CONSTR_PRIMARY,
	CONSTR_UNIQUE,
	CONSTR_ATTR_DEFERRABLE,		/* attributes for previous constraint node */
	CONSTR_ATTR_NOT_DEFERRABLE,
	CONSTR_ATTR_DEFERRED,
	CONSTR_ATTR_IMMEDIATE
} ConstrType;

typedef struct Constraint
899
{
900
	NodeTag		type;
901 902 903 904 905 906
	ConstrType	contype;
	char	   *name;			/* name, or NULL if unnamed */
	Node	   *raw_expr;		/* expr, as untransformed parse tree */
	char	   *cooked_expr;	/* expr, as nodeToString representation */
	List	   *keys;			/* Ident nodes naming referenced column(s) */
} Constraint;
907

908 909 910
/* ----------
 * Definitions for FOREIGN KEY constraints in CreateStmt
 * ----------
911
 */
912 913 914 915 916 917 918 919 920 921 922 923 924
#define FKCONSTR_ON_KEY_NOACTION		0x0000
#define FKCONSTR_ON_KEY_RESTRICT		0x0001
#define FKCONSTR_ON_KEY_CASCADE			0x0002
#define FKCONSTR_ON_KEY_SETNULL			0x0004
#define FKCONSTR_ON_KEY_SETDEFAULT		0x0008

#define FKCONSTR_ON_DELETE_MASK			0x000F
#define FKCONSTR_ON_DELETE_SHIFT		0

#define FKCONSTR_ON_UPDATE_MASK			0x00F0
#define FKCONSTR_ON_UPDATE_SHIFT		4

typedef struct FkConstraint
925
{
926
	NodeTag		type;
927
	char	   *constr_name;	/* Constraint name */
928
	RangeVar   *pktable;		/* Primary key table */
929 930 931 932 933 934 935
	List	   *fk_attrs;		/* Attributes of foreign key */
	List	   *pk_attrs;		/* Corresponding attrs in PK table */
	char	   *match_type;		/* FULL or PARTIAL */
	int32		actions;		/* ON DELETE/UPDATE actions */
	bool		deferrable;		/* DEFERRABLE */
	bool		initdeferred;	/* INITIALLY DEFERRED */
} FkConstraint;
936 937

/* ----------------------
938
 *		Create/Drop TRIGGER Statements
939 940
 * ----------------------
 */
941 942

typedef struct CreateTrigStmt
943
{
944
	NodeTag		type;
945
	char	   *trigname;		/* TRIGGER' name */
946
	RangeVar   *relation;		/* triggered relation */
947 948 949 950 951 952 953 954 955
	char	   *funcname;		/* function to call (or NULL) */
	List	   *args;			/* list of (T_String) Values or NULL */
	bool		before;			/* BEFORE/AFTER */
	bool		row;			/* ROW/STATEMENT */
	char		actions[4];		/* Insert, Update, Delete */
	char	   *lang;			/* currently not used, always NULL */
	char	   *text;			/* AS 'text' */
	List	   *attr;			/* UPDATE OF a, b,... (NI) or NULL */
	char	   *when;			/* WHEN 'a > 10 ...' (NI) or NULL */
956

957 958 959 960 961
	/* The following are used for referential */
	/* integrity constraint triggers */
	bool		isconstraint;	/* This is an RI trigger */
	bool		deferrable;		/* [NOT] DEFERRABLE */
	bool		initdeferred;	/* INITIALLY {DEFERRED|IMMEDIATE} */
962
	RangeVar   *constrrel;		/* opposite relation */
963 964 965
} CreateTrigStmt;

typedef struct DropTrigStmt
966
{
967
	NodeTag		type;
968
	char	   *trigname;		/* TRIGGER' name */
969
	RangeVar   *relation;		/* triggered relation */
970
} DropTrigStmt;
971

972
/* ----------------------
973
 *		Create/Drop PROCEDURAL LANGUAGE Statement
974 975
 * ----------------------
 */
976
typedef struct CreatePLangStmt
977 978
{
	NodeTag		type;
979 980 981 982 983
	char	   *plname;			/* PL name */
	char	   *plhandler;		/* PL call handler function */
	char	   *plcompiler;		/* lancompiler text */
	bool		pltrusted;		/* PL is trusted */
} CreatePLangStmt;
984

985
typedef struct DropPLangStmt
986
{
987
	NodeTag		type;
988 989
	char	   *plname;			/* PL name */
} DropPLangStmt;
990 991

/* ----------------------
992
 *	Create/Alter/Drop User Statements
993 994
 * ----------------------
 */
995
typedef struct CreateUserStmt
996
{
997
	NodeTag		type;
998 999 1000
	char	   *user;			/* PostgreSQL user login name */
	List	   *options;		/* List of DefElem nodes */
} CreateUserStmt;
1001

1002
typedef struct AlterUserStmt
1003
{
1004
	NodeTag		type;
1005 1006 1007
	char	   *user;			/* PostgreSQL user login name */
	List	   *options;		/* List of DefElem nodes */
} AlterUserStmt;
1008

1009
typedef struct AlterUserSetStmt
1010
{
1011
	NodeTag		type;
1012 1013 1014 1015
	char	   *user;
	char	   *variable;
	List	   *value;
} AlterUserSetStmt;
1016

1017
typedef struct DropUserStmt
V
Vadim B. Mikheev 已提交
1018 1019
{
	NodeTag		type;
1020 1021
	List	   *users;			/* List of users to remove */
} DropUserStmt;
V
Vadim B. Mikheev 已提交
1022

1023
/* ----------------------
1024
 *		Create/Alter/Drop Group Statements
1025 1026
 * ----------------------
 */
1027
typedef struct CreateGroupStmt
1028
{
1029
	NodeTag		type;
1030 1031 1032
	char	   *name;			/* name of the new group */
	List	   *options;		/* List of DefElem nodes */
} CreateGroupStmt;
1033

1034 1035 1036 1037 1038 1039 1040
typedef struct AlterGroupStmt
{
	NodeTag		type;
	char	   *name;			/* name of group to alter */
	int			action;			/* +1 = add, -1 = drop user */
	List	   *listUsers;		/* list of users to add/drop */
} AlterGroupStmt;
1041

1042
typedef struct DropGroupStmt
1043
{
1044 1045
	NodeTag		type;
	char	   *name;
1046
} DropGroupStmt;
1047 1048

/* ----------------------
1049
 *		Create SEQUENCE Statement
1050 1051 1052
 * ----------------------
 */

1053
typedef struct CreateSeqStmt
1054
{
1055
	NodeTag		type;
1056
	RangeVar   *sequence;		/* the sequence to create */
1057 1058
	List	   *options;
} CreateSeqStmt;
1059

1060
/* ----------------------
1061
 *		Create Version Statement
1062 1063
 * ----------------------
 */
1064
typedef struct VersionStmt
1065 1066
{
	NodeTag		type;
1067 1068 1069 1070 1071
	char	   *relname;		/* the new relation */
	int			direction;		/* FORWARD | BACKWARD */
	char	   *fromRelname;	/* relation to create a version */
	char	   *date;			/* date of the snapshot */
} VersionStmt;
1072 1073

/* ----------------------
1074
 *		Create {Operator|Type|Aggregate} Statement
1075 1076
 * ----------------------
 */
1077
typedef struct DefineStmt
1078 1079
{
	NodeTag		type;
T
Tom Lane 已提交
1080
	int			defType;		/* OPERATOR|TYPE_P|AGGREGATE */
1081 1082 1083
	char	   *defname;
	List	   *definition;		/* a list of DefElem */
} DefineStmt;
1084

T
Tom Lane 已提交
1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096
/* ----------------------
 *		Create Domain Statement
 * ----------------------
 */
typedef struct CreateDomainStmt
{
	NodeTag		type;
	char	   *domainname;			/* name of domain to create */
	TypeName   *typename;			/* the base type */
	List	   *constraints;		/* constraints (list of Constraint nodes) */
} CreateDomainStmt;

H
Hiroshi Inoue 已提交
1097
/* ----------------------
1098
 *		Drop Table|Sequence|View|Index|Rule|Type Statement
H
Hiroshi Inoue 已提交
1099 1100 1101
 * ----------------------
 */

1102 1103 1104 1105 1106
#define DROP_TABLE	  1
#define DROP_SEQUENCE 2
#define DROP_VIEW	  3
#define DROP_INDEX	  4
#define DROP_RULE	  5
T
Tom Lane 已提交
1107 1108
#define DROP_TYPE     6
#define DROP_DOMAIN	  7
1109

1110 1111 1112
typedef struct DropStmt
{
	NodeTag		type;
1113
	List	   *objects;
1114
	int			removeType;
1115
	int	   		behavior;		/* CASCADE or RESTRICT drop behavior */
1116
} DropStmt;
1117 1118

/* ----------------------
1119
 *				Truncate Table Statement
1120 1121
 * ----------------------
 */
1122
typedef struct TruncateStmt
1123
{
1124
	NodeTag		type;
1125
	RangeVar   *relation;		/* relation to be truncated */
1126
} TruncateStmt;
1127 1128

/* ----------------------
1129
 *				Comment On Statement
1130 1131
 * ----------------------
 */
1132
typedef struct CommentStmt
1133
{
1134
	NodeTag		type;
1135
	int			objtype;		/* Object's type */
1136 1137
	char	   *objschema;		/* Schema where object is defined,
								 * if object is schema specific */
1138 1139 1140 1141 1142
	char	   *objname;		/* Name of the object */
	char	   *objproperty;	/* Property Id (such as column) */
	List	   *objlist;		/* Arguments for VAL objects */
	char	   *comment;		/* The comment to insert */
} CommentStmt;
1143 1144

/* ----------------------
1145
 *		Begin Recipe Statement
1146 1147
 * ----------------------
 */
1148
typedef struct RecipeStmt
1149
{
1150
	NodeTag		type;
1151 1152
	char	   *recipeName;		/* name of the recipe */
} RecipeStmt;
1153 1154

/* ----------------------
1155
 *		Fetch Statement
1156 1157
 * ----------------------
 */
1158
typedef struct FetchStmt
1159
{
1160
	NodeTag		type;
1161 1162 1163 1164 1165
	int			direction;		/* FORWARD or BACKWARD */
	int			howMany;		/* amount to fetch ("ALL" --> 0) */
	char	   *portalname;		/* name of portal (cursor) */
	bool		ismove;			/* TRUE if MOVE */
} FetchStmt;
1166

1167
/* ----------------------
1168
 *		Create Index Statement
1169 1170
 * ----------------------
 */
1171
typedef struct IndexStmt
1172 1173
{
	NodeTag		type;
1174
	char	   *idxname;		/* name of the index */
1175
	RangeVar   *relation;		/* relation to build index on */
1176 1177 1178 1179 1180 1181 1182 1183
	char	   *accessMethod;	/* name of access method (eg. btree) */
	List	   *indexParams;	/* a list of IndexElem */
	Node	   *whereClause;	/* qualification (partial-index predicate) */
	List	   *rangetable;		/* range table for qual, filled in by
								 * transformStmt() */
	bool		unique;			/* is index unique? */
	bool		primary;		/* is index on primary key? */
} IndexStmt;
1184

1185 1186 1187
/* ----------------------
 *		Create Function Statement
 * ----------------------
1188
 */
1189
typedef struct ProcedureStmt
1190
{
1191
	NodeTag		type;
1192 1193 1194 1195 1196 1197 1198 1199
	bool		replace;		/* T => replace if already exists */
	char	   *funcname;		/* name of function to create */
	List	   *argTypes;		/* list of argument types (TypeName nodes) */
	Node	   *returnType;		/* the return type (a TypeName node) */
	List	   *withClause;		/* a list of DefElem */
	List	   *as;				/* definition of function body */
	char	   *language;		/* C, SQL, etc */
} ProcedureStmt;
1200

1201 1202 1203
/* ----------------------
 *		Drop Aggregate Statement
 * ----------------------
1204
 */
1205
typedef struct RemoveAggrStmt
1206
{
1207
	NodeTag		type;
1208 1209 1210
	char	   *aggname;		/* aggregate to drop */
	Node	   *aggtype;		/* TypeName for input datatype, or NULL */
} RemoveAggrStmt;
1211

1212 1213 1214
/* ----------------------
 *		Drop Function Statement
 * ----------------------
1215
 */
1216
typedef struct RemoveFuncStmt
1217
{
1218
	NodeTag		type;
1219 1220 1221
	char	   *funcname;		/* function to drop */
	List	   *args;			/* types of the arguments */
} RemoveFuncStmt;
1222

1223 1224 1225
/* ----------------------
 *		Drop Operator Statement
 * ----------------------
1226
 */
1227
typedef struct RemoveOperStmt
1228
{
1229
	NodeTag		type;
1230 1231 1232
	char	   *opname;			/* operator to drop */
	List	   *args;			/* types of the arguments */
} RemoveOperStmt;
1233

1234
/* ----------------------
1235
 *		Alter Table Rename Statement
1236
 * ----------------------
1237
 */
1238
typedef struct RenameStmt
1239
{
1240
	NodeTag		type;
1241
	RangeVar   *relation;		/* relation to be altered */
1242 1243 1244 1245 1246
	char	   *column;			/* if NULL, rename the relation name to
								 * the new name. Otherwise, rename this
								 * column name. */
	char	   *newname;		/* the new name */
} RenameStmt;
1247

1248 1249 1250
/* ----------------------
 *		Create Rule Statement
 * ----------------------
1251
 */
1252
typedef struct RuleStmt
1253 1254
{
	NodeTag		type;
1255
	RangeVar   *relation;		/* relation the rule is for */
1256 1257
	char	   *rulename;		/* name of the rule */
	Node	   *whereClause;	/* qualifications */
1258
	CmdType		event;			/* SELECT, INSERT, etc */
1259 1260 1261
	bool		instead;		/* is a 'do instead'? */
	List	   *actions;		/* the action statements */
} RuleStmt;
1262

1263 1264 1265
/* ----------------------
 *		Notify Statement
 * ----------------------
T
Thomas G. Lockhart 已提交
1266
 */
1267
typedef struct NotifyStmt
T
Thomas G. Lockhart 已提交
1268 1269
{
	NodeTag		type;
1270
	RangeVar   *relation;		/* qualified name to notify */
1271
} NotifyStmt;
T
Thomas G. Lockhart 已提交
1272

1273 1274 1275
/* ----------------------
 *		Listen Statement
 * ----------------------
T
Thomas G. Lockhart 已提交
1276
 */
1277
typedef struct ListenStmt
T
Thomas G. Lockhart 已提交
1278 1279
{
	NodeTag		type;
1280
	RangeVar   *relation;		/* qualified name to listen on */
1281
} ListenStmt;
T
Thomas G. Lockhart 已提交
1282

1283 1284 1285
/* ----------------------
 *		Unlisten Statement
 * ----------------------
1286
 */
1287
typedef struct UnlistenStmt
1288
{
1289
	NodeTag		type;
1290
	RangeVar   *relation;		/* qualified name to unlisten on, or '*' */
1291
} UnlistenStmt;
1292

1293 1294 1295 1296 1297
/* ----------------------
 *		{Begin|Abort|End} Transaction Statement
 * ----------------------
 */
typedef struct TransactionStmt
1298
{
1299
	NodeTag		type;
1300 1301
	int			command;		/* BEGIN|END|ABORT */
} TransactionStmt;
1302

1303 1304 1305
/* ----------------------
 *		Create View Statement
 * ----------------------
1306
 */
1307
typedef struct ViewStmt
1308
{
1309
	NodeTag		type;
1310
	RangeVar   *view;			/* the view to be created */
1311 1312 1313
	List	   *aliases;		/* target column names */
	Query	   *query;			/* the SQL statement */
} ViewStmt;
1314

1315 1316 1317 1318 1319
/* ----------------------
 *		Load Statement
 * ----------------------
 */
typedef struct LoadStmt
1320
{
1321
	NodeTag		type;
1322 1323
	char	   *filename;		/* file to load */
} LoadStmt;
1324

1325 1326 1327
/* ----------------------
 *		Createdb Statement
 * ----------------------
1328
 */
1329
typedef struct CreatedbStmt
1330
{
1331
	NodeTag		type;
1332 1333 1334 1335 1336 1337
	char	   *dbname;			/* name of database to create */
	char	   *dbowner;		/* name of owner (NULL = default) */
	char	   *dbpath;			/* location of database (NULL = default) */
	char	   *dbtemplate;		/* template to use (NULL = default) */
	int			encoding;		/* MULTIBYTE encoding (-1 = use default) */
} CreatedbStmt;
1338

1339 1340 1341
/* ----------------------
 *	Alter Database
 * ----------------------
1342
 */
1343
typedef struct AlterDatabaseSetStmt
1344
{
1345
	NodeTag		type;
1346 1347 1348 1349
	char	   *dbname;
	char	   *variable;
	List	   *value;
} AlterDatabaseSetStmt;
1350

1351 1352 1353
/* ----------------------
 *		Dropdb Statement
 * ----------------------
1354
 */
1355
typedef struct DropdbStmt
1356
{
1357
	NodeTag		type;
1358 1359
	char	   *dbname;			/* database to drop */
} DropdbStmt;
1360

1361 1362 1363
/* ----------------------
 *		Cluster Statement (support pbrown's cluster index implementation)
 * ----------------------
1364
 */
1365
typedef struct ClusterStmt
1366
{
1367
	NodeTag		type;
1368
	RangeVar   *relation;		/* relation being indexed */
1369 1370
	char	   *indexname;		/* original index defined */
} ClusterStmt;
1371

1372 1373
/* ----------------------
 *		Vacuum and Analyze Statements
1374
 *
1375 1376 1377
 * Even though these are nominally two statements, it's convenient to use
 * just one node type for both.
 * ----------------------
1378
 */
1379
typedef struct VacuumStmt
1380
{
1381
	NodeTag		type;
1382 1383 1384 1385 1386
	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 */
1387
	RangeVar   *relation;		/* single table to process, or NULL */
1388 1389
	List	   *va_cols;		/* list of column names, or NIL for all */
} VacuumStmt;
1390

1391 1392 1393
/* ----------------------
 *		Explain Statement
 * ----------------------
1394
 */
1395
typedef struct ExplainStmt
M
 
Marc G. Fournier 已提交
1396 1397
{
	NodeTag		type;
1398 1399 1400 1401
	Query	   *query;			/* the query */
	bool		verbose;		/* print plan info */
	bool		analyze;		/* get statistics by executing plan */
} ExplainStmt;
M
 
Marc G. Fournier 已提交
1402

1403 1404 1405
/* ----------------------
 * Checkpoint Statement
 * ----------------------
1406
 */
1407
typedef struct CheckPointStmt
1408
{
1409
	NodeTag		type;
1410
} CheckPointStmt;
1411

1412 1413 1414
/* ----------------------
 * Set Statement
 * ----------------------
1415
 */
1416 1417

typedef struct VariableSetStmt
1418 1419
{
	NodeTag		type;
1420 1421 1422
	char	   *name;
	List	   *args;
} VariableSetStmt;
1423

1424 1425 1426
/* ----------------------
 * Show Statement
 * ----------------------
1427
 */
1428 1429

typedef struct VariableShowStmt
1430
{
1431
	NodeTag		type;
1432 1433
	char	   *name;
} VariableShowStmt;
1434

1435 1436 1437
/* ----------------------
 * Reset Statement
 * ----------------------
1438
 */
1439 1440

typedef struct VariableResetStmt
1441
{
1442
	NodeTag		type;
1443 1444
	char	   *name;
} VariableResetStmt;
1445

1446 1447 1448
/* ----------------------
 *		LOCK Statement
 * ----------------------
1449
 */
1450
typedef struct LockStmt
1451
{
1452
	NodeTag		type;
1453
	List	   *relations;		/* relations to lock */
1454 1455
	int			mode;			/* lock mode */
} LockStmt;
1456

1457 1458 1459
/* ----------------------
 *		SET CONSTRAINTS Statement
 * ----------------------
1460
 */
1461
typedef struct ConstraintsSetStmt
1462
{
1463
	NodeTag		type;
1464 1465 1466
	List	   *constraints;	/* List of names as Value strings */
	bool		deferred;
} ConstraintsSetStmt;
B
Bruce Momjian 已提交
1467

1468 1469 1470
/* ----------------------
 *		REINDEX Statement
 * ----------------------
1471
 */
1472
typedef struct ReindexStmt
1473
{
1474
	NodeTag		type;
1475
	int			reindexType;	/* INDEX|TABLE|DATABASE */
1476 1477
	RangeVar   *relation;		/* Table or index to reindex */
	const char *name;			/* name of database to reindex */
1478 1479 1480
	bool		force;
	bool		all;
} ReindexStmt;
1481

1482
#endif   /* PARSENODES_H */