parsenodes.h 24.0 KB
Newer Older
1 2
/*-------------------------------------------------------------------------
 *
3
 * parsenodes.h
4
 *	  definitions for parse tree nodes
5 6 7 8
 *
 *
 * Copyright (c) 1994, Regents of the University of California
 *
9
 * $Id: parsenodes.h,v 1.75 1999/07/13 21:17:38 momjian Exp $
10 11 12
 *
 *-------------------------------------------------------------------------
 */
13 14
#ifndef PARSENODES_H
#define PARSENODES_H
15

16
#include <nodes/primnodes.h>
17 18

/*****************************************************************************
19
 *	Query Tree
20 21 22 23
 *****************************************************************************/

/*
 * Query -
24 25 26 27
 *	  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.
28 29 30 31 32
 *
 * we need the isPortal flag because portal names can be null too; can
 * get rid of it if we support CURSOR as a commandType.
 *
 */
33 34
typedef struct Query
{
35
	NodeTag		type;
36

37
	CmdType		commandType;	/* select|insert|update|delete|utility */
38

39
	Node	   *utilityStmt;	/* non-null if this is a non-optimizable
40 41
								 * statement */

42 43 44 45
	int			resultRelation; /* target relation (index to rtable) */
	char	   *into;			/* portal (cursor) name */
	bool		isPortal;		/* is this a retrieve into portal? */
	bool		isBinary;		/* binary portal? */
46
	bool		isTemp;			/* is 'into' a temp table? */
47
	bool		unionall;		/* union without unique sort */
48
	bool		hasAggs;		/* has aggregates in target list */
49
	bool		hasSubLinks;	/* has subquery SubLink */
50

51 52
	char	   *uniqueFlag;		/* NULL, '*', or Unique attribute name */
	List	   *sortClause;		/* a list of SortClause's */
53

54 55 56
	List	   *rtable;			/* list of range table entries */
	List	   *targetList;		/* target list (of TargetEntry) */
	Node	   *qual;			/* qualifications */
57
	List	   *rowMark;		/* list of RowMark entries */
58

59
	List	   *groupClause;	/* list of columns to specified in GROUP
60
								 * BY */
61
	Node	   *havingQual;		/* qualification of each group */
62

B
Bruce Momjian 已提交
63
	List	   *intersectClause;
B
Hi!  
Bruce Momjian 已提交
64

65 66
	List	   *unionClause;	/* unions are linked under the previous
								 * query */
B
Bruce Momjian 已提交
67 68
	Node	   *limitOffset;	/* # of result tuples to skip */
	Node	   *limitCount;		/* # of result tuples to return */
B
Bruce Momjian 已提交
69

70
	/* internal to planner */
71 72
	List	   *base_rel_list;	/* base relation list */
	List	   *join_rel_list;	/* list of relation involved in joins */
73
} Query;
74 75 76


/*****************************************************************************
77
 *		Other Statements (no optimizations required)
78
 *
79 80 81 82
 *		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.
83 84 85
 *****************************************************************************/

/* ----------------------
86
 *		Add Column Statement
87 88
 * ----------------------
 */
89 90
typedef struct AddAttrStmt
{
91 92 93
	NodeTag		type;
	char	   *relname;		/* the relation to add attr */
	bool		inh;			/* add recursively to children? */
94
	Node	   *colDef;			/* the attribute definition */
B
Bruce Momjian 已提交
95
} AddAttrStmt;
96 97

/* ----------------------
98
 *		Change ACL Statement
99 100
 * ----------------------
 */
101 102
typedef struct ChangeACLStmt
{
103
	NodeTag		type;
104
	struct AclItem *aclitem;
105 106
	unsigned	modechg;
	List	   *relNames;
107
} ChangeACLStmt;
108 109

/* ----------------------
110
 *		Close Portal Statement
111 112
 * ----------------------
 */
113 114
typedef struct ClosePortalStmt
{
115 116
	NodeTag		type;
	char	   *portalname;		/* name of the portal (cursor) */
117
} ClosePortalStmt;
118 119

/* ----------------------
120
 *		Copy Statement
121 122
 * ----------------------
 */
