parsenodes.h 22.7 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.38 1997/12/23 19:58:12 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

47 48
	char	   *uniqueFlag;		/* NULL, '*', or Unique attribute name */
	List	   *sortClause;		/* a list of SortClause's */
49

50 51 52
	List	   *rtable;			/* list of range table entries */
	List	   *targetList;		/* target list (of TargetEntry) */
	Node	   *qual;			/* qualifications */
53

54
	List	   *groupClause;	/* list of columns to specified in GROUP
55
								 * BY */
56
	Node	   *havingQual;		/* qualification of each group */
57

58 59
	int			qry_numAgg;		/* number of aggregates in the target list */
	Aggreg	  **qry_aggs;		/* the aggregates */
60 61

	/* internal to planner */
62
	List	   *base_relation_list_;	/* base relation list */
B
Bruce Momjian 已提交
63
	List	   *join_relation_list_;	/* list of relations */
64
} Query;
65 66 67


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

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

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

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

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

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

139
typedef enum ConstrType			/* type of constaints */
140
{
141 142
	CONSTR_NONE, CONSTR_NOTNULL, CONSTR_DEFAULT, CONSTR_CHECK, CONSTR_PRIMARY, CONSTR_UNIQUE
} ConstrType;
143

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

153
/* ----------------------
154
 *		Create/Drop TRIGGER Statements
155 156 157
 * ----------------------
 */

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

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


/* ----------------------
 *		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 */
193
} CreatePLangStmt;
194 195 196 197 198

typedef struct DropPLangStmt
{
	NodeTag		type;
	char	   *plname;			/* PL name */
199
} DropPLangStmt;
200

201

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

typedef CreateUserStmt        AlterUserStmt;

typedef struct DropUserStmt
{
        NodeTag         type;
        char*           user;           /* PostgreSQL user login              */
} DropUserStmt;


V
Vadim B. Mikheev 已提交
226
/* ----------------------
227
 *		Create SEQUENCE Statement
V
Vadim B. Mikheev 已提交
228 229 230
 * ----------------------
 */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/* ----------------------
431
 *		Listen Statement
432 433
 * ----------------------
 */
434 435
typedef struct ListenStmt
{
436 437
	NodeTag		type;
	char	   *relname;		/* relation to listen on */
438
} ListenStmt;
439 440

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

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

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

/* ----------------------
472
 *		Createdb Statement
473 474
 * ----------------------
 */
475 476
typedef struct CreatedbStmt
{
477 478
	NodeTag		type;
	char	   *dbname;			/* database to create */
479
	char	   *dbpath;			/* location of database */
480
} CreatedbStmt;
481 482

/* ----------------------
483
 *		Destroydb Statement
484 485
 * ----------------------
 */
486 487
typedef struct DestroydbStmt
{
488 489
	NodeTag		type;
	char	   *dbname;			/* database to drop */
490
} DestroydbStmt;
491 492

/* ----------------------
493
 *		Cluster Statement (support pbrown's cluster index implementation)
494 495
 * ----------------------
 */
496 497
typedef struct ClusterStmt
{
498 499 500
	NodeTag		type;
	char	   *relname;		/* relation being indexed */
	char	   *indexname;		/* original index defined */
501
} ClusterStmt;
502 503

/* ----------------------
504
 *		Vacuum Statement
505 506
 * ----------------------
 */
507 508
typedef struct VacuumStmt
{
509 510 511 512 513
	NodeTag		type;
	bool		verbose;		/* print status info */
	bool		analyze;		/* analyze data */
	char	   *vacrel;			/* table to vacuum */
	List	   *va_spec;		/* columns to analyse */
514
} VacuumStmt;
515 516

/* ----------------------
517
 *		Explain Statement
518 519
 * ----------------------
 */
520 521
typedef struct ExplainStmt
{
522 523 524
	NodeTag		type;
	Query	   *query;			/* the query */
	bool		verbose;		/* print plan info */
525
} ExplainStmt;
526

527 528 529 530 531
/* ----------------------
 * Set Statement
 * ----------------------
 */

532 533
typedef struct VariableSetStmt
{
534 535 536
	NodeTag		type;
	char	   *name;
	char	   *value;
537
} VariableSetStmt;
538 539 540 541 542 543

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

544 545
typedef struct VariableShowStmt
{
546 547
	NodeTag		type;
	char	   *name;
548
} VariableShowStmt;
549 550 551 552 553 554

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

555 556
typedef struct VariableResetStmt
{
557 558
	NodeTag		type;
	char	   *name;
559
} VariableResetStmt;
560

561 562

/*****************************************************************************
563
 *		Optimizable Statements
564 565 566
 *****************************************************************************/

/* ----------------------
567
 *		Insert Statement
568 569
 * ----------------------
 */
570 571
typedef struct AppendStmt
{
572 573 574 575 576 577
	NodeTag		type;
	char	   *relname;		/* relation to insert into */
	List	   *cols;			/* names of the columns */
	List	   *targetList;		/* the target list (of ResTarget) */
	List	   *fromClause;		/* the from clause */
	Node	   *whereClause;	/* qualifications */
B
Bruce Momjian 已提交
578
} AppendStmt;
579 580

/* ----------------------
581
 *		Delete Statement
582 583
 * ----------------------
 */
584 585
typedef struct DeleteStmt
{
586 587 588
	NodeTag		type;
	char	   *relname;		/* relation to delete from */
	Node	   *whereClause;	/* qualifications */
589
} DeleteStmt;
590 591

/* ----------------------
592
 *		Update Statement
593 594
 * ----------------------
 */
