primnodes.h 22.2 KB
Newer Older
1 2
/*-------------------------------------------------------------------------
 *
3
 * primnodes.h
4 5 6 7
 *	  Definitions for "primitive" node types, those that are used in more
 *	  than one of the parse/plan/execute stages of the query pipeline.
 *	  Currently, these are mostly nodes for executable expressions
 *	  and join trees.
8 9
 *
 *
B
Bruce Momjian 已提交
10
 * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
B
Add:  
Bruce Momjian 已提交
11
 * Portions Copyright (c) 1994, Regents of the University of California
12
 *
13
 * $Id: primnodes.h,v 1.71 2002/11/30 21:25:06 tgl Exp $
14 15 16 17
 *
 *-------------------------------------------------------------------------
 */
#ifndef PRIMNODES_H
18
#define PRIMNODES_H
19

20 21
#include "access/attnum.h"
#include "nodes/pg_list.h"
22 23 24 25

/* FunctionCache is declared in utils/fcache.h */
typedef struct FunctionCache *FunctionCachePtr;

26 27

/* ----------------------------------------------------------------
28
 *						node definitions
29 30 31
 * ----------------------------------------------------------------
 */

32
/*--------------------
33 34
 * Resdom (Result Domain)
 *
35 36
 * Notes:
 * ressortgroupref is the parse/plan-time representation of ORDER BY and
37
 * GROUP BY items.	Targetlist entries with ressortgroupref=0 are not
38
 * sort/group items.  If ressortgroupref>0, then this item is an ORDER BY or
39
 * GROUP BY value.	No two entries in a targetlist may have the same nonzero
40
 * ressortgroupref --- but there is no particular meaning to the nonzero
41 42
 * values, except as tags.	(For example, one must not assume that lower
 * ressortgroupref means a more significant sort key.)	The order of the
43 44 45 46 47
 * associated SortClause or GroupClause lists determine the semantics.
 *
 * reskey and reskeyop are the execution-time representation of sorting.
 * reskey must be zero in any non-sort-key item.  The reskey of sort key
 * targetlist items for a sort plan node is 1,2,...,n for the n sort keys.
48 49
 * The reskeyop of each such targetlist item is the sort operator's OID.
 * reskeyop will be zero in non-sort-key items.
50 51 52
 *
 * Both reskey and reskeyop are typically zero during parse/plan stages.
 * The executor does not pay any attention to ressortgroupref.
53
 *--------------------
54
 */
55 56
typedef struct Resdom
{
B
Bruce Momjian 已提交
57 58 59 60 61
	NodeTag		type;
	AttrNumber	resno;			/* attribute number */
	Oid			restype;		/* type of the value */
	int32		restypmod;		/* type-specific modifier of the value */
	char	   *resname;		/* name of the resdom (could be NULL) */
62
	Index		ressortgroupref;
B
Bruce Momjian 已提交
63 64
	/* nonzero if referenced by a sort/group clause */
	Index		reskey;			/* order of key in a sort (for those > 0) */
65
	Oid			reskeyop;		/* sort operator's Oid */
B
Bruce Momjian 已提交
66 67
	bool		resjunk;		/* set to true to eliminate the attribute
								 * from final target list */
68
} Resdom;
69

70
/*
71 72
 * Fjoin
 */
73 74
typedef struct Fjoin
{
75
	NodeTag		type;
B
Bruce Momjian 已提交
76 77 78 79 80
	bool		fj_initialized; /* true if the Fjoin has already been
								 * initialized for the current target list
								 * evaluation */
	int			fj_nNodes;		/* The number of Iter nodes returning sets
								 * that the node will flatten */
81 82 83 84
	List	   *fj_innerNode;	/* exactly one Iter node.  We eval every
								 * node in the outerList once then eval
								 * the inner node to completion pair the
								 * outerList result vector with each inner
B
Bruce Momjian 已提交
85
								 * result to form the full result.	When
86 87
								 * the inner has been exhausted, we get
								 * the next outer result vector and reset
B
Bruce Momjian 已提交
88
								 * the inner. */
89 90 91
	DatumPtr	fj_results;		/* The complete (flattened) result vector */
	BoolPtr		fj_alwaysDone;	/* a null vector to indicate sets with a
								 * cardinality of 0, we treat them as the
B
Bruce Momjian 已提交
92
								 * set {NULL}. */
93
} Fjoin;
94

95

