execnodes.h 23.5 KB
Newer Older
1 2
/*-------------------------------------------------------------------------
 *
3
 * execnodes.h
4
 *	  definitions for executor state nodes
5 6 7 8
 *
 *
 * Copyright (c) 1994, Regents of the University of California
 *
9
 * $Id: execnodes.h,v 1.36 1999/09/26 21:21:04 tgl Exp $
10 11 12 13 14 15
 *
 *-------------------------------------------------------------------------
 */
#ifndef EXECNODES_H
#define EXECNODES_H

Bruce Momjian's avatar
Bruce Momjian committed
16
#include "access/funcindex.h"
17 18
#include "access/relscan.h"
#include "access/sdir.h"
Bruce Momjian's avatar
Bruce Momjian committed
19
#include "executor/hashjoin.h"
20
#include "executor/tuptable.h"
Bruce Momjian's avatar
Bruce Momjian committed
21 22
#include "nodes/params.h"
#include "nodes/primnodes.h"
23 24

/* ----------------
25
 *	  IndexInfo information
26
 *
27 28
 *		this class holds the information saying what attributes
 *		are the key attributes for this index. -cim 10/15/89
29
 *
30 31 32
 *		NumKeyAttributes		number of key attributes for this index
 *		KeyAttributeNumbers		array of attribute numbers used as keys
 *		Predicate				partial-index predicate for this index
33 34
 * ----------------
 */
35 36
typedef struct IndexInfo
{
37 38 39
	NodeTag		type;
	int			ii_NumKeyAttributes;
	AttrNumber *ii_KeyAttributeNumbers;
40
	FuncIndexInfoPtr ii_FuncIndexInfo;
41
	Node	   *ii_Predicate;
42
} IndexInfo;
43 44

/* ----------------
45 46 47 48 49 50 51 52 53 54 55 56
 *	  RelationInfo information
 *
 *		whenever we update an existing relation, we have to
 *		update indices on the relation.  The RelationInfo class
 *		is used to hold all the information on result relations,
 *		including indices.. -cim 10/15/89
 *
 *		RangeTableIndex			result relation's range table index
 *		RelationDesc			relation descriptor for result relation
 *		NumIndices				number indices existing on result relation
 *		IndexRelationDescs		array of relation descriptors for indices
 *		IndexRelationInfo		array of key/attr info for indices
57 58
 * ----------------
 */
59 60
typedef struct RelationInfo
{
61 62 63 64 65 66
	NodeTag		type;
	Index		ri_RangeTableIndex;
	Relation	ri_RelationDesc;
	int			ri_NumIndices;
	RelationPtr ri_IndexRelationDescs;
	IndexInfo **ri_IndexRelationInfo;
67
} RelationInfo;
68 69

/* ----------------
70 71 72 73 74 75 76 77
 *	  ExprContext
 *
 *		This class holds the "current context" information
 *		needed to evaluate expressions for doing tuple qualifications
 *		and tuple projections.	For example, if an expression refers
 *		to an attribute in the current inner tuple then we need to know
 *		what the current inner tuple is and so we look at the expression
 *		context.
78 79
 * ----------------
 */
80 81
typedef struct ExprContext
{
82 83 84 85 86 87 88 89 90
	NodeTag		type;
	TupleTableSlot *ecxt_scantuple;
	TupleTableSlot *ecxt_innertuple;
	TupleTableSlot *ecxt_outertuple;
	Relation	ecxt_relation;
	Index		ecxt_relid;
	ParamListInfo ecxt_param_list_info;
	ParamExecData *ecxt_param_exec_vals;		/* this is for subselects */
	List	   *ecxt_range_table;
91 92
	Datum	   *ecxt_aggvalues;	/* precomputed values for Aggref nodes */
	bool	   *ecxt_aggnulls;	/* null flags for Aggref nodes */
93
} ExprContext;
94 95

/* ----------------
96 97 98 99 100 101 102 103 104 105 106 107 108
 *		ProjectionInfo node information
 *
 *		This is all the information needed to preform projections
 *		on a tuple.  Nodes which need to do projections create one
 *		of these.  In theory, when a node wants to preform a projection
 *		it should just update this information as necessary and then
 *		call ExecProject().  -cim 6/3/91
 *
 *		targetlist		target list for projection
 *		len				length of target list
 *		tupValue		array of pointers to projection results
 *		exprContext		expression context for ExecTargetList
 *		slot			slot to place projection result in
109 110
 * ----------------
 */