595 596
typedef struct ReplaceStmt
{
597 598 599 600 601
	NodeTag		type;
	char	   *relname;		/* relation to update */
	List	   *targetList;		/* the target list (of ResTarget) */
	Node	   *whereClause;	/* qualifications */
	List	   *fromClause;		/* the from clause */
602
} ReplaceStmt;
603 604

/* ----------------------
605
 *		Create Cursor Statement
606 607
 * ----------------------
 */
608 609
typedef struct CursorStmt
{
610 611 612 613 614 615 616 617 618
	NodeTag		type;
	char	   *portalname;		/* the portal (cursor) to create */
	bool		binary;			/* a binary (internal) portal? */
	char	   *unique;			/* NULL, "*", or unique attribute name */
	List	   *targetList;		/* the target list (of ResTarget) */
	List	   *fromClause;		/* the from clause */
	Node	   *whereClause;	/* qualifications */
	List	   *groupClause;	/* group by clause */
	List	   *sortClause;		/* sort clause (a list of SortGroupBy's) */
619
} CursorStmt;
620 621

/* ----------------------
622
 *		Select Statement
623 624
 * ----------------------
 */
625 626
typedef struct RetrieveStmt
{
627 628 629 630 631 632 633 634
	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 */
635
	List	   *unionClause;	/* union subselect parameters */
636
	List	   *sortClause;		/* sort clause (a list of SortGroupBy's) */
637
} RetrieveStmt;
638 639 640


/****************************************************************************
641
 *	Supporting data structures for Parse Trees
642 643
 ****************************************************************************/

644 645 646
/*
 * SubSelect - specifies subselect parameters
 */
647 648
typedef struct SubSelect
{
649 650
	NodeTag		type;
	char	   *unique;			/* NULL, '*', or unique attribute name */
651
	int			unionall;		/* union without unique sort */
652 653 654 655 656
	List	   *targetList;		/* the target list (of ResTarget) */
	List	   *fromClause;		/* the from clause */
	Node	   *whereClause;	/* qualifications */
	List	   *groupClause;	/* group by clause */
	Node	   *havingClause;	/* having conditional-expression */
657
} SubSelect;
658

659 660 661
/*
 * TypeName - specifies a type in definitions
 */
662 663
typedef struct TypeName
{
664 665 666 667 668 669
	NodeTag		type;
	char	   *name;			/* name of the type */
	bool		timezone;		/* timezone specified? */
	bool		setof;			/* is a set? */
	List	   *arrayBounds;	/* array bounds */
	int			typlen;			/* length for char() and varchar() */
670
} TypeName;
671 672 673 674

/*
 * ParamNo - specifies a parameter reference
 */
675 676
typedef struct ParamNo
{
677 678 679
	NodeTag		type;
	int			number;			/* the number of the parameter */
	TypeName   *typename;		/* the typecast */
680
} ParamNo;
681 682 683 684

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

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

/*
 * A_Const - a constant expression
 */
714 715
typedef struct A_Const
{
716 717 718
	NodeTag		type;
	Value		val;			/* the value (with the tag) */
	TypeName   *typename;		/* typecast */
B
Bruce Momjian 已提交
719
} A_Const;
720 721 722 723

/*
 * ColumnDef - column definition (used in various creates)
 */
724 725
typedef struct ColumnDef
{
726 727 728 729 730
	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 */
731 732
	List	   *constraints;	/* constraints on column */
} ColumnDef;
733 734

/*
735 736 737 738 739 740 741 742
 * 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
{
743 744 745 746
	NodeTag		type;
	char	   *name;			/* its name */
	List	   *indirection;	/* array references */
	bool		isRel;			/* is a relation - filled in by
747
								 * transformExpr() */
748
} Ident;
749 750 751 752

/*
 * FuncCall - a function/aggregate invocation
 */
753 754
typedef struct FuncCall
{
755 756 757
	NodeTag		type;
	char	   *funcname;		/* name of function */
	List	   *args;			/* the arguments (list of exprs) */
758
} FuncCall;
759 760 761 762

/*
 * A_Indices - array reference or bounds ([lidx:uidx] or [uidx])
 */
763 764
typedef struct A_Indices
{
765 766 767
	NodeTag		type;
	Node	   *lidx;			/* could be NULL */
	Node	   *uidx;
B
Bruce Momjian 已提交
768
} A_Indices;
769 770

/*
771 772 773 774 775
 * ResTarget -
 *	  result target (used in target list of pre-transformed Parse trees)
 */
typedef struct ResTarget
{
776 777 778 779
	NodeTag		type;
	char	   *name;			/* name of the result column */
	List	   *indirection;	/* array references */
	Node	   *val;			/* the value of the result (A_Expr or
780
								 * Attr) (or A_Const) */
781
} ResTarget;
782 783 784 785

/*
 * ParamString - used in with clauses
 */
786 787
typedef struct ParamString
{
788 789 790
	NodeTag		type;
	char	   *name;
	char	   *val;
791
} ParamString;
792 793 794 795

/*
 * RelExpr - relation expressions
 */
796 797
typedef struct RelExpr
{
798 799 800
	NodeTag		type;
	char	   *relname;		/* the relation name */
	bool		inh;			/* inheritance query */
801
} RelExpr;
802 803

/*
804
 * SortGroupBy - for order by clause
805
 */
806 807
typedef struct SortGroupBy
{
808 809 810 811 812
	NodeTag		type;
	int			resno;			/* target number */
	char	   *range;
	char	   *name;			/* name of column to sort on */
	char	   *useOp;			/* operator to use */
813
} SortGroupBy;
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 834
	NodeTag		type;
	char	   *name;			/* name of index */
	List	   *args;			/* if not NULL, function index */
	char	   *class;
	TypeName   *tname;			/* 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 */
889
} RangeTblEntry;
890 891 892

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

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

913
#endif							/* PARSENODES_H */