123 124
typedef struct CopyStmt
{
125 126 127 128 129 130 131
	NodeTag		type;
	bool		binary;			/* is a binary copy? */
	char	   *relname;		/* the relation to copy */
	bool		oids;			/* copy oid's? */
	int			direction;		/* TO or FROM */
	char	   *filename;		/* if NULL, use stdin/stdout */
	char	   *delimiter;		/* delimiter character, \t by default */
132
} CopyStmt;
133 134

/* ----------------------
135
 *		Create Table Statement
136 137
 * ----------------------
 */
138 139
typedef struct CreateStmt
{
140
	NodeTag		type;
141
	bool		istemp;			/* is this a temp table? */
142
	char	   *relname;		/* the relation to create */
143
	List	   *tableElts;		/* column definitions list of Column */
144
	List	   *inhRelnames;	/* relations to inherit from list of Value
145
								 * (string) */
146
	List	   *constraints;	/* list of constraints (ConstaintDef) */
147
} CreateStmt;
148

149
typedef enum ConstrType			/* type of constaints */
150
{
151
	CONSTR_NULL, CONSTR_NOTNULL, CONSTR_DEFAULT, CONSTR_CHECK, CONSTR_PRIMARY, CONSTR_UNIQUE
152
} ConstrType;
153

154
typedef struct Constraint
155
{
156 157
	NodeTag		type;
	ConstrType	contype;
158 159
	char	   *name;			/* name */
	void	   *def;			/* definition */
160 161
	void	   *keys;			/* list of primary keys */
} Constraint;
162

163
/* ----------------------
164
 *		Create/Drop TRIGGER Statements
165 166 167
 * ----------------------
 */

168 169
typedef struct CreateTrigStmt
{
170 171 172 173 174 175 176 177 178 179 180 181
	NodeTag		type;
	char	   *trigname;		/* TRIGGER' name */
	char	   *relname;		/* triggered relation */
	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;			/* NULL (which means Clanguage) */
	char	   *text;			/* AS 'text' */
	List	   *attr;			/* UPDATE OF a, b,... (NI) or NULL */
	char	   *when;			/* WHEN 'a > 10 ...' (NI) or NULL */
182
} CreateTrigStmt;
183

184 185
typedef struct DropTrigStmt
{
186 187 188
	NodeTag		type;
	char	   *trigname;		/* TRIGGER' name */
	char	   *relname;		/* triggered relation */
189
} DropTrigStmt;
190 191 192 193 194 195 196 197 198 199 200 201 202


/* ----------------------
 *		Create/Drop PROCEDURAL LANGUAGE Statement
 * ----------------------
 */
typedef struct CreatePLangStmt
{
	NodeTag		type;
	char	   *plname;			/* PL name */
	char	   *plhandler;		/* PL call handler function */
	char	   *plcompiler;		/* lancompiler text */
	bool		pltrusted;		/* PL is trusted */
203
} CreatePLangStmt;
204 205 206 207 208

typedef struct DropPLangStmt
{
	NodeTag		type;
	char	   *plname;			/* PL name */
209
} DropPLangStmt;
210

211

212
/* ----------------------
213
 *				Create/Alter/Drop User Statements
214 215 216 217
 * ----------------------
 */
typedef struct CreateUserStmt
{
218 219 220 221 222 223 224
	NodeTag		type;
	char	   *user;			/* PostgreSQL user login			  */
	char	   *password;		/* PostgreSQL user password			  */
	bool	   *createdb;		/* Can the user create databases?	  */
	bool	   *createuser;		/* Can this user create users?		  */
	List	   *groupElts;		/* The groups the user is a member of */
	char	   *validUntil;		/* The time the login is valid until  */
225 226
} CreateUserStmt;

227
typedef CreateUserStmt AlterUserStmt;
228 229 230

typedef struct DropUserStmt
{
231 232
	NodeTag		type;
	char	   *user;			/* PostgreSQL user login			  */
233 234 235
} DropUserStmt;


V
Vadim B. Mikheev 已提交
236
/* ----------------------
237
 *		Create SEQUENCE Statement
V
Vadim B. Mikheev 已提交
238 239 240
 * ----------------------
 */