111 112
typedef struct ProjectionInfo
{
113 114 115 116 117
	NodeTag		type;
	List	   *pi_targetlist;
	int			pi_len;
	Datum	   *pi_tupValue;
	ExprContext *pi_exprContext;
118
	TupleTableSlot *pi_slot;
119
} ProjectionInfo;
120 121

/* ----------------
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
 *	  JunkFilter
 *
 *	  this class is used to store information regarding junk attributes.
 *	  A junk attribute is an attribute in a tuple that is needed only for
 *	  storing intermediate information in the executor, and does not belong
 *	  in the tuple proper.	For example, when we do a delete or replace
 *	  query, the planner adds an entry to the targetlist so that the tuples
 *	  returned to ExecutePlan() contain an extra attribute: the t_ctid of
 *	  the tuple to be deleted/replaced.  This is needed for amdelete() and
 *	  amreplace().	In doing a delete this does not make much of a
 *	  difference, but in doing a replace we have to make sure we disgard
 *	  all the junk in a tuple before calling amreplace().  Otherwise the
 *	  inserted tuple will not have the correct schema.	This solves a
 *	  problem with hash-join and merge-sort replace plans.	-cim 10/10/90
 *
 *	  targetList:		the original target list (including junk attributes).
 *	  length:			the length of 'targetList'.
 *	  tupType:			the tuple descriptor for the "original" tuple
 *						(including the junk attributes).
 *	  cleanTargetList:	the "clean" target list (junk attributes removed).
 *	  cleanLength:		the length of 'cleanTargetList'
 *	  cleanTupTyp:		the tuple descriptor of the "clean" tuple (with
 *						junk attributes removed).
 *	  cleanMap:			A map with the correspondance between the non junk
 *						attributes of the "original" tuple and the
 *						attributes of the "clean" tuple.
148 149
 * ----------------
 */
150 151
typedef struct JunkFilter
{
152 153 154 155 156 157 158 159
	NodeTag		type;
	List	   *jf_targetList;
	int			jf_length;
	TupleDesc	jf_tupType;
	List	   *jf_cleanTargetList;
	int			jf_cleanLength;
	TupleDesc	jf_cleanTupType;
	AttrNumber *jf_cleanMap;
160
} JunkFilter;
161 162

/* ----------------
163
 *	  EState information
164
 *
165
 *		direction						direction of the scan
166
 *
167
 *		range_table						array of scan relation information
168
 *
169
 *		result_relation_information		for update queries
170
 *
171
 *		into_relation_descriptor		relation being retrieved "into"
172
 *
173 174
 *		param_list_info					information needed to transform
 *										Param nodes into Const nodes
175
 *
176 177 178
 *		BaseId							during InitPlan(), each node is
 *										given a number.  this is the next
 *										number to be assigned.
179
 *
180 181 182
 *		tupleTable						this is a pointer to an array
 *										of pointers to tuples used by
 *										the executor at any given moment.
183
 *
184 185 186
 *		junkFilter						contains information used to
 *										extract junk attributes from a tuple.
 *										(see JunkFilter above)
187
 *
188 189 190 191 192
 *		refcount						local buffer refcounts used in
 *										an ExecMain cycle.	this is introduced
 *										to avoid ExecStart's unpinning each
 *										other's buffers when called recursively
 * ----------------
193
 */
