parsenodes.h 23.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
 *
T
Thomas G. Lockhart 已提交
9
 * $Id: parsenodes.h,v 1.62 1998/12/04 15:34:44 thomas 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
	Node	   *limitOffset;	/* # of result tuples to skip */
	Node	   *limitCount;		/* # of result tuples to return */
B
Bruce Momjian 已提交
65

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


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

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

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

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

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

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

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

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

158
/* ----------------------
159
 *		Create/Drop TRIGGER Statements
160 161 162
 * ----------------------
 */

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

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


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

typedef struct DropPLangStmt
{
	NodeTag		type;
	char	   *plname;			/* PL name */
204
} DropPLangStmt;
205

206

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

222
typedef CreateUserStmt AlterUserStmt;
223 224 225

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

543 544 545 546 547
/* ----------------------
 * Set Statement
 * ----------------------
 */

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

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

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

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

571 572
typedef struct VariableResetStmt
{
573 574
	NodeTag		type;
	char	   *name;
575
} VariableResetStmt;
576

577 578

/*****************************************************************************
579
 *		Optimizable Statements
580 581 582
 *****************************************************************************/

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

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

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

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


/****************************************************************************
650
 *	Supporting data structures for Parse Trees
651 652 653 654 655
 ****************************************************************************/

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

/*
 * ParamNo - specifies a parameter reference
 */
669 670
typedef struct ParamNo
{
671 672 673
	NodeTag		type;
	int			number;			/* the number of the parameter */
	TypeName   *typename;		/* the typecast */
674
	List	   *indirection;	/* array references */
675
} ParamNo;
676 677 678 679

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

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

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

T
Thomas G. Lockhart 已提交
716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737
/*
 * 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) */
} CaseExpr;

/*
 * CaseWhen - an argument to a CASE expression
 */
typedef struct CaseWhen
{
	NodeTag		type;
	Node	   *expr;			/* comparison expression */
	Node	   *result;			/* substitution result */
} CaseWhen;

738 739 740
/*
 * ColumnDef - column definition (used in various creates)
 */
741 742
typedef struct ColumnDef
{
743 744 745 746
	NodeTag		type;
	char	   *colname;		/* name of column */
	TypeName   *typename;		/* type of column */
	bool		is_not_null;	/* flag to NOT NULL constraint */
747
	bool		is_sequence;	/* is a sequence? */
748
	char	   *defval;			/* default value of column */
749 750
	List	   *constraints;	/* constraints on column */
} ColumnDef;
751 752

/*
753 754 755 756 757 758 759 760
 * 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
{
761 762 763 764
	NodeTag		type;
	char	   *name;			/* its name */
	List	   *indirection;	/* array references */
	bool		isRel;			/* is a relation - filled in by
765
								 * transformExpr() */
766
} Ident;
767 768 769 770

/*
 * FuncCall - a function/aggregate invocation
 */
771 772
typedef struct FuncCall
{
773 774 775
	NodeTag		type;
	char	   *funcname;		/* name of function */
	List	   *args;			/* the arguments (list of exprs) */
776
} FuncCall;
777 778 779 780

/*
 * A_Indices - array reference or bounds ([lidx:uidx] or [uidx])
 */
781 782
typedef struct A_Indices
{
783 784 785
	NodeTag		type;
	Node	   *lidx;			/* could be NULL */
	Node	   *uidx;
B
Bruce Momjian 已提交
786
} A_Indices;
787 788

/*
789 790 791 792 793
 * ResTarget -
 *	  result target (used in target list of pre-transformed Parse trees)
 */
typedef struct ResTarget
{
794 795 796 797
	NodeTag		type;
	char	   *name;			/* name of the result column */
	List	   *indirection;	/* array references */
	Node	   *val;			/* the value of the result (A_Expr or
798
								 * Attr) (or A_Const) */
799
} ResTarget;
800 801

/*
T
Thomas G. Lockhart 已提交
802
 * ParamString - used in WITH clauses
803
 */
804 805
typedef struct ParamString
{
806 807 808
	NodeTag		type;
	char	   *name;
	char	   *val;
809
} ParamString;
810 811 812 813

/*
 * RelExpr - relation expressions
 */
