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
 *
B
Bruce Momjian 已提交
9
 * $Id: parsenodes.h,v 1.73 1999/05/25 16:14:09 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 64
	/***S*I***/
	List	   *intersectClause;
B
Hi!  
Bruce Momjian 已提交
65

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

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


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

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

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

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

/* ----------------------
121
 *		Copy Statement
122 123
 * ----------------------
 */
124 125
typedef struct CopyStmt
{
126 127 128 129 130 131 132
	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 */
133
} CopyStmt;
134 135

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

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

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

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

169 170
typedef struct CreateTrigStmt
{
171 172 173 174 175 176 177 178 179 180 181 182
	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 */
183
} CreateTrigStmt;
184

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


/* ----------------------
 *		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 */
204
} CreatePLangStmt;
205 206 207 208 209

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

212

213
/* ----------------------
214
 *				Create/Alter/Drop User Statements
215 216 217 218
 * ----------------------
 */
typedef struct CreateUserStmt
{
219 220 221 222 223 224 225
	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  */
226 227
} CreateUserStmt;

228
typedef CreateUserStmt AlterUserStmt;
229 230 231

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


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

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

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

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

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

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

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

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

/* ----------------------
322
 *		Create Index Statement
323 324
 * ----------------------
 */
325 326
typedef struct IndexStmt
{
327 328 329 330 331 332 333 334
	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
335
								 * transformStmt() */
336 337
	bool	   *lossy;			/* is index lossy? */
	bool		unique;			/* is index unique? */
338
	bool		primary;		/* is index on primary key? */
339
} IndexStmt;
340 341

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

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

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

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

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

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

/* ----------------------
418
 *		Create Rule Statement
419 420
 * ----------------------
 */
421 422
typedef struct RuleStmt
{
423 424 425 426 427 428 429
	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 */
430
} RuleStmt;
431 432

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

584 585 586 587 588 589 590 591 592
/* ----------------------
 *		LOCK Statement
 * ----------------------
 */
typedef struct LockStmt
{
	NodeTag		type;
	char	   *relname;		/* relation to lock */
	int			mode;			/* lock mode */
B
Bruce Momjian 已提交
593
}			LockStmt;
594 595

/*****************************************************************************
596
 *		Optimizable Statements
597 598 599
 *****************************************************************************/

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

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

/* ----------------------
633
 *		Update Statement
634 635
 * ----------------------
 */
B
Bruce Momjian 已提交
636
typedef struct UpdateStmt
637
{
638 639 640 641 642
	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 已提交
643
} UpdateStmt;
644 645

/* ----------------------
646
 *		Select Statement
647 648
 * ----------------------
 */
B
Bruce Momjian 已提交
649
typedef struct SelectStmt
650
{
651 652 653 654 655 656 657 658
	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 */
659 660 661 662
	/***S*I***/
	List	   *intersectClause;
	List	   *exceptClause;

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

/****************************************************************************
675
 *	Supporting data structures for Parse Trees
676 677 678 679 680
 ****************************************************************************/

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

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

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

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

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

T
Thomas G. Lockhart 已提交
741 742 743 744 745 746 747 748 749 750
/*
 * 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) */
B
Bruce Momjian 已提交
751
}			CaseExpr;
T
Thomas G. Lockhart 已提交
752 753 754 755 756 757 758 759 760

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

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

/*
778 779 780 781 782 783 784 785
 * 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
{
786 787 788 789
	NodeTag		type;
	char	   *name;			/* its name */
	List	   *indirection;	/* array references */
	bool		isRel;			/* is a relation - filled in by
790
								 * transformExpr() */
791
} Ident;
792 793 794 795

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

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

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

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

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

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

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

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

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

889 890 891 892 893 894 895 896 897 898
/*
 * JoinExpr - for JOIN expressions
 */
typedef struct JoinExpr
{
	NodeTag		type;
	int			jointype;
	RangeVar   *larg;
	Node	   *rarg;
	List	   *quals;
B
Bruce Momjian 已提交
899
}			JoinExpr;
900

901 902

/****************************************************************************
903
 *	Nodes for a Query tree
904 905 906 907
 ****************************************************************************/

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

/*
 * RangeTblEntry -
923 924
 *	  used in range tables. Some of the following are only used in one of
 *	  the parsing, optimizing, execution stages.
925
 *
926 927 928 929 930 931 932 933 934
 *	  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
{
935 936 937
	NodeTag		type;
	char	   *relname;		/* real name of the relation */
	char	   *refname;		/* the reference name (specified in the
938
								 * from clause) */
939 940 941
	Oid			relid;
	bool		inh;			/* inheritance? */
	bool		inFromCl;		/* comes from From Clause */
M
Marc G. Fournier 已提交
942
	bool		skipAcl;		/* skip ACL check in executor */
943
} RangeTblEntry;
944 945 946

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

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

B
Bruce Momjian 已提交
967 968
#define ROW_MARK_FOR_UPDATE		(1 << 0)
#define ROW_ACL_FOR_UPDATE		(1 << 1)
969 970 971

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

977
#endif	 /* PARSENODES_H */