parsenodes.h 22.2 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
 *
M
 
Marc G. Fournier 已提交
9
 * $Id: parsenodes.h,v 1.53 1998/08/05 04:49:13 scrappy 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
	List	   *base_relation_list_;	/* base relation list */
B
Bruce Momjian 已提交
66
	List	   *join_relation_list_;	/* list of relations */
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;
442 443

/* ----------------------
444
 *		{Begin|Abort|End} Transaction Statement
445 446
 * ----------------------
 */
447 448
typedef struct TransactionStmt
{
449 450
	NodeTag		type;
	int			command;		/* BEGIN|END|ABORT */
451
} TransactionStmt;
452 453

/* ----------------------
454
 *		Create View Statement
455 456
 * ----------------------
 */
457 458
typedef struct ViewStmt
{
459 460 461
	NodeTag		type;
	char	   *viewname;		/* name of the view */
	Query	   *query;			/* the SQL statement */
462
} ViewStmt;
463 464

/* ----------------------
465
 *		Load Statement
466 467
 * ----------------------
 */
468 469
typedef struct LoadStmt
{
470 471
	NodeTag		type;
	char	   *filename;		/* file to load */
472
} LoadStmt;
473 474

/* ----------------------
475
 *		Createdb Statement
476 477
 * ----------------------
 */
478 479
typedef struct CreatedbStmt
{
480 481
	NodeTag		type;
	char	   *dbname;			/* database to create */
482
	char	   *dbpath;			/* location of database */
M
 
Marc G. Fournier 已提交
483
#ifdef MULTIBYTE
M
 
Marc G. Fournier 已提交
484 485 486
	int	   encoding;			/* default encoding
						   (see regex/pg_wchar.h) */
#endif
487
} CreatedbStmt;
488 489

/* ----------------------
490
 *		Destroydb Statement
491 492
 * ----------------------
 */
493 494
typedef struct DestroydbStmt
{
495 496
	NodeTag		type;
	char	   *dbname;			/* database to drop */
497
} DestroydbStmt;
498 499

/* ----------------------
500
 *		Cluster Statement (support pbrown's cluster index implementation)
501 502
 * ----------------------
 */
503 504
typedef struct ClusterStmt
{
505 506 507
	NodeTag		type;
	char	   *relname;		/* relation being indexed */
	char	   *indexname;		/* original index defined */
508
} ClusterStmt;
509 510

/* ----------------------
511
 *		Vacuum Statement
512 513
 * ----------------------
 */
514 515
typedef struct VacuumStmt
{
516 517 518 519 520
	NodeTag		type;
	bool		verbose;		/* print status info */
	bool		analyze;		/* analyze data */
	char	   *vacrel;			/* table to vacuum */
	List	   *va_spec;		/* columns to analyse */
521
} VacuumStmt;
522 523

/* ----------------------
524
 *		Explain Statement
525 526
 * ----------------------
 */
527 528
typedef struct ExplainStmt
{
529 530 531
	NodeTag		type;
	Query	   *query;			/* the query */
	bool		verbose;		/* print plan info */
532
} ExplainStmt;
533

534 535 536 537 538
/* ----------------------
 * Set Statement
 * ----------------------
 */

539 540
typedef struct VariableSetStmt
{
541 542 543
	NodeTag		type;
	char	   *name;
	char	   *value;
544
} VariableSetStmt;
545 546 547 548 549 550

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

551 552
typedef struct VariableShowStmt
{
553 554
	NodeTag		type;
	char	   *name;
555
} VariableShowStmt;
556 557 558 559 560 561

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

562 563
typedef struct VariableResetStmt
{
564 565
	NodeTag		type;
	char	   *name;
566
} VariableResetStmt;
567

568 569

/*****************************************************************************
570
 *		Optimizable Statements
571 572 573
 *****************************************************************************/

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

/* ----------------------
593
 *		Delete Statement
594 595
 * ----------------------
 */
596 597
typedef struct DeleteStmt
{
598 599 600
	NodeTag		type;
	char	   *relname;		/* relation to delete from */
	Node	   *whereClause;	/* qualifications */
601
} DeleteStmt;
602 603

/* ----------------------
604
 *		Update Statement
605 606
 * ----------------------
 */
B
Bruce Momjian 已提交
607
typedef struct UpdateStmt
608
{
609 610 611 612 613
	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 已提交
614
} UpdateStmt;
615 616

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


/****************************************************************************
639
 *	Supporting data structures for Parse Trees
640 641 642 643 644
 ****************************************************************************/

/*
 * TypeName - specifies a type in definitions
 */
645 646
typedef struct TypeName
{
647 648 649 650
	NodeTag		type;
	char	   *name;			/* name of the type */
	bool		timezone;		/* timezone specified? */
	bool		setof;			/* is a set? */
M
 
Marc G. Fournier 已提交
651
	int16		typmod;			/* type modifier */
652
	List	   *arrayBounds;	/* array bounds */
653
} TypeName;
654 655 656 657

/*
 * ParamNo - specifies a parameter reference
 */
658 659
typedef struct ParamNo
{
660 661 662
	NodeTag		type;
	int			number;			/* the number of the parameter */
	TypeName   *typename;		/* the typecast */
663
} ParamNo;
664 665 666 667

/*
 * A_Expr - binary expressions
 */
668 669
typedef struct A_Expr
{
670 671
	NodeTag		type;
	int			oper;			/* type of operation
672
								 * {OP,OR,AND,NOT,ISNULL,NOTNULL} */
673 674 675
	char	   *opname;			/* name of operator/function */
	Node	   *lexpr;			/* left argument */
	Node	   *rexpr;			/* right argument */
B
Bruce Momjian 已提交
676
} A_Expr;
677 678 679

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