96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
/*
 * Alias -
 *	  specifies an alias for a range variable; the alias might also
 *	  specify renaming of columns within the table.
 */
typedef struct Alias
{
	NodeTag		type;
	char	   *aliasname;		/* aliased rel name (never qualified) */
	List	   *colnames;		/* optional list of column aliases */
	/* Note: colnames is a list of Value nodes (always strings) */
} Alias;

typedef enum InhOption
{
	INH_NO,						/* Do NOT scan child tables */
	INH_YES,					/* DO scan child tables */
	INH_DEFAULT					/* Use current SQL_inheritance option */
} InhOption;

/*
 * RangeVar - range variable, used in FROM clauses
 *
 * Also used to represent table names in utility statements; there, the alias
 * field is not used, and inhOpt shows whether to apply the operation
 * recursively to child tables.  In some contexts it is also useful to carry
 * a TEMP table indication here.
 */
typedef struct RangeVar
{
	NodeTag		type;
	char	   *catalogname;	/* the catalog (database) name, or NULL */
	char	   *schemaname;		/* the schema name, or NULL */
	char	   *relname;		/* the relation/sequence name */
B
Bruce Momjian 已提交
130 131
	InhOption	inhOpt;			/* expand rel by inheritance? recursively
								 * act on children? */
132 133 134 135 136
	bool		istemp;			/* is this a temp relation/sequence? */
	Alias	   *alias;			/* table alias & optional column aliases */
} RangeVar;


137 138 139 140 141
/* ----------------------------------------------------------------
 *					node types for executable expressions
 * ----------------------------------------------------------------
 */

142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
/*
 * CoercionContext - distinguishes the allowed set of type casts
 *
 * NB: ordering of the alternatives is significant; later (larger) values
 * allow more casts than earlier ones.
 */
typedef enum CoercionContext
{
	COERCION_IMPLICIT,			/* coercion in context of expression */
	COERCION_ASSIGNMENT,		/* coercion in context of assignment */
	COERCION_EXPLICIT			/* explicit cast operation */
} CoercionContext;

/*
 * CoercionForm - information showing how to display a function-call node
 */
typedef enum CoercionForm
{
	COERCE_EXPLICIT_CALL,		/* display as a function call */
	COERCE_EXPLICIT_CAST,		/* display as an explicit cast */
	COERCE_IMPLICIT_CAST,		/* implicit cast, so hide it */
	COERCE_DONTCARE				/* special case for pathkeys */
} CoercionForm;

166
/*
167
 * Expr
168 169 170 171 172 173
 *
 * Note: DISTINCT_EXPR implements the "x IS DISTINCT FROM y" construct.
 * This is similar to an OP_EXPR, except for its handling of NULL inputs.
 * The oper field is always an Oper node for the "=" operator for x and y.
 * (We use "=", not the more obvious "<>", because more datatypes have "="
 * than "<>".  This means the executor must invert the operator result.)
174
 */
175 176
typedef enum OpType
{
177 178
	OP_EXPR, DISTINCT_EXPR, FUNC_EXPR,
	OR_EXPR, AND_EXPR, NOT_EXPR, SUBPLAN_EXPR
179
} OpType;
180

181 182
typedef struct Expr
{
183
	NodeTag		type;
B
Bruce Momjian 已提交
184
	Oid			typeOid;		/* oid of the type of this expression */
185
	OpType		opType;			/* kind of expression */
B
Bruce Momjian 已提交
186 187 188
	Node	   *oper;			/* operator node if needed (Oper, Func, or
								 * SubPlan) */
	List	   *args;			/* arguments to this expression */
189
} Expr;
190

191
/*
192
 * Oper - Expr subnode for an OP_EXPR (or DISTINCT_EXPR)
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
 *
 * NOTE: in the good old days 'opno' used to be both (or either, or
 * neither) the pg_operator oid, and/or the pg_proc oid depending
 * on the postgres module in question (parser->pg_operator,
 * executor->pg_proc, planner->both), the mood of the programmer,
 * and the phase of the moon (rumors that it was also depending on the day
 * of the week are probably false). To make things even more postgres-like
 * (i.e. a mess) some comments were referring to 'opno' using the name
 * 'opid'. Anyway, now we have two separate fields, and of course that
 * immediately removes all bugs from the code...		[ sp :-) ].
 *
 * Note also that opid is not necessarily filled in immediately on creation
 * of the node.  The planner makes sure it is valid before passing the node
 * tree to the executor, but during parsing/planning opid is typically 0.
 */
