parsenodes.h 22.4 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.59 1998/09/01 04:36:43 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		unionall;		/* union without unique sort */
47
	bool		hasAggs;		/* has aggregates in target list */
48
	bool		hasSubLinks;	/* has subquery SubLink */
49

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

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

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

61 62
	List	   *unionClause;	/* unions are linked under the previous
								 * query */
B
Bruce Momjian 已提交
63

64
	/* internal to planner */
65 66
	List	   *base_rel_list;	/* base relation list */
	List	   *join_rel_list;	/* list of relation involved in joins */
67
} Query;
68 69 70


/*****************************************************************************
71
 *		Other Statements (no optimizations required)
72
 *
73 74 75 76
 *		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.
77 78 79
 *****************************************************************************/

/* ----------------------
80
 *		Add Column Statement
81 82
 * ----------------------
 */
83 84
typedef struct AddAttrStmt
{
85 86 87
	NodeTag		type;
	char	   *relname;		/* the relation to add attr */
	bool		inh;			/* add recursively to children? */
88
	Node	   *colDef;			/* the attribute definition */
B
Bruce Momjian 已提交
89
} AddAttrStmt;
90 91

/* ----------------------
92
 *		Change ACL Statement
93 94
 * ----------------------
 */
95 96
typedef struct ChangeACLStmt
{
97
	NodeTag		type;
98
	struct AclItem *aclitem;
99 100
	unsigned	modechg;
	List	   *relNames;
101
} ChangeACLStmt;
102 103

/* ----------------------
104
 *		Close Portal Statement
105 106
 * ----------------------
 */
107 108
typedef struct ClosePortalStmt
{
109 110
	NodeTag		type;
	char	   *portalname;		/* name of the portal (cursor) */
111
} ClosePortalStmt;
112 113

/* ----------------------
114
 *		Copy Statement
115 116
 * ----------------------
 */
117 118
typedef struct CopyStmt
{
119 120 121 122 123 124 125
	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 */
126
} CopyStmt;
127 128

/* ----------------------
129
 *		Create Table Statement
130 131
 * ----------------------
 */
132 133
typedef struct CreateStmt
{
134 135
	NodeTag		type;
	char	   *relname;		/* the relation to create */
136
	List	   *tableElts;		/* column definitions list of Column */
137
	List	   *inhRelnames;	/* relations to inherit from list of Value
138
								 * (string) */
139
	List	   *constraints;	/* list of constraints (ConstaintDef) */
140
} CreateStmt;
141

142
typedef enum ConstrType			/* type of constaints */
143
{
144 145
	CONSTR_NONE, CONSTR_NOTNULL, CONSTR_DEFAULT, CONSTR_CHECK, CONSTR_PRIMARY, CONSTR_UNIQUE
} ConstrType;
146

147
typedef struct Constraint
148
{
149 150
	NodeTag		type;
	ConstrType	contype;
151 152
	char	   *name;			/* name */
	void	   *def;			/* definition */
153 154
	void	   *keys;			/* list of primary keys */
} Constraint;
155

156
/* ----------------------
157
 *		Create/Drop TRIGGER Statements
158 159 160
 * ----------------------
 */

161 162
typedef struct CreateTrigStmt
{
163 164 165 166 167 168 169 170 171 172 173 174
	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 */
175
} CreateTrigStmt;
176

177 178
typedef struct DropTrigStmt
{
179 180 181
	NodeTag		type;
	char	   *trigname;		/* TRIGGER' name */
	char	   *relname;		/* triggered relation */
182
} DropTrigStmt;
183 184 185 186 187 188 189 190 191 192 193 194 195


/* ----------------------
 *		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 */
196
} CreatePLangStmt;
197 198 199 200 201

typedef struct DropPLangStmt
{
	NodeTag		type;
	char	   *plname;			/* PL name */
202
} DropPLangStmt;
203

204

205
/* ----------------------
206
 *				Create/Alter/Drop User Statements
207 208 209 210
 * ----------------------
 */
typedef struct CreateUserStmt
{
211 212 213 214 215 216 217
	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  */
218 219
} CreateUserStmt;