194 195
typedef struct EState
{
Bruce Momjian's avatar
Bruce Momjian committed
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
	NodeTag		type;
	ScanDirection es_direction;
	Snapshot	es_snapshot;
	List	   *es_range_table;
	RelationInfo *es_result_relation_info;
	List	  **es_result_relation_constraints;
	Relation	es_into_relation_descriptor;
	ParamListInfo es_param_list_info;
	ParamExecData *es_param_exec_vals;	/* this is for subselects */
	int			es_BaseId;
	TupleTable	es_tupleTable;
	JunkFilter *es_junkFilter;
	uint32		es_processed;	/* # of tuples processed */
	Oid			es_lastoid;		/* last oid processed (by INSERT) */
	List	   *es_rowMark;		/* not good place, but there is no other */
211
	/* Below is to re-evaluate plan qual in READ COMMITTED mode */
Bruce Momjian's avatar
Bruce Momjian committed
212 213 214 215 216
	struct Plan *es_origPlan;
	Pointer		es_evalPlanQual;
	bool	   *es_evTupleNull;
	HeapTuple  *es_evTuple;
	bool		es_useEvalPlan;
217
} EState;
218 219

/* ----------------
220 221 222 223 224 225 226 227
 *		Executor Type information needed by plannodes.h
 *
 *|		Note: the bogus classes CommonState and CommonScanState exist only
 *|			  because our inheritance system only allows single inheritance
 *|			  and we have to have unique slot names.  Hence two or more
 *|			  classes which want to have a common slot must ALL inherit
 *|			  the slot from some other class.  (This is a big hack to
 *|			  allow our classes to share slot names..)
228
 *|
229 230 231 232 233 234 235
 *|		Example:
 *|			  the class Result and the class NestLoop nodes both want
 *|			  a slot called "OuterTuple" so they both have to inherit
 *|			  it from some other class.  In this case they inherit
 *|			  it from CommonState.	"CommonState" and "CommonScanState" are
 *|			  the best names I could come up with for this sort of
 *|			  stuff.
236
 *|
237 238 239 240 241 242
 *|			  As a result, many classes have extra slots which they
 *|			  don't use.  These slots are denoted (unused) in the
 *|			  comment preceeding the class definition.	If you
 *|			  comes up with a better idea of a way of doing things
 *|			  along these lines, then feel free to make your idea
 *|			  known to me.. -cim 10/15/89
243 244 245 246
 * ----------------
 */

/* ----------------------------------------------------------------
247
 *				 Common Executor State Information
248 249 250
 * ----------------------------------------------------------------
 */

251
/* BaseNode removed -- base_id moved into CommonState		- jolly */
252 253

/* ----------------
254
 *	 CommonState information
255
 *
256 257
 *|		this is a bogus class used to hold slots so other
 *|		nodes can inherit them...
258
 *
259 260 261 262 263 264
 *		OuterTupleSlot	   pointer to slot containing current "outer" tuple
 *		ResultTupleSlot    pointer to slot in tuple table for projected tuple
 *		ExprContext		   node's current expression context
 *		ProjInfo		   info this node uses to form tuple projections
 *		NumScanAttributes  size of ScanAttributes array
 *		ScanAttributes	   attribute numbers of interest in this tuple
265 266 267
 *
 * ----------------
 */
268 269
typedef struct CommonState
{
270 271
	NodeTag		type;			/* its first field is NodeTag */
	int			cs_base_id;
272 273
	TupleTableSlot *cs_OuterTupleSlot;
	TupleTableSlot *cs_ResultTupleSlot;
274
	ExprContext *cs_ExprContext;
275
	ProjectionInfo *cs_ProjInfo;
276
	bool		cs_TupFromTlist;
277
} CommonState;
278 279 280


/* ----------------------------------------------------------------
281
 *				 Control Node State Information
282 283 284 285
 * ----------------------------------------------------------------
 */

/* ----------------
286
 *	 ResultState information
287
 *
288 289
 *		done			   flag which tells us to quit when we
 *						   have already returned a constant tuple.
290
 *
291
 *	 CommonState information
292
 *
293 294 295 296 297 298
 *		OuterTupleSlot	   pointer to slot containing current "outer" tuple
 *		ResultTupleSlot    pointer to slot in tuple table for projected tuple
 *		ExprContext		   node's current expression context
 *		ProjInfo		   info this node uses to form tuple projections
 *		NumScanAttributes  size of ScanAttributes array
 *		ScanAttributes	   attribute numbers of interest in this tuple
299 300
 * ----------------
 */
301 302
typedef struct ResultState
{
303
	CommonState cstate;			/* its first field is NodeTag */
304 305
	bool		rs_done;
	bool		rs_checkqual;
306
} ResultState;
307 308