typedef struct Oper
{
	NodeTag		type;
	Oid			opno;			/* PG_OPERATOR OID of the operator */
	Oid			opid;			/* PG_PROC OID of underlying function */
	Oid			opresulttype;	/* PG_TYPE OID of result value */
	bool		opretset;		/* true if operator returns set */
B
Bruce Momjian 已提交
215
	FunctionCachePtr op_fcache; /* runtime state, else NULL */
216 217 218 219 220 221 222 223 224
} Oper;

/*
 * Func - Expr subnode for a FUNC_EXPR
 */
typedef struct Func
{
	NodeTag		type;
	Oid			funcid;			/* PG_PROC OID of the function */
B
Bruce Momjian 已提交
225
	Oid			funcresulttype; /* PG_TYPE OID of result value */
226
	bool		funcretset;		/* true if function returns set */
227
	CoercionForm funcformat;	/* how to display this function call */
B
Bruce Momjian 已提交
228
	FunctionCachePtr func_fcache;		/* runtime state, or NULL */
229 230
} Func;

231
/*
232
 * Var
233 234 235 236 237 238 239 240 241
 *
 * Note: during parsing/planning, varnoold/varoattno are always just copies
 * of varno/varattno.  At the tail end of planning, Var nodes appearing in
 * upper-level plan nodes are reassigned to point to the outputs of their
 * subplans; for example, in a join node varno becomes INNER or OUTER and
 * varattno becomes the index of the proper element of that subplan's target
 * list.  But varnoold/varoattno continue to hold the original values.
 * The code doesn't really need varnoold/varoattno, but they are very useful
 * for debugging and interpreting completed plans, so we keep them around.
242
 */
243 244
#define    INNER		65000
#define    OUTER		65001
245

246 247
#define    PRS2_OLD_VARNO			1
#define    PRS2_NEW_VARNO			2
248

249 250
typedef struct Var
{
251
	NodeTag		type;
B
Bruce Momjian 已提交
252 253 254 255 256 257 258 259
	Index		varno;			/* index of this var's relation in the
								 * range table (could also be INNER or
								 * OUTER) */
	AttrNumber	varattno;		/* attribute number of this var, or zero
								 * for all */
	Oid			vartype;		/* pg_type tuple OID for the type of this
								 * var */
	int32		vartypmod;		/* pg_attribute typmod value */
260
	Index		varlevelsup;
B
Bruce Momjian 已提交
261 262 263 264 265 266 267

	/*
	 * for subquery variables referencing outer relations; 0 in a normal
	 * var, >0 means N levels up
	 */
	Index		varnoold;		/* original value of varno, for debugging */
	AttrNumber	varoattno;		/* original value of varattno */
268
} Var;
269

270
/*
271 272
 * Const
 */
273 274
typedef struct Const
{
275
	NodeTag		type;
276 277
	Oid			consttype;		/* PG_TYPE OID of the constant's datatype */
	int			constlen;		/* typlen of the constant's datatype */
278 279
	Datum		constvalue;		/* the constant's value */
	bool		constisnull;	/* whether the constant is null (if true,
280 281 282 283 284
								 * constvalue is undefined) */
	bool		constbyval;		/* whether this datatype is passed by value.
								 * If true, then all the information is
								 * stored in the Datum.
								 * If false, then the Datum contains a
B
Bruce Momjian 已提交
285
								 * pointer to the information. */
286
} Const;
287 288 289

/* ----------------
 * Param
290 291
 *		paramkind - specifies the kind of parameter. The possible values
 *		for this field are specified in "params.h", and they are:
292
 *
293 294
 *		PARAM_NAMED: The parameter has a name, i.e. something
 *				like `$.salary' or `$.foobar'.
295
 *				In this case field `paramname' must be a valid name.
296
 *
297 298 299
 *		PARAM_NUM:	 The parameter has only a numeric identifier,
 *				i.e. something like `$1', `$2' etc.
 *				The number is contained in the `paramid' field.
300
 *
301 302
 *		PARAM_EXEC:	 The parameter is an internal executor parameter.
 *				It has a number contained in the `paramid' field.
303 304 305
 *
 * ----------------
 */
306 307
typedef struct Param
{
308
	NodeTag		type;
309 310 311 312
	int			paramkind;		/* kind of parameter. See above */
	AttrNumber	paramid;		/* numeric ID for parameter ("$1") */
	char	   *paramname;		/* name for parameter ("$.foo") */
	Oid			paramtype;		/* PG_TYPE OID of parameter's datatype */
313
} Param;
314