220
typedef CreateUserStmt AlterUserStmt;
221 222 223

typedef struct DropUserStmt
{
224 225
	NodeTag		type;
	char	   *user;			/* PostgreSQL user login			  */
226 227 228
} DropUserStmt;


V
Vadim B. Mikheev 已提交
229
/* ----------------------
230
 *		Create SEQUENCE Statement
V
Vadim B. Mikheev 已提交
231 232 233
 * ----------------------
 */

234 235
typedef struct CreateSeqStmt
{
236 237 238
	NodeTag		type;
	char	   *seqname;		/* the relation to create */
	List	   *options;
239
} CreateSeqStmt;
V
Vadim B. Mikheev 已提交
240

241
/* ----------------------
242
 *		Create Version Statement
243 244
 * ----------------------
 */
245 246
typedef struct VersionStmt
{
247 248 249 250 251
	NodeTag		type;
	char	   *relname;		/* the new relation */
	int			direction;		/* FORWARD | BACKWARD */
	char	   *fromRelname;	/* relation to create a version */
	char	   *date;			/* date of the snapshot */
252
} VersionStmt;
253 254

/* ----------------------
255
 *		Create {Operator|Type|Aggregate} Statement
256 257
 * ----------------------
 */
258 259
typedef struct DefineStmt
{
260 261 262 263
	NodeTag		type;
	int			defType;		/* OPERATOR|P_TYPE|AGGREGATE */
	char	   *defname;
	List	   *definition;		/* a list of DefElem */
264
} DefineStmt;
265 266

/* ----------------------
267
 *		Drop Table Statement
268 269
 * ----------------------
 */
270 271
typedef struct DestroyStmt
{
272 273 274
	NodeTag		type;
	List	   *relNames;		/* relations to be dropped */
	bool		sequence;
275
} DestroyStmt;
276 277

/* ----------------------
278
 *		Extend Index Statement
279 280
 * ----------------------
 */
281 282
typedef struct ExtendStmt
{
283 284 285 286
	NodeTag		type;
	char	   *idxname;		/* name of the index */
	Node	   *whereClause;	/* qualifications */
	List	   *rangetable;		/* range table, filled in by
287
								 * transformStmt() */
288
} ExtendStmt;
289 290

/* ----------------------
291
 *		Begin Recipe Statement
292 293
 * ----------------------
 */
294 295
typedef struct RecipeStmt
{
296 297
	NodeTag		type;
	char	   *recipeName;		/* name of the recipe */
298
} RecipeStmt;
299 300

/* ----------------------
301
 *		Fetch Statement
302 303
 * ----------------------
 */
304 305
typedef struct FetchStmt
{
306 307 308 309
	NodeTag		type;
	int			direction;		/* FORWARD or BACKWARD */
	int			howMany;		/* amount to fetch ("ALL" --> 0) */
	char	   *portalname;		/* name of portal (cursor) */
310
	bool		ismove;			/* TRUE if MOVE */
311
} FetchStmt;
312 313

/* ----------------------
314
 *		Create Index Statement
315 316
 * ----------------------
 */
317 318
typedef struct IndexStmt
{
319 320 321 322 323 324 325 326
	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
327
								 * transformStmt() */
328 329
	bool	   *lossy;			/* is index lossy? */
	bool		unique;			/* is index unique? */
330
} IndexStmt;
331 332

/* ----------------------
333
 *		Create Function Statement
334 335
 * ----------------------
 */
336 337
typedef struct ProcedureStmt
{
338 339 340
	NodeTag		type;
	char	   *funcname;		/* name of function to create */
	List	   *defArgs;		/* list of definitions a list of strings
341
								 * (as Value *) */
342
	Node	   *returnType;		/* the return type (as a string or a
343
								 * TypeName (ie.setof) */
344 345 346
	List	   *withClause;		/* a list of ParamString */
	char	   *as;				/* the SQL statement or filename */
	char	   *language;		/* C or SQL */
347
} ProcedureStmt;
348

349
/* ----------------------
350
 *		Drop Aggregate Statement
351 352
 * ----------------------
 */