/* ----------------
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329
 *	 AppendState information
 *
 *		append nodes have this field "unionplans" which is this
 *		list of plans to execute in sequence..	these variables
 *		keep track of things..
 *
 *		whichplan		which plan is being executed
 *		nplans			how many plans are in the list
 *		initialized		array of ExecInitNode() results
 *		rtentries		range table for the current plan
 *		result_relation_info_list  array of each subplan's result relation info
 *		junkFilter_list  array of each subplan's junk filter
 *
 *	 CommonState information
 *
 *		OuterTupleSlot	   pointer to slot containing current "outer" tuple
 *		ResultTupleSlot    pointer to slot in tuple table for projected tuple
 *		ExprContext		   node's current expression context
 *		ProjInfo		   info this node uses to form tuple projections
 *		NumScanAttributes  size of ScanAttributes array
 *		ScanAttributes	   attribute numbers of interest in this tuple
330 331
 * ----------------
 */
332 333
typedef struct AppendState
{
334 335 336 337 338 339 340
	CommonState cstate;			/* its first field is NodeTag */
	int			as_whichplan;
	int			as_nplans;
	bool	   *as_initialized;
	List	   *as_rtentries;
	List	   *as_result_relation_info_list;
	List	   *as_junkFilter_list;
Bruce Momjian's avatar
Bruce Momjian committed
341
} AppendState;
342 343

/* ----------------------------------------------------------------
344
 *				 Scan State Information
345 346 347 348
 * ----------------------------------------------------------------
 */

/* ----------------
349
 *	 CommonScanState information
350
 *
351 352 353
 *		CommonScanState is a class like CommonState, but is used more
 *		by the nodes like SeqScan and Sort which want to
 *		keep track of an underlying relation.
354
 *
355 356 357
 *		currentRelation    relation being scanned
 *		currentScanDesc    current scan descriptor for scan
 *		ScanTupleSlot	   pointer to slot in tuple table holding scan tuple
358
 *
359
 *	 CommonState information
360
 *
361 362 363 364 365 366
 *		OuterTupleSlot	   pointer to slot containing current "outer" tuple
 *		ResultTupleSlot    pointer to slot in tuple table for projected tuple
 *		ExprContext		   node's current expression context
 *		ProjInfo		   info this node uses to form tuple projections
 *		NumScanAttributes  size of ScanAttributes array
 *		ScanAttributes	   attribute numbers of interest in this tuple
367 368
 * ----------------
 */
369 370
typedef struct CommonScanState
{
371 372 373
	CommonState cstate;			/* its first field is NodeTag */
	Relation	css_currentRelation;
	HeapScanDesc css_currentScanDesc;
374
	TupleTableSlot *css_ScanTupleSlot;
375
} CommonScanState;
376 377

/* ----------------
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400
 *	 IndexScanState information
 *
 *|		index scans don't use CommonScanState because
 *|		the underlying AM abstractions for heap scans and
 *|		index scans are too different..  It would be nice
 *|		if the current abstraction was more useful but ... -cim 10/15/89
 *
 *		IndexPtr		   current index in use
 *		NumIndices		   number of indices in this scan
 *		ScanKeys		   Skey structures to scan index rels
 *		NumScanKeys		   array of no of keys in each Skey struct
 *		RuntimeKeyInfo	   array of array of flags for Skeys evaled at runtime
 *		RelationDescs	   ptr to array of relation descriptors
 *		ScanDescs		   ptr to array of scan descriptors
 *
 *	 CommonState information
 *
 *		OuterTupleSlot	   pointer to slot containing current "outer" tuple
 *		ResultTupleSlot    pointer to slot in tuple table for projected tuple
 *		ExprContext		   node's current expression context
 *		ProjInfo		   info this node uses to form tuple projections
 *		NumScanAttributes  size of ScanAttributes array
 *		ScanAttributes	   attribute numbers of interest in this tuple
401 402
 * ----------------
 */