814 815
typedef struct RelExpr
{
816 817 818
	NodeTag		type;
	char	   *relname;		/* the relation name */
	bool		inh;			/* inheritance query */
819
} RelExpr;
820 821

/*
T
Thomas G. Lockhart 已提交
822
 * SortGroupBy - for ORDER BY clause
823
 */
824
typedef struct SortGroupBy
M
 
Marc G. Fournier 已提交
825 826 827
{
	NodeTag		type;
	char	   *useOp;			/* operator to use */
828
	Node	   *node;			/* Expression  */
M
 
Marc G. Fournier 已提交
829 830 831
} SortGroupBy;

/*
T
Thomas G. Lockhart 已提交
832
 * JoinUsing - for JOIN USING clause
M
 
Marc G. Fournier 已提交
833 834
 */
typedef struct JoinUsing
835
{
836 837 838 839
	NodeTag		type;
	int			resno;			/* target number */
	char	   *range;
	char	   *name;			/* name of column to sort on */
840
}			JoinUsing;
841 842

/*
T
Thomas G. Lockhart 已提交
843
 * RangeVar - range variable, used in FROM clauses
844
 */
845 846
typedef struct RangeVar
{
847 848 849
	NodeTag		type;
	RelExpr    *relExpr;		/* the relation expression */
	char	   *name;			/* the name to be referenced (optional) */
850
} RangeVar;
851 852

/*
T
Thomas G. Lockhart 已提交
853
 * IndexElem - index parameters (used in CREATE INDEX)
854
 */
855 856
typedef struct IndexElem
{
857 858 859 860
	NodeTag		type;
	char	   *name;			/* name of index */
	List	   *args;			/* if not NULL, function index */
	char	   *class;
861
	TypeName   *typename;		/* type of index's keys (optional) */
862
} IndexElem;
863 864 865

/*
 * DefElem -
866
 *	  a definition (used in definition lists in the form of defname = arg)
867
 */
868 869
typedef struct DefElem
{
870 871 872
	NodeTag		type;
	char	   *defname;
	Node	   *arg;			/* a (Value *) or a (TypeName *) */
873
} DefElem;
874 875 876


/****************************************************************************
877
 *	Nodes for a Query tree
878 879 880 881
 ****************************************************************************/

/*
 * TargetEntry -
882
 *	   a target  entry (used in the transformed target list)
883 884
 *
 * one of resdom or fjoin is not NULL. a target list is
885
 *		((<resdom | fjoin> expr) (<resdom | fjoin> expr) ...)
886
 */
887 888
typedef struct TargetEntry
{
889 890 891 892
	NodeTag		type;
	Resdom	   *resdom;			/* fjoin overload this to be a list?? */
	Fjoin	   *fjoin;
	Node	   *expr;			/* can be a list too */
893
} TargetEntry;
894 895 896

/*
 * RangeTblEntry -
897 898
 *	  used in range tables. Some of the following are only used in one of
 *	  the parsing, optimizing, execution stages.
899
 *
900 901 902 903 904 905 906 907 908
 *	  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
{
909 910 911
	NodeTag		type;
	char	   *relname;		/* real name of the relation */
	char	   *refname;		/* the reference name (specified in the
912
								 * from clause) */
913 914 915
	Oid			relid;
	bool		inh;			/* inheritance? */
	bool		inFromCl;		/* comes from From Clause */
M
Marc G. Fournier 已提交
916
	bool		skipAcl;		/* skip ACL check in executor */
917
} RangeTblEntry;
918 919 920

/*
 * SortClause -
921
 *	   used in the sort clause for retrieves and cursors
922
 */
923 924
typedef struct SortClause
{
925 926 927
	NodeTag		type;
	Resdom	   *resdom;			/* attributes in tlist to be sorted */
	Oid			opoid;			/* sort operators */
928
} SortClause;
929 930 931

/*
 * GroupClause -
932
 *	   used in the GROUP BY clause
933
 */
934 935
typedef struct GroupClause
{
936 937 938
	NodeTag		type;
	TargetEntry *entry;			/* attributes to group on */
	Oid			grpOpoid;		/* the sort operator to use */
939
} GroupClause;
940

941
#endif	 /* PARSENODES_H */