241 242
typedef struct CreateSeqStmt
{
243 244 245
	NodeTag		type;
	char	   *seqname;		/* the relation to create */
	List	   *options;
246
} CreateSeqStmt;
V
Vadim B. Mikheev 已提交
247

248
/* ----------------------
249
 *		Create Version Statement
250 251
 * ----------------------
 */
252 253
typedef struct VersionStmt
{
254 255 256 257 258
	NodeTag		type;
	char	   *relname;		/* the new relation */
	int			direction;		/* FORWARD | BACKWARD */
	char	   *fromRelname;	/* relation to create a version */
	char	   *date;			/* date of the snapshot */
259
} VersionStmt;
260 261

/* ----------------------
262
 *		Create {Operator|Type|Aggregate} Statement
263 264
 * ----------------------
 */
265 266
typedef struct DefineStmt
{
267 268 269 270
	NodeTag		type;
	int			defType;		/* OPERATOR|P_TYPE|AGGREGATE */
	char	   *defname;
	List	   *definition;		/* a list of DefElem */
271
} DefineStmt;
272 273

/* ----------------------
274
 *		Drop Table Statement
275 276
 * ----------------------
 */
277 278
typedef struct DestroyStmt
{
279 280 281
	NodeTag		type;
	List	   *relNames;		/* relations to be dropped */
	bool		sequence;
282
} DestroyStmt;
283 284

/* ----------------------
285
 *		Extend Index Statement
286 287
 * ----------------------
 */
288 289
typedef struct ExtendStmt
{
290 291 292 293
	NodeTag		type;
	char	   *idxname;		/* name of the index */
	Node	   *whereClause;	/* qualifications */
	List	   *rangetable;		/* range table, filled in by
294
								 * transformStmt() */
295
} ExtendStmt;
296 297

/* ----------------------
298
 *		Begin Recipe Statement
299 300
 * ----------------------
 */
301 302
typedef struct RecipeStmt
{
303 304
	NodeTag		type;
	char	   *recipeName;		/* name of the recipe */
305
} RecipeStmt;
306 307

/* ----------------------
308
 *		Fetch Statement
309 310
 * ----------------------
 */
311 312
typedef struct FetchStmt
{
313 314 315 316
	NodeTag		type;
	int			direction;		/* FORWARD or BACKWARD */
	int			howMany;		/* amount to fetch ("ALL" --> 0) */
	char	   *portalname;		/* name of portal (cursor) */
317
	bool		ismove;			/* TRUE if MOVE */
318
} FetchStmt;
319 320

/* ----------------------
321
 *		Create Index Statement
322 323
 * ----------------------
 */
324 325
typedef struct IndexStmt
{
326 327 328 329 330 331 332 333
	NodeTag		type;
	char	   *idxname;		/* name of the index */
	char	   *relname;		/* name of relation to index on */
	char	   *accessMethod;	/* name of acess methood (eg. btree) */
	List	   *indexParams;	/* a list of IndexElem */
	List	   *withClause;		/* a list of ParamString */
	Node	   *whereClause;	/* qualifications */
	List	   *rangetable;		/* range table, filled in by
334
								 * transformStmt() */
335 336
	bool	   *lossy;			/* is index lossy? */
	bool		unique;			/* is index unique? */
337
	bool		primary;		/* is index on primary key? */
338
} IndexStmt;
339 340

/* ----------------------
341
 *		Create Function Statement
342 343
 * ----------------------
 */
344 345
typedef struct ProcedureStmt
{
346 347 348
	NodeTag		type;
	char	   *funcname;		/* name of function to create */
	List	   *defArgs;		/* list of definitions a list of strings
349
								 * (as Value *) */
350
	Node	   *returnType;		/* the return type (as a string or a
351
								 * TypeName (ie.setof) */
352 353 354
	List	   *withClause;		/* a list of ParamString */
	char	   *as;				/* the SQL statement or filename */
	char	   *language;		/* C or SQL */
355
} ProcedureStmt;
356

357
/* ----------------------
358
 *		Drop Aggregate Statement
359 360
 * ----------------------
 */