403 404
typedef struct IndexScanState
{
Bruce Momjian's avatar
Bruce Momjian committed
405 406 407 408 409 410 411 412 413 414
	CommonState cstate;			/* its first field is NodeTag */
	int			iss_NumIndices;
	int			iss_IndexPtr;
	int			iss_MarkIndexPtr;
	ScanKey    *iss_ScanKeys;
	int		   *iss_NumScanKeys;
	Pointer		iss_RuntimeKeyInfo;
	RelationPtr iss_RelationDescs;
	IndexScanDescPtr iss_ScanDescs;
	HeapTupleData iss_htup;
415
} IndexScanState;
416 417 418


/* ----------------------------------------------------------------
419
 *				 Join State Information
420 421 422 423
 * ----------------------------------------------------------------
 */

/* ----------------
424
 *	 JoinState information
425
 *
426
 *	 CommonState information
427
 *
428 429 430 431 432 433
 *		OuterTupleSlot	   pointer to slot containing current "outer" tuple
 *		ResultTupleSlot    pointer to slot in tuple table for projected tuple
 *		ExprContext		   node's current expression context
 *		ProjInfo		   info this node uses to form tuple projections
 *		NumScanAttributes  size of ScanAttributes array
 *		ScanAttributes	   attribute numbers of interest in this tuple
434 435
 * ----------------
 */
436
typedef CommonState JoinState;
437 438

/* ----------------
439
 *	 NestLoopState information
440
 *
441
 *		PortalFlag		   Set to enable portals to work.
442
 *
443
 *	 JoinState information
444
 *
445
 *	 CommonState information
446
 *
447 448 449 450 451 452
 *		OuterTupleSlot	   pointer to slot containing current "outer" tuple
 *		ResultTupleSlot    pointer to slot in tuple table for projected tuple
 *		ExprContext		   node's current expression context
 *		ProjInfo		   info this node uses to form tuple projections
 *		NumScanAttributes  size of ScanAttributes array
 *		ScanAttributes	   attribute numbers of interest in this tuple
453 454
 * ----------------
 */
455 456
typedef struct NestLoopState
{
457 458
	JoinState	jstate;			/* its first field is NodeTag */
	bool		nl_PortalFlag;
459
} NestLoopState;
460 461

/* ----------------
462
 *	 MergeJoinState information
463
 *
464 465
 *		OuterSkipQual	   outerKey1 < innerKey1 ...
 *		InnerSkipQual	   outerKey1 > innerKey1 ...
466 467
 *		JoinState		   current "state" of join. see executor.h
 *		MarkedTupleSlot    pointer to slot in tuple table for marked tuple
468
 *
469
 *	 JoinState information
470
 *
471
 *	 CommonState information
472
 *
473 474 475 476 477 478
 *		OuterTupleSlot	   pointer to slot containing current "outer" tuple
 *		ResultTupleSlot    pointer to slot in tuple table for projected tuple
 *		ExprContext		   node's current expression context
 *		ProjInfo		   info this node uses to form tuple projections
 *		NumScanAttributes  size of ScanAttributes array
 *		ScanAttributes	   attribute numbers of interest in this tuple
479 480
 * ----------------
 */
481 482
typedef struct MergeJoinState
{
483
	JoinState	jstate;			/* its first field is NodeTag */
484 485
	List	   *mj_OuterSkipQual;
	List	   *mj_InnerSkipQual;
486
	int			mj_JoinState;
487
	TupleTableSlot *mj_MarkedTupleSlot;
488
} MergeJoinState;
489 490

/* ----------------
491 492
 *	 HashJoinState information
 *
493 494 495 496 497 498
 *		hj_HashTable			hash table for the hashjoin
 *		hj_CurBucketNo			bucket# for current outer tuple
 *		hj_CurTuple				last inner tuple matched to current outer
 *								tuple, or NULL if starting search
 *								(CurBucketNo and CurTuple are meaningless
 *								 unless OuterTupleSlot is nonempty!)
499 500 501 502 503 504 505 506 507 508 509 510 511 512
 *		hj_InnerHashKey			the inner hash key in the hashjoin condition
 *		hj_OuterTupleSlot		tuple slot for outer tuples
 *		hj_HashTupleSlot		tuple slot for hashed tuples
 *
 *	 JoinState information
 *
 *	 CommonState information
 *
 *		OuterTupleSlot	   pointer to slot containing current "outer" tuple
 *		ResultTupleSlot    pointer to slot in tuple table for projected tuple
 *		ExprContext		   node's current expression context
 *		ProjInfo		   info this node uses to form tuple projections
 *		NumScanAttributes  size of ScanAttributes array
 *		ScanAttributes	   attribute numbers of interest in this tuple
513 514
 * ----------------
 */