353 354
typedef struct RemoveAggrStmt
{
355 356 357
	NodeTag		type;
	char	   *aggname;		/* aggregate to drop */
	char	   *aggtype;		/* for this type */
358
} RemoveAggrStmt;
359

360
/* ----------------------
361
 *		Drop Function Statement
362 363
 * ----------------------
 */
364 365
typedef struct RemoveFuncStmt
{
366 367 368
	NodeTag		type;
	char	   *funcname;		/* function to drop */
	List	   *args;			/* types of the arguments */
369
} RemoveFuncStmt;
370 371

/* ----------------------
372
 *		Drop Operator Statement
373 374
 * ----------------------
 */
375 376
typedef struct RemoveOperStmt
{
377 378 379
	NodeTag		type;
	char	   *opname;			/* operator to drop */
	List	   *args;			/* types of the arguments */
380
} RemoveOperStmt;
381 382

/* ----------------------
383
 *		Drop {Type|Index|Rule|View} Statement
384 385
 * ----------------------
 */
386 387
typedef struct RemoveStmt
{
388 389 390
	NodeTag		type;
	int			removeType;		/* P_TYPE|INDEX|RULE|VIEW */
	char	   *name;			/* name to drop */
391
} RemoveStmt;
392 393

/* ----------------------
394
 *		Alter Table Statement
395 396
 * ----------------------
 */
397 398
typedef struct RenameStmt
{
399 400 401 402
	NodeTag		type;
	char	   *relname;		/* relation to be altered */
	bool		inh;			/* recursively alter children? */
	char	   *column;			/* if NULL, rename the relation name to
403 404
								 * the new name. Otherwise, rename this
								 * column name. */
405
	char	   *newname;		/* the new name */
406
} RenameStmt;
407 408

/* ----------------------
409
 *		Create Rule Statement
410 411
 * ----------------------
 */
412 413
typedef struct RuleStmt
{
414 415 416 417 418 419 420
	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 */
421
} RuleStmt;
422 423

/* ----------------------
424
 *		Notify Statement
425 426
 * ----------------------
 */
427 428
typedef struct NotifyStmt
{
429 430
	NodeTag		type;
	char	   *relname;		/* relation to notify */
431
} NotifyStmt;
432 433

/* ----------------------
434
 *		Listen Statement
435 436
 * ----------------------
 */
437 438
typedef struct ListenStmt
{
439 440
	NodeTag		type;
	char	   *relname;		/* relation to listen on */
441
} ListenStmt;
M
 
Marc G. Fournier 已提交
442 443 444 445 446 447 448 449 450

/* ----------------------
 *		Unlisten Statement
 * ----------------------
 */
typedef struct UnlistenStmt
{
	NodeTag		type;
	char	   *relname;		/* relation to unlisten on */
451
}			UnlistenStmt;
452 453

/* ----------------------
454
 *		{Begin|Abort|End} Transaction Statement
455 456
 * ----------------------
 */
457 458
typedef struct TransactionStmt
{
459 460
	NodeTag		type;
	int			command;		/* BEGIN|END|ABORT */
461
} TransactionStmt;
462 463

/* ----------------------
464
 *		Create View Statement
465 466
 * ----------------------
 */
467 468
typedef struct ViewStmt
{
469 470 471
	NodeTag		type;
	char	   *viewname;		/* name of the view */
	Query	   *query;			/* the SQL statement */
472
} ViewStmt;
473 474

/* ----------------------
475
 *		Load Statement
476 477
 * ----------------------
 */
478 479
typedef struct LoadStmt
{
480 481
	NodeTag		type;
	char	   *filename;		/* file to load */
482
} LoadStmt;
483 484

/* ----------------------
485
 *		Createdb Statement
486 487
 * ----------------------
 */
488 489
typedef struct CreatedbStmt
{
490 491
	NodeTag		type;
	char	   *dbname;			/* database to create */
492
	char	   *dbpath;			/* location of database */
493
	int			encoding;		/* default encoding (see regex/pg_wchar.h) */
494
} CreatedbStmt;
495 496

/* ----------------------
497
 *		Destroydb Statement
498 499
 * ----------------------
 */