315
/*
B
Bruce Momjian 已提交
316
 * Aggref
317
 */
B
Bruce Momjian 已提交
318
typedef struct Aggref
319
{
320
	NodeTag		type;
321 322 323
	Oid			aggfnoid;		/* pg_proc Oid of the aggregate */
	Oid			aggtype;		/* type Oid of result of the aggregate */
	Node	   *target;			/* expression we are aggregating on */
B
Bruce Momjian 已提交
324 325 326
	bool		aggstar;		/* TRUE if argument was really '*' */
	bool		aggdistinct;	/* TRUE if it's agg(DISTINCT ...) */
	int			aggno;			/* workspace for executor (see nodeAgg.c) */
327
} Aggref;
328

329 330
/* ----------------
 * SubLink
331
 *
332
 * A SubLink represents a subselect appearing in an expression, and in some
333
 * cases also the combining operator(s) just above it.	The subLinkType
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350
 * indicates the form of the expression represented:
 *	EXISTS_SUBLINK		EXISTS(SELECT ...)
 *	ALL_SUBLINK			(lefthand) op ALL (SELECT ...)
 *	ANY_SUBLINK			(lefthand) op ANY (SELECT ...)
 *	MULTIEXPR_SUBLINK	(lefthand) op (SELECT ...)
 *	EXPR_SUBLINK		(SELECT with single targetlist item ...)
 * For ALL, ANY, and MULTIEXPR, the lefthand is a list of expressions of the
 * same length as the subselect's targetlist.  MULTIEXPR will *always* have
 * a list with more than one entry; if the subselect has just one target
 * then the parser will create an EXPR_SUBLINK instead (and any operator
 * above the subselect will be represented separately).  Note that both
 * MULTIEXPR and EXPR require the subselect to deliver only one row.
 * ALL, ANY, and MULTIEXPR require the combining operators to deliver boolean
 * results.  These are reduced to one result per row using OR or AND semantics
 * depending on the "useor" flag.  ALL and ANY combine the per-row results
 * using AND and OR semantics respectively.
 *
351 352 353
 * NOTE: lefthand and oper have varying meanings depending on where you look
 * in the parse/plan pipeline:
 * 1. gram.y delivers a list of the (untransformed) lefthand expressions in
354 355
 *	  lefthand, and sets oper to a single A_Expr (not a list!) containing
 *	  the string name of the operator, but no arguments.
356
 * 2. The parser's expression transformation transforms lefthand normally,
357 358 359 360 361 362
 *	  and replaces oper with a list of Oper nodes, one per lefthand
 *	  expression.  These nodes represent the parser's resolution of exactly
 *	  which operator to apply to each pair of lefthand and targetlist
 *	  expressions.	However, we have not constructed actual Expr trees for
 *	  these operators yet.	This is the representation seen in saved rules
 *	  and in the rewriter.
363
 * 3. Finally, the planner converts the oper list to a list of normal Expr
364 365
 *	  nodes representing the application of the operator(s) to the lefthand
 *	  expressions and values from the inner targetlist.  The inner
366
 *	  targetlist items are represented by placeholder Param nodes.
367 368
 *	  The lefthand field is set to NIL, since its expressions are now in
 *	  the Expr list.  This representation is passed to the executor.
369 370 371 372 373 374
 *
 * Planner routines that might see either representation 2 or 3 can tell
 * the difference by checking whether lefthand is NIL or not.  Also,
 * representation 2 appears in a "bare" SubLink, while representation 3 is
 * found in SubLinks that are children of SubPlan nodes.
 *
375
 * In EXISTS and EXPR SubLinks, both lefthand and oper are unused and are
376
 * always NIL.	useor is not significant either for these sublink types.
377 378 379 380
 * ----------------
 */
typedef enum SubLinkType
{
381
	EXISTS_SUBLINK, ALL_SUBLINK, ANY_SUBLINK, MULTIEXPR_SUBLINK, EXPR_SUBLINK
382 383 384 385 386 387
} SubLinkType;


typedef struct SubLink
{
	NodeTag		type;
B
Bruce Momjian 已提交
388 389 390 391 392 393 394 395
	SubLinkType subLinkType;	/* EXISTS, ALL, ANY, MULTIEXPR, EXPR */
	bool		useor;			/* TRUE to combine column results with
								 * "OR" not "AND" */
	List	   *lefthand;		/* list of outer-query expressions on the
								 * left */
	List	   *oper;			/* list of Oper nodes for combining
								 * operators */
	Node	   *subselect;		/* subselect as Query* or parsetree */
396 397
} SubLink;