515 516
typedef struct HashJoinState
{
517
	JoinState	jstate;			/* its first field is NodeTag */
Bruce Momjian's avatar
Bruce Momjian committed
518 519 520 521
	HashJoinTable hj_HashTable;
	int			hj_CurBucketNo;
	HashJoinTuple hj_CurTuple;
	Var		   *hj_InnerHashKey;
522 523
	TupleTableSlot *hj_OuterTupleSlot;
	TupleTableSlot *hj_HashTupleSlot;
524
} HashJoinState;
525 526 527


/* ----------------------------------------------------------------
528
 *				 Materialization State Information
529 530 531 532
 * ----------------------------------------------------------------
 */

/* ----------------
533
 *	 MaterialState information
534
 *
535 536
 *		materialize nodes are used to materialize the results
 *		of a subplan into a temporary relation.
537
 *
538 539 540
 *		Flag			indicated whether subplan has been materialized
 *		TempRelation	temporary relation containing result of executing
 *						the subplan.
541
 *
542
 *	 CommonScanState information
543
 *
544 545 546
 *		currentRelation    relation descriptor of sorted relation
 *		currentScanDesc    current scan descriptor for scan
 *		ScanTupleSlot	   pointer to slot in tuple table holding scan tuple
547
 *
548
 *	 CommonState information
549
 *
550 551 552 553 554 555
 *		OuterTupleSlot	   pointer to slot containing current "outer" tuple
 *		ResultTupleSlot    pointer to slot in tuple table for projected tuple
 *		ExprContext		   node's current expression context
 *		ProjInfo		   info this node uses to form tuple projections
 *		NumScanAttributes  size of ScanAttributes array
 *		ScanAttributes	   attribute numbers of interest in this tuple
556 557
 * ----------------
 */
558 559 560
typedef struct MaterialState
{
	CommonScanState csstate;	/* its first field is NodeTag */
561 562
	bool		mat_Flag;
	Relation	mat_TempRelation;
563
} MaterialState;
564 565

/* ---------------------
566
 *	AggregateState information
567
 *
568 569 570
 *	Note: the associated ExprContext contains ecxt_aggvalues and ecxt_aggnulls
 *	arrays, which hold the computed agg values for the current input group
 *	during evaluation of an Agg node's output tuple(s).
571 572
 * -------------------------
 */
573 574
typedef struct AggStatePerAggData *AggStatePerAgg; /* private in nodeAgg.c */

575 576 577
typedef struct AggState
{
	CommonScanState csstate;	/* its first field is NodeTag */
578
	List	   *aggs;			/* all Aggref nodes in targetlist & quals */
579 580 581
	int			numaggs;		/* length of list (could be zero!) */
	AggStatePerAgg peragg;		/* per-Aggref working state */
	bool		agg_done;		/* indicates completion of Agg scan */
Bruce Momjian's avatar
Bruce Momjian committed
582
} AggState;
583 584

/* ---------------------
585
 *	GroupState information
586 587 588
 *
 * -------------------------
 */
589 590
typedef struct GroupState
{
591 592
	CommonScanState csstate;	/* its first field is NodeTag */
	bool		grp_useFirstTuple;		/* first tuple not processed yet */
593
	bool		grp_done;
Vadim B. Mikheev's avatar
Vadim B. Mikheev committed
594
	HeapTuple	grp_firstTuple;
595
} GroupState;
596 597