361 362
typedef struct RemoveAggrStmt
{
363 364 365
	NodeTag		type;
	char	   *aggname;		/* aggregate to drop */
	char	   *aggtype;		/* for this type */
366
} RemoveAggrStmt;
367

368
/* ----------------------
369
 *		Drop Function Statement
370 371
 * ----------------------
 */
372 373
typedef struct RemoveFuncStmt
{
374 375 376
	NodeTag		type;
	char	   *funcname;		/* function to drop */
	List	   *args;			/* types of the arguments */
377
} RemoveFuncStmt;
378 379

/* ----------------------
380
 *		Drop Operator Statement
381 382
 * ----------------------
 */
383 384
typedef struct RemoveOperStmt
{
385 386 387
	NodeTag		type;
	char	   *opname;			/* operator to drop */
	List	   *args;			/* types of the arguments */
388
} RemoveOperStmt;
389 390

/* ----------------------
391
 *		Drop {Type|Index|Rule|View} Statement
392 393
 * ----------------------
 */
394 395
typedef struct RemoveStmt
{
396 397 398
	NodeTag		type;
	int			removeType;		/* P_TYPE|INDEX|RULE|VIEW */
	char	   *name;			/* name to drop */
399
} RemoveStmt;
400 401

/* ----------------------
402
 *		Alter Table Statement
403 404
 * ----------------------
 */
405 406
typedef struct RenameStmt
{
407 408 409 410
	NodeTag		type;
	char	   *relname;		/* relation to be altered */
	bool		inh;			/* recursively alter children? */
	char	   *column;			/* if NULL, rename the relation name to
411 412
								 * the new name. Otherwise, rename this
								 * column name. */
413
	char	   *newname;		/* the new name */
414
} RenameStmt;
415 416

/* ----------------------
417
 *		Create Rule Statement
418 419
 * ----------------------
 */
420 421
typedef struct RuleStmt
{
422 423 424 425 426 427 428
	NodeTag		type;
	char	   *rulename;		/* name of the rule */
	Node	   *whereClause;	/* qualifications */
	CmdType		event;			/* RETRIEVE */
	struct Attr *object;		/* object affected */
	bool		instead;		/* is a 'do instead'? */
	List	   *actions;		/* the action statements */
429
} RuleStmt;
430 431

/* ----------------------
432
 *		Notify Statement
433 434
 * ----------------------
 */
435 436
typedef struct NotifyStmt
{
437 438
	NodeTag		type;
	char	   *relname;		/* relation to notify */
439
} NotifyStmt;
440 441

/* ----------------------
442
 *		Listen Statement
443 444
 * ----------------------
 */
445 446
typedef struct ListenStmt
{
447 448
	NodeTag		type;
	char	   *relname;		/* relation to listen on */
449
} ListenStmt;
M
 
Marc G. Fournier 已提交
450 451 452 453 454 455 456 457 458

/* ----------------------
 *		Unlisten Statement
 * ----------------------
 */
typedef struct UnlistenStmt
{
	NodeTag		type;
	char	   *relname;		/* relation to unlisten on */
459
} UnlistenStmt;
460 461

/* ----------------------
462
 *		{Begin|Abort|End} Transaction Statement
463 464
 * ----------------------
 */
465 466
typedef struct TransactionStmt
{
467 468
	NodeTag		type;
	int			command;		/* BEGIN|END|ABORT */
469
} TransactionStmt;
470 471

/* ----------------------
472
 *		Create View Statement
473 474
 * ----------------------
 */
475 476
typedef struct ViewStmt
{
477 478 479
	NodeTag		type;
	char	   *viewname;		/* name of the view */
	Query	   *query;			/* the SQL statement */
480
} ViewStmt;
481 482

/* ----------------------
483
 *		Load Statement
484 485
 * ----------------------
 */
486 487
typedef struct LoadStmt
{
488 489
	NodeTag		type;
	char	   *filename;		/* file to load */
490
} LoadStmt;
491 492

/* ----------------------
493
 *		Createdb Statement
494 495
 * ----------------------
 */