398
/* ----------------
399 400 401 402 403 404
 *	ArrayRef: describes an array subscripting operation
 *
 * An ArrayRef can describe fetching a single element from an array,
 * fetching a subarray (array slice), storing a single element into
 * an array, or storing a slice.  The "store" cases work with an
 * initial array value and a source value that is inserted into the
405 406
 * appropriate part of the array; the result of the operation is an
 * entire new modified array value.
407 408
 *
 * If reflowerindexpr = NIL, then we are fetching or storing a single array
409
 * element at the subscripts given by refupperindexpr.	Otherwise we are
410 411 412 413 414 415 416
 * fetching or storing an array slice, that is a rectangular subarray
 * with lower and upper bounds given by the index expressions.
 * reflowerindexpr must be the same length as refupperindexpr when it
 * is not NIL.
 *
 * Note: array types can be fixed-length (refattrlength > 0), but only
 * when the element type is itself fixed-length.  Otherwise they are
417
 * varlena structures and have refattrlength = -1.	In any case,
418 419
 * an array type is never pass-by-value.
 *
420 421 422
 * Note: refrestype is NOT the element type, but the array type,
 * when doing subarray fetch or either type of store.  It might be a good
 * idea to include a refelemtype field as well.
423 424
 * ----------------
 */
425 426
typedef struct ArrayRef
{
427
	NodeTag		type;
428 429
	Oid			refrestype;		/* type of the result of the ArrayRef
								 * operation */
B
Bruce Momjian 已提交
430 431 432
	int			refattrlength;	/* typlen of array type */
	int			refelemlength;	/* typlen of the array element type */
	bool		refelembyval;	/* is the element type pass-by-value? */
433
	char		refelemalign;	/* typalign of the element type */
B
Bruce Momjian 已提交
434 435 436 437 438 439 440 441
	List	   *refupperindexpr;/* expressions that evaluate to upper
								 * array indexes */
	List	   *reflowerindexpr;/* expressions that evaluate to lower
								 * array indexes */
	Node	   *refexpr;		/* the expression that evaluates to an
								 * array value */
	Node	   *refassgnexpr;	/* expression for the source value, or
								 * NULL if fetch */
B
Bruce Momjian 已提交
442
} ArrayRef;
443

444 445 446 447 448 449 450 451 452 453 454 455 456
/* ----------------
 * FieldSelect
 *
 * FieldSelect represents the operation of extracting one field from a tuple
 * value.  At runtime, the input expression is expected to yield a Datum
 * that contains a pointer-to-TupleTableSlot.  The specified field number
 * is extracted and returned as a Datum.
 * ----------------
 */

typedef struct FieldSelect
{
	NodeTag		type;
457 458 459 460 461
	Node	   *arg;			/* input expression */
	AttrNumber	fieldnum;		/* attribute number of field to extract */
	Oid			resulttype;		/* type of the field (result type of this
								 * node) */
	int32		resulttypmod;	/* output typmod (usually -1) */
462 463
} FieldSelect;

464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
/* ----------------
 * RelabelType
 *
 * RelabelType represents a "dummy" type coercion between two binary-
 * compatible datatypes, such as reinterpreting the result of an OID
 * expression as an int4.  It is a no-op at runtime; we only need it
 * to provide a place to store the correct type to be attributed to
 * the expression result during type resolution.  (We can't get away
 * with just overwriting the type field of the input expression node,
 * so we need a separate node to show the coercion's result type.)
 * ----------------
 */

typedef struct RelabelType
{
	NodeTag		type;
480 481 482
	Node	   *arg;			/* input expression */
	Oid			resulttype;		/* output type of coercion expression */
	int32		resulttypmod;	/* output typmod (usually -1) */
483
	CoercionForm relabelformat;	/* how to display this node */
484 485
} RelabelType;

486 487 488 489 490 491