/* ----------------
598 599 600
 *	 SortState information
 *
 *|		sort nodes are really just a kind of a scan since
601
 *|		we implement sorts by retrieving the entire subplan
602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625
 *|		into a temp relation, sorting the temp relation into
 *|		another sorted relation, and then preforming a simple
 *|		unqualified sequential scan on the sorted relation..
 *|		-cim 10/15/89
 *
 *		Flag			indicated whether relation has been sorted
 *		Keys			scan key structures used to keep info on sort keys
 *		TempRelation	temporary relation containing result of executing
 *						the subplan.
 *
 *	 CommonScanState information
 *
 *		currentRelation    relation descriptor of sorted relation
 *		currentScanDesc    current scan descriptor for scan
 *		ScanTupleSlot	   pointer to slot in tuple table holding scan tuple
 *
 *	 CommonState information
 *
 *		OuterTupleSlot	   pointer to slot containing current "outer" tuple
 *		ResultTupleSlot    pointer to slot in tuple table for projected tuple
 *		ExprContext		   node's current expression context
 *		ProjInfo		   info this node uses to form tuple projections
 *		NumScanAttributes  size of ScanAttributes array
 *		ScanAttributes	   attribute numbers of interest in this tuple
626 627
 * ----------------
 */
628 629 630
typedef struct SortState
{
	CommonScanState csstate;	/* its first field is NodeTag */
631 632 633
	bool		sort_Flag;
	ScanKey		sort_Keys;
	bool		cleaned;
634
} SortState;
635 636

/* ----------------
637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653
 *	 UniqueState information
 *
 *		Unique nodes are used "on top of" sort nodes to discard
 *		duplicate tuples returned from the sort phase.	Basically
 *		all it does is compare the current tuple from the subplan
 *		with the previously fetched tuple stored in OuterTuple and
 *		if the two are identical, then we just fetch another tuple
 *		from the sort and try again.
 *
 *	 CommonState information
 *
 *		OuterTupleSlot	   pointer to slot containing current "outer" tuple
 *		ResultTupleSlot    pointer to slot in tuple table for projected tuple
 *		ExprContext		   node's current expression context
 *		ProjInfo		   info this node uses to form tuple projections
 *		NumScanAttributes  size of ScanAttributes array
 *		ScanAttributes	   attribute numbers of interest in this tuple
654 655
 * ----------------
 */
656
typedef CommonState UniqueState;
657 658 659


/* ----------------
660
 *	 HashState information
661
 *
662
 *		hashtable			hash table for the hashjoin
663
 *
664
 *	 CommonState information
665
 *
666 667 668 669 670 671
 *		OuterTupleSlot	   pointer to slot containing current "outer" tuple
 *		ResultTupleSlot    pointer to slot in tuple table for projected tuple
 *		ExprContext		   node's current expression context
 *		ProjInfo		   info this node uses to form tuple projections
 *		NumScanAttributes  size of ScanAttributes array
 *		ScanAttributes	   attribute numbers of interest in this tuple
672 673
 * ----------------
 */
674 675
typedef struct HashState
{
676
	CommonState cstate;			/* its first field is NodeTag */
677
	HashJoinTable hashtable;
678
} HashState;
679

680
#ifdef NOT_USED
681
/* -----------------------
682 683 684 685 686 687 688 689 690 691
 *	TeeState information
 *	  leftPlace  :	  next item in the queue unseen by the left parent
 *	  rightPlace :	  next item in the queue unseen by the right parent
 *	  lastPlace  :	  last item in the queue
 *	  bufferRelname :  name of the relation used as the buffer queue
 *	  bufferRel		:  the relation used as the buffer queue
 *	  mcxt			:  for now, tee's have their own memory context
 *					   may be cleaned up later if portals are cleaned up
 *
 * initially, a Tee starts with [left/right]Place variables set to	-1.
692
 * on cleanup, queue is free'd when both leftPlace and rightPlace = -1
693
 * -------------------------
694
*/
695 696
typedef struct TeeState
{
Bruce Momjian's avatar
Bruce Momjian committed
697 698 699 700 701 702
	CommonState cstate;			/* its first field is NodeTag */
	int			tee_leftPlace,
				tee_rightPlace,
				tee_lastPlace;
	char	   *tee_bufferRelname;
	Relation	tee_bufferRel;
703
	MemoryContext tee_mcxt;
Bruce Momjian's avatar
Bruce Momjian committed
704 705
	HeapScanDesc tee_leftScanDesc,
				tee_rightScanDesc;
706
}			TeeState;
Bruce Momjian's avatar
Bruce Momjian committed
707

708
#endif
709

710
#endif	 /* EXECNODES_H */