496 497
typedef struct CreatedbStmt
{
498 499
	NodeTag		type;
	char	   *dbname;			/* database to create */
500
	char	   *dbpath;			/* location of database */
501
	int			encoding;		/* default encoding (see regex/pg_wchar.h) */
502
} CreatedbStmt;
503 504

/* ----------------------
505
 *		Destroydb Statement
506 507
 * ----------------------
 */
508 509
typedef struct DestroydbStmt
{
510 511
	NodeTag		type;
	char	   *dbname;			/* database to drop */
512
} DestroydbStmt;
513 514

/* ----------------------
515
 *		Cluster Statement (support pbrown's cluster index implementation)
516 517
 * ----------------------
 */
518 519
typedef struct ClusterStmt
{
520 521 522
	NodeTag		type;
	char	   *relname;		/* relation being indexed */
	char	   *indexname;		/* original index defined */
523
} ClusterStmt;
524 525

/* ----------------------
526
 *		Vacuum Statement
527 528
 * ----------------------
 */
529 530
typedef struct VacuumStmt
{
531 532 533 534 535
	NodeTag		type;
	bool		verbose;		/* print status info */
	bool		analyze;		/* analyze data */
	char	   *vacrel;			/* table to vacuum */
	List	   *va_spec;		/* columns to analyse */
536
} VacuumStmt;
537 538

/* ----------------------
539
 *		Explain Statement
540 541
 * ----------------------
 */
542 543
typedef struct ExplainStmt
{
544 545 546
	NodeTag		type;
	Query	   *query;			/* the query */
	bool		verbose;		/* print plan info */
547
} ExplainStmt;
548

549 550 551 552 553
/* ----------------------
 * Set Statement
 * ----------------------
 */

554 555
typedef struct VariableSetStmt
{
556 557 558
	NodeTag		type;
	char	   *name;
	char	   *value;
559
} VariableSetStmt;
560 561 562 563 564 565

/* ----------------------
 * Show Statement
 * ----------------------
 */

566 567
typedef struct VariableShowStmt
{
568 569
	NodeTag		type;
	char	   *name;
570
} VariableShowStmt;
571 572 573 574 575 576

/* ----------------------
 * Reset Statement
 * ----------------------
 */

577 578
typedef struct VariableResetStmt
{
579 580
	NodeTag		type;
	char	   *name;
581
} VariableResetStmt;
582

583 584 585 586 587 588 589 590 591
/* ----------------------
 *		LOCK Statement
 * ----------------------
 */
typedef struct LockStmt
{
	NodeTag		type;
	char	   *relname;		/* relation to lock */
	int			mode;			/* lock mode */
592
} LockStmt;
593 594

/*****************************************************************************
595
 *		Optimizable Statements
596 597 598
 *****************************************************************************/

/* ----------------------
599
 *		Insert Statement
600 601
 * ----------------------
 */
B
Bruce Momjian 已提交
602
typedef struct InsertStmt
603
{
604 605
	NodeTag		type;
	char	   *relname;		/* relation to insert into */
606
	char	   *unique;			/* NULL, '*', or unique attribute name */
607 608 609 610
	List	   *cols;			/* names of the columns */
	List	   *targetList;		/* the target list (of ResTarget) */
	List	   *fromClause;		/* the from clause */
	Node	   *whereClause;	/* qualifications */
611 612 613
	List	   *groupClause;	/* group by clause */
	Node	   *havingClause;	/* having conditional-expression */
	List	   *unionClause;	/* union subselect parameters */
614
	bool		unionall;		/* union without unique sort */
B
Bruce Momjian 已提交
615
	List	   *intersectClause;
616
	List	   *forUpdate;		/* FOR UPDATE clause */
B
Bruce Momjian 已提交
617
} InsertStmt;
618 619

/* ----------------------
620
 *		Delete Statement
621 622
 * ----------------------
 */
623 624
typedef struct DeleteStmt
{
625 626 627
	NodeTag		type;
	char	   *relname;		/* relation to delete from */
	Node	   *whereClause;	/* qualifications */
628
} DeleteStmt;
629 630

/* ----------------------
631
 *		Update Statement
632 633
 * ----------------------
 */