500 501
typedef struct DestroydbStmt
{
502 503
	NodeTag		type;
	char	   *dbname;			/* database to drop */
504
} DestroydbStmt;
505 506

/* ----------------------
507
 *		Cluster Statement (support pbrown's cluster index implementation)
508 509
 * ----------------------
 */
510 511
typedef struct ClusterStmt
{
512 513 514
	NodeTag		type;
	char	   *relname;		/* relation being indexed */
	char	   *indexname;		/* original index defined */
515
} ClusterStmt;
516 517

/* ----------------------
518
 *		Vacuum Statement
519 520
 * ----------------------
 */
521 522
typedef struct VacuumStmt
{
523 524 525 526 527
	NodeTag		type;
	bool		verbose;		/* print status info */
	bool		analyze;		/* analyze data */
	char	   *vacrel;			/* table to vacuum */
	List	   *va_spec;		/* columns to analyse */
528
} VacuumStmt;
529 530

/* ----------------------
531
 *		Explain Statement
532 533
 * ----------------------
 */
534 535
typedef struct ExplainStmt
{
536 537 538
	NodeTag		type;
	Query	   *query;			/* the query */
	bool		verbose;		/* print plan info */
539
} ExplainStmt;
540

541 542 543 544 545
/* ----------------------
 * Set Statement
 * ----------------------
 */

546 547
typedef struct VariableSetStmt
{
548 549 550
	NodeTag		type;
	char	   *name;
	char	   *value;
551
} VariableSetStmt;
552 553 554 555 556 557

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

558 559
typedef struct VariableShowStmt
{
560 561
	NodeTag		type;
	char	   *name;
562
} VariableShowStmt;
563 564 565 566 567 568

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

569 570
typedef struct VariableResetStmt
{
571 572
	NodeTag		type;
	char	   *name;
573
} VariableResetStmt;
574

575 576

/*****************************************************************************
577
 *		Optimizable Statements
578 579 580
 *****************************************************************************/

/* ----------------------
581
 *		Insert Statement
582 583
 * ----------------------
 */
B
Bruce Momjian 已提交
584
typedef struct InsertStmt
585
{
586 587
	NodeTag		type;
	char	   *relname;		/* relation to insert into */
588
	char	   *unique;			/* NULL, '*', or unique attribute name */
589 590 591 592
	List	   *cols;			/* names of the columns */
	List	   *targetList;		/* the target list (of ResTarget) */
	List	   *fromClause;		/* the from clause */
	Node	   *whereClause;	/* qualifications */
593 594 595 596
	List	   *groupClause;	/* group by clause */
	Node	   *havingClause;	/* having conditional-expression */
	List	   *unionClause;	/* union subselect parameters */
	bool		unionall;		/* union without unique sort */
B
Bruce Momjian 已提交
597
} InsertStmt;
598 599

/* ----------------------
600
 *		Delete Statement
601 602
 * ----------------------
 */
603 604
typedef struct DeleteStmt
{
605 606 607
	NodeTag		type;
	char	   *relname;		/* relation to delete from */
	Node	   *whereClause;	/* qualifications */
608
} DeleteStmt;
609 610

/* ----------------------
611
 *		Update Statement
612 613
 * ----------------------
 */
B
Bruce Momjian 已提交
614
typedef struct UpdateStmt
615
{
616 617 618 619 620
	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 已提交
621
} UpdateStmt;
622 623

/* ----------------------
624
 *		Select Statement
625 626
 * ----------------------
 */
B
Bruce Momjian 已提交
627
typedef struct SelectStmt
628
{
629 630 631 632 633 634 635 636
	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 */
637
	List	   *unionClause;	/* union subselect parameters */
638
	List	   *sortClause;		/* sort clause (a list of SortGroupBy's) */
639 640
	char	   *portalname;		/* the portal (cursor) to create */
	bool		binary;			/* a binary (internal) portal? */
641
	bool		unionall;		/* union without unique sort */
B
Bruce Momjian 已提交
642
} SelectStmt;
643 644 645


/****************************************************************************
646
 *	Supporting data structures for Parse Trees
647 648 649 650 651
 ****************************************************************************/