/* ----------------------------------------------------------------
 *					node types for join trees
 *
 * The leaves of a join tree structure are RangeTblRef nodes.  Above
 * these, JoinExpr nodes can appear to denote a specific kind of join
492 493 494 495 496 497 498 499 500 501 502 503
 * or qualified join.  Also, FromExpr nodes can appear to denote an
 * ordinary cross-product join ("FROM foo, bar, baz WHERE ...").
 * FromExpr is like a JoinExpr of jointype JOIN_INNER, except that it
 * may have any number of child nodes, not just two.  Also, there is an
 * implementation-defined difference: the planner is allowed to join the
 * children of a FromExpr using whatever join order seems good to it.
 * At present, JoinExpr nodes are always joined in exactly the order
 * implied by the jointree structure (except the planner may choose to
 * swap inner and outer members of a join pair).
 *
 * NOTE: the top level of a Query's jointree is always a FromExpr.
 * Even if the jointree contains no rels, there will be a FromExpr.
504 505
 *
 * NOTE: the qualification expressions present in JoinExpr nodes are
506
 * *in addition to* the query's main WHERE clause, which appears as the
B
Bruce Momjian 已提交
507
 * qual of the top-level FromExpr.	The reason for associating quals with
508 509 510 511 512
 * specific nodes in the jointree is that the position of a qual is critical
 * when outer joins are present.  (If we enforce a qual too soon or too late,
 * that may cause the outer join to produce the wrong set of NULL-extended
 * rows.)  If all joins are inner joins then all the qual positions are
 * semantically interchangeable.
513
 *
514 515 516 517 518
 * NOTE: in the raw output of gram.y, a join tree contains RangeVar,
 * RangeSubselect, and RangeFunction nodes, which are all replaced by
 * RangeTblRef nodes during the parse analysis phase.  Also, the top-level
 * FromExpr is added during parse analysis; the grammar regards FROM and
 * WHERE as separate.
519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537
 * ----------------------------------------------------------------
 */

/*
 * RangeTblRef - reference to an entry in the query's rangetable
 *
 * We could use direct pointers to the RT entries and skip having these
 * nodes, but multiple pointers to the same node in a querytree cause
 * lots of headaches, so it seems better to store an index into the RT.
 */
typedef struct RangeTblRef
{
	NodeTag		type;
	int			rtindex;
} RangeTblRef;

/*----------
 * JoinExpr - for SQL JOIN expressions
 *
B
Bruce Momjian 已提交
538
 * isNatural, using, and quals are interdependent.	The user can write only
539 540 541 542
 * one of NATURAL, USING(), or ON() (this is enforced by the grammar).
 * If he writes NATURAL then parse analysis generates the equivalent USING()
 * list, and from that fills in "quals" with the right equality comparisons.
 * If he writes USING() then "quals" is filled with equality comparisons.
B
Bruce Momjian 已提交
543
 * If he writes ON() then only "quals" is set.	Note that NATURAL/USING
544 545
 * are not equivalent to ON() since they also affect the output column list.
 *
546
 * alias is an Alias node representing the AS alias-clause attached to the
547 548 549 550
 * join expression, or NULL if no clause.  NB: presence or absence of the
 * alias has a critical impact on semantics, because a join with an alias
 * restricts visibility of the tables/columns inside it.
 *
551
 * During parse analysis, an RTE is created for the Join, and its index
B
Bruce Momjian 已提交
552
 * is filled into rtindex.	This RTE is present mainly so that Vars can
553
 * be created that refer to the outputs of the join.
554 555 556 557 558 559 560 561 562 563 564
 *----------
 */
typedef struct JoinExpr
{
	NodeTag		type;
	JoinType	jointype;		/* type of join */
	bool		isNatural;		/* Natural join? Will need to shape table */
	Node	   *larg;			/* left subtree */
	Node	   *rarg;			/* right subtree */
	List	   *using;			/* USING clause, if any (list of String) */
	Node	   *quals;			/* qualifiers on join, if any */
565
	Alias	   *alias;			/* user-written alias clause, if any */
566
	int			rtindex;		/* RT index assigned for join */
567 568
} JoinExpr;

569 570 571 572 573 574 575 576 577 578 579 580 581 582 583
/*----------
 * FromExpr - represents a FROM ... WHERE ... construct
 *
 * This is both more flexible than a JoinExpr (it can have any number of
 * children, including zero) and less so --- we don't need to deal with
 * aliases and so on.  The output column set is implicitly just the union
 * of the outputs of the children.
 *----------
 */
typedef struct FromExpr
{
	NodeTag		type;
	List	   *fromlist;		/* List of join subtrees */
	Node	   *quals;			/* qualifiers on join, if any */
} FromExpr;
584

585
#endif   /* PRIMNODES_H */