B
Bruce Momjian 已提交
634
typedef struct UpdateStmt
635
{
636 637 638 639 640
	NodeTag		type;
	char	   *relname;		/* relation to update */
	List	   *targetList;		/* the target list (of ResTarget) */
	Node	   *whereClause;	/* qualifications */
	List	   *fromClause;		/* the from clause */
B
Bruce Momjian 已提交
641
} UpdateStmt;
642 643

/* ----------------------
644
 *		Select Statement
645 646
 * ----------------------
 */
B
Bruce Momjian 已提交
647
typedef struct SelectStmt
648
{
649 650 651 652 653 654 655 656
	NodeTag		type;
	char	   *unique;			/* NULL, '*', or unique attribute name */
	char	   *into;			/* name of table (for select into table) */
	List	   *targetList;		/* the target list (of ResTarget) */
	List	   *fromClause;		/* the from clause */
	Node	   *whereClause;	/* qualifications */
	List	   *groupClause;	/* group by clause */
	Node	   *havingClause;	/* having conditional-expression */
657 658 659
	List	   *intersectClause;
	List	   *exceptClause;

660
	List	   *unionClause;	/* union subselect parameters */
661
	List	   *sortClause;		/* sort clause (a list of SortGroupBy's) */
662 663
	char	   *portalname;		/* the portal (cursor) to create */
	bool		binary;			/* a binary (internal) portal? */
664
	bool		istemp;			/* into is a temp table */
665
	bool		unionall;		/* union without unique sort */
B
Bruce Momjian 已提交
666 667
	Node	   *limitOffset;	/* # of result tuples to skip */
	Node	   *limitCount;		/* # of result tuples to return */
V
Vadim B. Mikheev 已提交
668
	List	   *forUpdate;		/* FOR UPDATE clause */
B
Bruce Momjian 已提交
669
} SelectStmt;
670 671

/****************************************************************************
672
 *	Supporting data structures for Parse Trees
673 674 675 676 677
 ****************************************************************************/

/*
 * TypeName - specifies a type in definitions
 */
678 679
typedef struct TypeName
{
680 681 682 683
	NodeTag		type;
	char	   *name;			/* name of the type */
	bool		timezone;		/* timezone specified? */
	bool		setof;			/* is a set? */
684
	int32		typmod;			/* type modifier */
685
	List	   *arrayBounds;	/* array bounds */
686
} TypeName;
687 688 689 690

/*
 * ParamNo - specifies a parameter reference
 */
691 692
typedef struct ParamNo
{
693 694 695
	NodeTag		type;
	int			number;			/* the number of the parameter */
	TypeName   *typename;		/* the typecast */
696
	List	   *indirection;	/* array references */
697
} ParamNo;
698 699 700 701

/*
 * A_Expr - binary expressions
 */
702 703
typedef struct A_Expr
{
704 705
	NodeTag		type;
	int			oper;			/* type of operation
706
								 * {OP,OR,AND,NOT,ISNULL,NOTNULL} */
707 708 709
	char	   *opname;			/* name of operator/function */
	Node	   *lexpr;			/* left argument */
	Node	   *rexpr;			/* right argument */
B
Bruce Momjian 已提交
710
} A_Expr;
711 712 713

/*
 * Attr -
714 715
 *	  specifies an Attribute (ie. a Column); could have nested dots or
 *	  array references.
716 717
 *
 */
718 719
typedef struct Attr
{
720 721 722 723
	NodeTag		type;
	char	   *relname;		/* name of relation (can be "*") */
	ParamNo    *paramNo;		/* or a parameter */
	List	   *attrs;			/* attributes (possibly nested); list of
724
								 * Values (strings) */
725
	List	   *indirection;	/* array refs (list of A_Indices') */
B
Bruce Momjian 已提交
726
} Attr;
727 728 729 730

/*
 * A_Const - a constant expression
 */
731 732
typedef struct A_Const
{
733 734 735
	NodeTag		type;
	Value		val;			/* the value (with the tag) */
	TypeName   *typename;		/* typecast */
B
Bruce Momjian 已提交
736
} A_Const;
737