/*
 * A_Const - a constant expression
 */
697 698
typedef struct A_Const
{
699 700 701
	NodeTag		type;
	Value		val;			/* the value (with the tag) */
	TypeName   *typename;		/* typecast */
B
Bruce Momjian 已提交
702
} A_Const;
703 704 705 706

/*
 * ColumnDef - column definition (used in various creates)
 */
707 708
typedef struct ColumnDef
{
709 710 711 712 713
	NodeTag		type;
	char	   *colname;		/* name of column */
	TypeName   *typename;		/* type of column */
	bool		is_not_null;	/* flag to NOT NULL constraint */
	char	   *defval;			/* default value of column */
714 715
	List	   *constraints;	/* constraints on column */
} ColumnDef;
716 717

/*
718 719 720 721 722 723 724 725
 * 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
{
726 727 728 729
	NodeTag		type;
	char	   *name;			/* its name */
	List	   *indirection;	/* array references */
	bool		isRel;			/* is a relation - filled in by
730
								 * transformExpr() */
731
} Ident;
732 733 734 735

/*
 * FuncCall - a function/aggregate invocation
 */
736 737
typedef struct FuncCall
{
738 739 740
	NodeTag		type;
	char	   *funcname;		/* name of function */
	List	   *args;			/* the arguments (list of exprs) */
741
} FuncCall;
742 743 744 745

/*
 * A_Indices - array reference or bounds ([lidx:uidx] or [uidx])
 */
746 747
typedef struct A_Indices
{
748 749 750
	NodeTag		type;
	Node	   *lidx;			/* could be NULL */
	Node	   *uidx;
B
Bruce Momjian 已提交
751
} A_Indices;
752 753

/*
754 755 756 757 758
 * ResTarget -
 *	  result target (used in target list of pre-transformed Parse trees)
 */
typedef struct ResTarget
{
759 760 761 762
	NodeTag		type;
	char	   *name;			/* name of the result column */
	List	   *indirection;	/* array references */
	Node	   *val;			/* the value of the result (A_Expr or
763
								 * Attr) (or A_Const) */
764
} ResTarget;
765 766 767 768

/*
 * ParamString - used in with clauses
 */
769 770
typedef struct ParamString
{
771 772 773
	NodeTag		type;
	char	   *name;
	char	   *val;
774
} ParamString;
775 776 777 778

/*
 * RelExpr - relation expressions
 */
779 780
typedef struct RelExpr
{
781 782 783
	NodeTag		type;
	char	   *relname;		/* the relation name */
	bool		inh;			/* inheritance query */
784
} RelExpr;
785 786

/*
787
 * SortGroupBy - for order by clause
788
 */
789
typedef struct SortGroupBy
M
 
Marc G. Fournier 已提交
790 791 792 793 794 795 796 797 798 799
{
	NodeTag		type;
	char	   *useOp;			/* operator to use */
	Node       *node;           /*  Expression  */    
} SortGroupBy;

/*
 * JoinUsing - for join using clause
 */
typedef struct JoinUsing
800
{
801 802 803 804
	NodeTag		type;
	int			resno;			/* target number */
	char	   *range;
	char	   *name;			/* name of column to sort on */
M
 
Marc G. Fournier 已提交
805
} JoinUsing;
806 807 808 809

/*
 * RangeVar - range variable, used in from clauses
 */
810 811
typedef struct RangeVar
{
812 813 814
	NodeTag		type;
	RelExpr    *relExpr;		/* the relation expression */
	char	   *name;			/* the name to be referenced (optional) */
815
} RangeVar;
816 817 818 819

/*
 * IndexElem - index parameters (used in create index)
 */
820 821
typedef struct IndexElem
{
822 823 824 825 826
	NodeTag		type;
	char	   *name;			/* name of index */
	List	   *args;			/* if not NULL, function index */
	char	   *class;
	TypeName   *tname;			/* type of index's keys (optional) */
827
} IndexElem;
828 829 830

/*
 * DefElem -
831
 *	  a definition (used in definition lists in the form of defname = arg)
832
 */
833 834
typedef struct DefElem
{
835 836 837
	NodeTag		type;
	char	   *defname;
	Node	   *arg;			/* a (Value *) or a (TypeName *) */
838
} DefElem;
839 840 841


/****************************************************************************
842
 *	Nodes for a Query tree
843 844 845 846
 ****************************************************************************/

/*
 * TargetEntry -
847
 *	   a target  entry (used in the transformed target list)
848 849
 *
 * one of resdom or fjoin is not NULL. a target list is
850
 *		((<resdom | fjoin> expr) (<resdom | fjoin> expr) ...)
851
 */
852 853
typedef struct TargetEntry
{
854 855 856 857
	NodeTag		type;
	Resdom	   *resdom;			/* fjoin overload this to be a list?? */
	Fjoin	   *fjoin;
	Node	   *expr;			/* can be a list too */
858
} TargetEntry;
859 860 861

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

/*
 * SortClause -
886
 *	   used in the sort clause for retrieves and cursors
887
 */
888 889
typedef struct SortClause
{
890 891 892
	NodeTag		type;
	Resdom	   *resdom;			/* attributes in tlist to be sorted */
	Oid			opoid;			/* sort operators */
893
} SortClause;
894 895 896

/*
 * GroupClause -
897
 *	   used in the GROUP BY clause
898
 */
899 900
typedef struct GroupClause
{
901 902 903
	NodeTag		type;
	TargetEntry *entry;			/* attributes to group on */
	Oid			grpOpoid;		/* the sort operator to use */
904
} GroupClause;
905

906
#endif							/* PARSENODES_H */