/*
 * TypeName - specifies a type in definitions
 */
652 653
typedef struct TypeName
{
654 655 656 657
	NodeTag		type;
	char	   *name;			/* name of the type */
	bool		timezone;		/* timezone specified? */
	bool		setof;			/* is a set? */
M
 
Marc G. Fournier 已提交
658
	int16		typmod;			/* type modifier */
659
	List	   *arrayBounds;	/* array bounds */
660
} TypeName;
661 662 663 664

/*
 * ParamNo - specifies a parameter reference
 */
665 666
typedef struct ParamNo
{
667 668 669
	NodeTag		type;
	int			number;			/* the number of the parameter */
	TypeName   *typename;		/* the typecast */
670
} ParamNo;
671 672 673 674

/*
 * A_Expr - binary expressions
 */
675 676
typedef struct A_Expr
{
677 678
	NodeTag		type;
	int			oper;			/* type of operation
679
								 * {OP,OR,AND,NOT,ISNULL,NOTNULL} */
680 681 682
	char	   *opname;			/* name of operator/function */
	Node	   *lexpr;			/* left argument */
	Node	   *rexpr;			/* right argument */
B
Bruce Momjian 已提交
683
} A_Expr;
684 685 686

/*
 * Attr -
687 688
 *	  specifies an Attribute (ie. a Column); could have nested dots or
 *	  array references.
689 690
 *
 */
691 692
typedef struct Attr
{
693 694 695 696
	NodeTag		type;
	char	   *relname;		/* name of relation (can be "*") */
	ParamNo    *paramNo;		/* or a parameter */
	List	   *attrs;			/* attributes (possibly nested); list of
697
								 * Values (strings) */
698
	List	   *indirection;	/* array refs (list of A_Indices') */
B
Bruce Momjian 已提交
699
} Attr;
700 701 702 703

/*
 * A_Const - a constant expression
 */
704 705
typedef struct A_Const
{
706 707 708
	NodeTag		type;
	Value		val;			/* the value (with the tag) */
	TypeName   *typename;		/* typecast */
B
Bruce Momjian 已提交
709
} A_Const;
710 711 712 713

/*
 * ColumnDef - column definition (used in various creates)
 */
714 715
typedef struct ColumnDef
{
716 717 718 719
	NodeTag		type;
	char	   *colname;		/* name of column */
	TypeName   *typename;		/* type of column */
	bool		is_not_null;	/* flag to NOT NULL constraint */
720
	bool		is_sequence;	/* is a sequence? */
721
	char	   *defval;			/* default value of column */
722 723
	List	   *constraints;	/* constraints on column */
} ColumnDef;
724 725

/*
726 727 728 729 730 731 732 733
 * 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
{
734 735 736 737
	NodeTag		type;
	char	   *name;			/* its name */
	List	   *indirection;	/* array references */
	bool		isRel;			/* is a relation - filled in by
738
								 * transformExpr() */
739
} Ident;
740 741 742 743

/*
 * FuncCall - a function/aggregate invocation
 */
744 745
typedef struct FuncCall
{
746 747 748
	NodeTag		type;
	char	   *funcname;		/* name of function */
	List	   *args;			/* the arguments (list of exprs) */
749
} FuncCall;
750 751 752 753

/*
 * A_Indices - array reference or bounds ([lidx:uidx] or [uidx])
 */
754 755
typedef struct A_Indices
{
756 757 758
	NodeTag		type;
	Node	   *lidx;			/* could be NULL */
	Node	   *uidx;
B
Bruce Momjian 已提交
759
} A_Indices;
760 761

/*
762 763 764 765 766
 * ResTarget -
 *	  result target (used in target list of pre-transformed Parse trees)
 */
typedef struct ResTarget
{
767 768 769 770
	NodeTag		type;
	char	   *name;			/* name of the result column */
	List	   *indirection;	/* array references */
	Node	   *val;			/* the value of the result (A_Expr or
771
								 * Attr) (or A_Const) */
772
} ResTarget;
773 774 775 776

/*
 * ParamString - used in with clauses
 */