T
Thomas G. Lockhart 已提交
738 739 740 741 742 743 744 745 746 747
/*
 * CaseExpr - a CASE expression
 */
typedef struct CaseExpr
{
	NodeTag		type;
	Oid			casetype;
	Node	   *arg;			/* implicit equality comparison argument */
	List	   *args;			/* the arguments (list of WHEN clauses) */
	Node	   *defresult;		/* the default result (ELSE clause) */
748
} CaseExpr;
T
Thomas G. Lockhart 已提交
749 750 751 752 753 754 755 756 757

/*
 * CaseWhen - an argument to a CASE expression
 */
typedef struct CaseWhen
{
	NodeTag		type;
	Node	   *expr;			/* comparison expression */
	Node	   *result;			/* substitution result */
758
} CaseWhen;
T
Thomas G. Lockhart 已提交
759

760 761 762
/*
 * ColumnDef - column definition (used in various creates)
 */
763 764
typedef struct ColumnDef
{
765 766 767 768
	NodeTag		type;
	char	   *colname;		/* name of column */
	TypeName   *typename;		/* type of column */
	bool		is_not_null;	/* flag to NOT NULL constraint */
769
	bool		is_sequence;	/* is a sequence? */
770
	char	   *defval;			/* default value of column */
771 772
	List	   *constraints;	/* constraints on column */
} ColumnDef;
773 774

/*
775 776 777 778 779 780 781 782
 * Ident -
 *	  an identifier (could be an attribute or a relation name). Depending
 *	  on the context at transformStmt time, the identifier is treated as
 *	  either a relation name (in which case, isRel will be set) or an
 *	  attribute (in which case, it will be transformed into an Attr).
 */
typedef struct Ident
{
783 784 785 786
	NodeTag		type;
	char	   *name;			/* its name */
	List	   *indirection;	/* array references */
	bool		isRel;			/* is a relation - filled in by
787
								 * transformExpr() */
788
} Ident;
789 790 791 792

/*
 * FuncCall - a function/aggregate invocation
 */
793 794
typedef struct FuncCall
{
795 796 797
	NodeTag		type;
	char	   *funcname;		/* name of function */
	List	   *args;			/* the arguments (list of exprs) */
798
} FuncCall;
799 800 801 802

/*
 * A_Indices - array reference or bounds ([lidx:uidx] or [uidx])
 */
803 804
typedef struct A_Indices
{
805 806 807
	NodeTag		type;
	Node	   *lidx;			/* could be NULL */
	Node	   *uidx;
B
Bruce Momjian 已提交
808
} A_Indices;
809 810

/*
811 812 813 814 815
 * ResTarget -
 *	  result target (used in target list of pre-transformed Parse trees)
 */
typedef struct ResTarget
{
816 817 818 819
	NodeTag		type;
	char	   *name;			/* name of the result column */
	List	   *indirection;	/* array references */
	Node	   *val;			/* the value of the result (A_Expr or
820
								 * Attr) (or A_Const) */
821
} ResTarget;
822 823

/*
T
Thomas G. Lockhart 已提交
824
 * ParamString - used in WITH clauses
825
 */
826 827
typedef struct ParamString
{
828 829 830
	NodeTag		type;
	char	   *name;
	char	   *val;
831
} ParamString;
832 833 834 835

/*
 * RelExpr - relation expressions
 */
836 837
typedef struct RelExpr
{
838 839 840
	NodeTag		type;
	char	   *relname;		/* the relation name */
	bool		inh;			/* inheritance query */
841
} RelExpr;
842 843

/*
T
Thomas G. Lockhart 已提交
844
 * SortGroupBy - for ORDER BY clause
845
 */
846
typedef struct SortGroupBy
M
 
Marc G. Fournier 已提交
847 848 849
{
	NodeTag		type;
	char	   *useOp;			/* operator to use */
850
	Node	   *node;			/* Expression  */
M
 
Marc G. Fournier 已提交
851 852
} SortGroupBy;

853
/*
T
Thomas G. Lockhart 已提交
854
 * RangeVar - range variable, used in FROM clauses
855
 */
856 857
typedef struct RangeVar
{
858 859 860
	NodeTag		type;
	RelExpr    *relExpr;		/* the relation expression */
	char	   *name;			/* the name to be referenced (optional) */
861
} RangeVar;
862 863

/*
T
Thomas G. Lockhart 已提交
864
 * IndexElem - index parameters (used in CREATE INDEX)
865
 */
866 867
typedef struct IndexElem
{
868 869 870 871
	NodeTag		type;
	char	   *name;			/* name of index */
	List	   *args;			/* if not NULL, function index */
	char	   *class;
872
	TypeName   *typename;		/* type of index's keys (optional) */
873
} IndexElem;
874 875 876

/*
 * DefElem -
877
 *	  a definition (used in definition lists in the form of defname = arg)
878
 */
879 880
typedef struct DefElem
{
881 882 883
	NodeTag		type;
	char	   *defname;
	Node	   *arg;			/* a (Value *) or a (TypeName *) */
884
} DefElem;
885

886 887 888 889 890 891 892 893 894 895
/*
 * JoinExpr - for JOIN expressions
 */
typedef struct JoinExpr
{
	NodeTag		type;
	int			jointype;
	RangeVar   *larg;
	Node	   *rarg;
	List	   *quals;
896
} JoinExpr;
897

898 899

/****************************************************************************
900
 *	Nodes for a Query tree
901 902 903 904
 ****************************************************************************/

/*
 * TargetEntry -
905
 *	   a target  entry (used in the transformed target list)
906 907
 *
 * one of resdom or fjoin is not NULL. a target list is
908
 *		((<resdom | fjoin> expr) (<resdom | fjoin> expr) ...)
909
 */
910 911
typedef struct TargetEntry
{
912 913 914 915
	NodeTag		type;
	Resdom	   *resdom;			/* fjoin overload this to be a list?? */
	Fjoin	   *fjoin;
	Node	   *expr;			/* can be a list too */
916
} TargetEntry;
917 918 919

/*
 * RangeTblEntry -
920 921
 *	  used in range tables. Some of the following are only used in one of
 *	  the parsing, optimizing, execution stages.
922
 *
923 924 925 926 927 928 929 930 931
 *	  inFromCl marks those range variables that are listed in the from clause.
 *	  In SQL, the targetlist can only refer to range variables listed in the
 *	  from clause but POSTQUEL allows you to refer to tables not specified, in
 *	  which case a range table entry will be generated. We use POSTQUEL
 *	  semantics which is more powerful. However, we need SQL semantics in
 *	  some cases (eg. when expanding a '*')
 */
typedef struct RangeTblEntry
{
932 933 934
	NodeTag		type;
	char	   *relname;		/* real name of the relation */
	char	   *refname;		/* the reference name (specified in the
935
								 * from clause) */
936 937 938
	Oid			relid;
	bool		inh;			/* inheritance? */
	bool		inFromCl;		/* comes from From Clause */
M
Marc G. Fournier 已提交
939
	bool		skipAcl;		/* skip ACL check in executor */
940
} RangeTblEntry;
941 942 943

/*
 * SortClause -
944
 *	   used in the sort clause for retrieves and cursors
945
 */
946 947
typedef struct SortClause
{
948 949 950
	NodeTag		type;
	Resdom	   *resdom;			/* attributes in tlist to be sorted */
	Oid			opoid;			/* sort operators */
951
} SortClause;
952 953 954

/*
 * GroupClause -
955
 *	   used in the GROUP BY clause
956
 */
957 958
typedef struct GroupClause
{
959 960
	NodeTag		type;
	Oid			grpOpoid;		/* the sort operator to use */
961
	Index		tleGroupref;	/* reference into targetlist */
962
} GroupClause;
963

B
Bruce Momjian 已提交
964 965
#define ROW_MARK_FOR_UPDATE		(1 << 0)
#define ROW_ACL_FOR_UPDATE		(1 << 1)
966 967 968

typedef struct RowMark
{
B
Bruce Momjian 已提交
969 970 971
	NodeTag		type;
	Index		rti;			/* index in Query->rtable */
	bits8		info;			/* as above */
972
} RowMark;
973

974
#endif	 /* PARSENODES_H */