777 778
typedef struct ParamString
{
779 780 781
	NodeTag		type;
	char	   *name;
	char	   *val;
782
} ParamString;
783 784 785 786

/*
 * RelExpr - relation expressions
 */
787 788
typedef struct RelExpr
{
789 790 791
	NodeTag		type;
	char	   *relname;		/* the relation name */
	bool		inh;			/* inheritance query */
792
} RelExpr;
793 794

/*
795
 * SortGroupBy - for order by clause
796
 */
797
typedef struct SortGroupBy
M
 
Marc G. Fournier 已提交
798 799 800
{
	NodeTag		type;
	char	   *useOp;			/* operator to use */
801
	Node	   *node;			/* Expression  */
M
 
Marc G. Fournier 已提交
802 803 804 805 806 807
} SortGroupBy;

/*
 * JoinUsing - for join using clause
 */
typedef struct JoinUsing
808
{
809 810 811 812
	NodeTag		type;
	int			resno;			/* target number */
	char	   *range;
	char	   *name;			/* name of column to sort on */
813
}			JoinUsing;
814 815 816 817

/*
 * RangeVar - range variable, used in from clauses
 */
818 819
typedef struct RangeVar
{
820 821 822
	NodeTag		type;
	RelExpr    *relExpr;		/* the relation expression */
	char	   *name;			/* the name to be referenced (optional) */
823
} RangeVar;
824 825 826 827

/*
 * IndexElem - index parameters (used in create index)
 */
828 829
typedef struct IndexElem
{
830 831 832 833
	NodeTag		type;
	char	   *name;			/* name of index */
	List	   *args;			/* if not NULL, function index */
	char	   *class;
834
	TypeName   *typename;		/* type of index's keys (optional) */
835
} IndexElem;
836 837 838

/*
 * DefElem -
839
 *	  a definition (used in definition lists in the form of defname = arg)
840
 */
841 842
typedef struct DefElem
{
843 844 845
	NodeTag		type;
	char	   *defname;
	Node	   *arg;			/* a (Value *) or a (TypeName *) */
846
} DefElem;
847 848 849


/****************************************************************************
850
 *	Nodes for a Query tree
851 852 853 854
 ****************************************************************************/

/*
 * TargetEntry -
855
 *	   a target  entry (used in the transformed target list)
856 857
 *
 * one of resdom or fjoin is not NULL. a target list is
858
 *		((<resdom | fjoin> expr) (<resdom | fjoin> expr) ...)
859
 */
860 861
typedef struct TargetEntry
{
862 863 864 865
	NodeTag		type;
	Resdom	   *resdom;			/* fjoin overload this to be a list?? */
	Fjoin	   *fjoin;
	Node	   *expr;			/* can be a list too */
866
} TargetEntry;
867 868 869

/*
 * RangeTblEntry -
870 871
 *	  used in range tables. Some of the following are only used in one of
 *	  the parsing, optimizing, execution stages.
872
 *
873 874 875 876 877 878 879 880 881
 *	  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
{
882 883 884
	NodeTag		type;
	char	   *relname;		/* real name of the relation */
	char	   *refname;		/* the reference name (specified in the
885
								 * from clause) */
886 887 888
	Oid			relid;
	bool		inh;			/* inheritance? */
	bool		inFromCl;		/* comes from From Clause */
M
Marc G. Fournier 已提交
889
	bool		skipAcl;		/* skip ACL check in executor */
890
} RangeTblEntry;
891 892 893

/*
 * SortClause -
894
 *	   used in the sort clause for retrieves and cursors
895
 */
896 897
typedef struct SortClause
{
898 899 900
	NodeTag		type;
	Resdom	   *resdom;			/* attributes in tlist to be sorted */
	Oid			opoid;			/* sort operators */
901
} SortClause;
902 903 904

/*
 * GroupClause -
905
 *	   used in the GROUP BY clause
906
 */
907 908
typedef struct GroupClause
{
909 910 911
	NodeTag		type;
	TargetEntry *entry;			/* attributes to group on */
	Oid			grpOpoid;		/* the sort operator to use */
912
} GroupClause;
913

914
#endif	 /* PARSENODES_H */