1996-07-09 02:22:35 -04:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
*
|
1999-02-13 18:22:53 -05:00
|
|
|
* executor.h
|
1997-09-07 01:04:48 -04:00
|
|
|
* support for the POSTGRES executor module
|
1996-07-09 02:22:35 -04:00
|
|
|
*
|
|
|
|
|
*
|
2004-12-31 17:04:05 -05:00
|
|
|
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
2000-01-26 00:58:53 -05:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 02:22:35 -04:00
|
|
|
*
|
2005-12-03 00:51:03 -05:00
|
|
|
* $PostgreSQL: pgsql/src/include/executor/executor.h,v 1.123 2005/12/03 05:51:03 tgl Exp $
|
1996-07-09 02:22:35 -04:00
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
#ifndef EXECUTOR_H
|
|
|
|
|
#define EXECUTOR_H
|
|
|
|
|
|
1999-07-15 19:04:24 -04:00
|
|
|
#include "executor/execdesc.h"
|
1996-11-05 03:18:44 -05:00
|
|
|
|
2002-12-05 10:50:39 -05:00
|
|
|
|
2004-03-16 20:02:24 -05:00
|
|
|
/*
|
|
|
|
|
* ExecEvalExpr was formerly a function containing a switch statement;
|
|
|
|
|
* now it's just a macro invoking the function pointed to by an ExprState
|
|
|
|
|
* node. Beware of double evaluation of the ExprState argument!
|
|
|
|
|
*/
|
|
|
|
|
#define ExecEvalExpr(expr, econtext, isNull, isDone) \
|
|
|
|
|
((*(expr)->evalfunc) (expr, econtext, isNull, isDone))
|
|
|
|
|
|
|
|
|
|
|
1996-07-09 02:22:35 -04:00
|
|
|
/*
|
|
|
|
|
* prototypes from functions in execAmi.c
|
|
|
|
|
*/
|
2003-08-08 17:42:59 -04:00
|
|
|
extern void ExecReScan(PlanState *node, ExprContext *exprCtxt);
|
|
|
|
|
extern void ExecMarkPos(PlanState *node);
|
|
|
|
|
extern void ExecRestrPos(PlanState *node);
|
2002-11-30 00:21:03 -05:00
|
|
|
extern bool ExecSupportsMarkRestore(NodeTag plantype);
|
2003-03-09 22:53:52 -05:00
|
|
|
extern bool ExecSupportsBackwardScan(Plan *node);
|
2004-03-02 13:56:15 -05:00
|
|
|
extern bool ExecMayReturnRawTuples(PlanState *node);
|
1996-07-09 02:22:35 -04:00
|
|
|
|
2003-01-10 18:54:24 -05:00
|
|
|
/*
|
|
|
|
|
* prototypes from functions in execGrouping.c
|
|
|
|
|
*/
|
2005-03-16 16:38:10 -05:00
|
|
|
extern bool execTuplesMatch(TupleTableSlot *slot1,
|
2005-10-14 22:49:52 -04:00
|
|
|
TupleTableSlot *slot2,
|
|
|
|
|
int numCols,
|
|
|
|
|
AttrNumber *matchColIdx,
|
|
|
|
|
FmgrInfo *eqfunctions,
|
|
|
|
|
MemoryContext evalContext);
|
2005-03-16 16:38:10 -05:00
|
|
|
extern bool execTuplesUnequal(TupleTableSlot *slot1,
|
2005-10-14 22:49:52 -04:00
|
|
|
TupleTableSlot *slot2,
|
|
|
|
|
int numCols,
|
|
|
|
|
AttrNumber *matchColIdx,
|
|
|
|
|
FmgrInfo *eqfunctions,
|
|
|
|
|
MemoryContext evalContext);
|
2003-01-10 18:54:24 -05:00
|
|
|
extern FmgrInfo *execTuplesMatchPrepare(TupleDesc tupdesc,
|
|
|
|
|
int numCols,
|
|
|
|
|
AttrNumber *matchColIdx);
|
2003-06-22 18:04:55 -04:00
|
|
|
extern void execTuplesHashPrepare(TupleDesc tupdesc,
|
2003-08-03 20:43:34 -04:00
|
|
|
int numCols,
|
|
|
|
|
AttrNumber *matchColIdx,
|
|
|
|
|
FmgrInfo **eqfunctions,
|
|
|
|
|
FmgrInfo **hashfunctions);
|
2003-01-10 18:54:24 -05:00
|
|
|
extern TupleHashTable BuildTupleHashTable(int numCols, AttrNumber *keyColIdx,
|
2003-08-03 20:43:34 -04:00
|
|
|
FmgrInfo *eqfunctions,
|
|
|
|
|
FmgrInfo *hashfunctions,
|
|
|
|
|
int nbuckets, Size entrysize,
|
|
|
|
|
MemoryContext tablecxt,
|
|
|
|
|
MemoryContext tempcxt);
|
2003-01-10 18:54:24 -05:00
|
|
|
extern TupleHashEntry LookupTupleHashEntry(TupleHashTable hashtable,
|
2003-08-03 20:43:34 -04:00
|
|
|
TupleTableSlot *slot,
|
|
|
|
|
bool *isnew);
|
2003-01-10 18:54:24 -05:00
|
|
|
|
1996-07-09 02:22:35 -04:00
|
|
|
/*
|
|
|
|
|
* prototypes from functions in execJunk.c
|
|
|
|
|
*/
|
2004-10-07 14:38:51 -04:00
|
|
|
extern JunkFilter *ExecInitJunkFilter(List *targetList, bool hasoid,
|
2001-10-25 01:50:21 -04:00
|
|
|
TupleTableSlot *slot);
|
2004-10-07 14:38:51 -04:00
|
|
|
extern JunkFilter *ExecInitJunkFilterConversion(List *targetList,
|
2005-10-14 22:49:52 -04:00
|
|
|
TupleDesc cleanTupType,
|
|
|
|
|
TupleTableSlot *slot);
|
1998-09-01 00:40:42 -04:00
|
|
|
extern bool ExecGetJunkAttribute(JunkFilter *junkfilter, TupleTableSlot *slot,
|
1997-09-08 17:56:23 -04:00
|
|
|
char *attrName, Datum *value, bool *isNull);
|
2005-03-16 16:38:10 -05:00
|
|
|
extern TupleTableSlot *ExecFilterJunk(JunkFilter *junkfilter,
|
2005-10-14 22:49:52 -04:00
|
|
|
TupleTableSlot *slot);
|
1997-09-08 17:56:23 -04:00
|
|
|
extern HeapTuple ExecRemoveJunk(JunkFilter *junkfilter, TupleTableSlot *slot);
|
1996-07-09 02:22:35 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* prototypes from functions in execMain.c
|
|
|
|
|
*/
|
2004-09-13 16:10:13 -04:00
|
|
|
extern void ExecutorStart(QueryDesc *queryDesc, bool explainOnly);
|
2002-12-05 10:50:39 -05:00
|
|
|
extern TupleTableSlot *ExecutorRun(QueryDesc *queryDesc,
|
2002-09-04 16:31:48 -04:00
|
|
|
ScanDirection direction, long count);
|
2002-12-05 10:50:39 -05:00
|
|
|
extern void ExecutorEnd(QueryDesc *queryDesc);
|
2003-03-11 14:40:24 -05:00
|
|
|
extern void ExecutorRewind(QueryDesc *queryDesc);
|
2004-01-14 18:01:55 -05:00
|
|
|
extern void ExecCheckRTPerms(List *rangeTable);
|
2003-08-08 17:42:59 -04:00
|
|
|
extern void ExecEndPlan(PlanState *planstate, EState *estate);
|
2004-01-21 21:23:21 -05:00
|
|
|
extern bool ExecContextForcesOids(PlanState *planstate, bool *hasoids);
|
2003-07-21 13:05:12 -04:00
|
|
|
extern void ExecConstraints(ResultRelInfo *resultRelInfo,
|
2001-03-21 23:01:46 -05:00
|
|
|
TupleTableSlot *slot, EState *estate);
|
2000-05-28 21:59:17 -04:00
|
|
|
extern TupleTableSlot *EvalPlanQual(EState *estate, Index rti,
|
2005-10-14 22:49:52 -04:00
|
|
|
ItemPointer tid, TransactionId priorXmax);
|
1999-05-25 12:15:34 -04:00
|
|
|
|
1996-07-09 02:22:35 -04:00
|
|
|
/*
|
|
|
|
|
* prototypes from functions in execProcnode.c
|
|
|
|
|
*/
|
2002-12-05 10:50:39 -05:00
|
|
|
extern PlanState *ExecInitNode(Plan *node, EState *estate);
|
2003-08-08 17:42:59 -04:00
|
|
|
extern TupleTableSlot *ExecProcNode(PlanState *node);
|
2005-04-16 16:07:35 -04:00
|
|
|
extern Node *MultiExecProcNode(PlanState *node);
|
1997-09-08 17:56:23 -04:00
|
|
|
extern int ExecCountSlotsNode(Plan *node);
|
2003-08-08 17:42:59 -04:00
|
|
|
extern void ExecEndNode(PlanState *node);
|
1996-07-09 02:22:35 -04:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* prototypes from functions in execQual.c
|
|
|
|
|
*/
|
2004-04-01 16:28:47 -05:00
|
|
|
extern Datum GetAttributeByNum(HeapTupleHeader tuple, AttrNumber attrno,
|
2001-03-21 23:01:46 -05:00
|
|
|
bool *isNull);
|
2004-04-01 16:28:47 -05:00
|
|
|
extern Datum GetAttributeByName(HeapTupleHeader tuple, const char *attname,
|
2001-03-21 23:01:46 -05:00
|
|
|
bool *isNull);
|
2003-08-08 17:42:59 -04:00
|
|
|
extern void init_fcache(Oid foid, FuncExprState *fcache,
|
2003-08-03 20:43:34 -04:00
|
|
|
MemoryContext fcacheCxt);
|
2003-08-08 17:42:59 -04:00
|
|
|
extern Datum ExecMakeFunctionResult(FuncExprState *fcache,
|
2001-03-21 23:01:46 -05:00
|
|
|
ExprContext *econtext,
|
|
|
|
|
bool *isNull,
|
|
|
|
|
ExprDoneCond *isDone);
|
2003-08-08 17:42:59 -04:00
|
|
|
extern Tuplestorestate *ExecMakeTableFunctionResult(ExprState *funcexpr,
|
2002-09-04 16:31:48 -04:00
|
|
|
ExprContext *econtext,
|
|
|
|
|
TupleDesc expectedDesc,
|
|
|
|
|
TupleDesc *returnDesc);
|
2003-08-08 17:42:59 -04:00
|
|
|
extern Datum ExecEvalExprSwitchContext(ExprState *expression, ExprContext *econtext,
|
2001-03-21 23:01:46 -05:00
|
|
|
bool *isNull, ExprDoneCond *isDone);
|
2003-08-08 17:42:59 -04:00
|
|
|
extern ExprState *ExecInitExpr(Expr *node, PlanState *parent);
|
|
|
|
|
extern SubPlanState *ExecInitExprInitPlan(SubPlan *node, PlanState *parent);
|
2002-12-15 11:17:59 -05:00
|
|
|
extern ExprState *ExecPrepareExpr(Expr *node, EState *estate);
|
2000-01-19 18:55:03 -05:00
|
|
|
extern bool ExecQual(List *qual, ExprContext *econtext, bool resultForNull);
|
1997-09-08 17:56:23 -04:00
|
|
|
extern int ExecTargetListLength(List *targetlist);
|
2000-08-21 16:55:31 -04:00
|
|
|
extern int ExecCleanTargetListLength(List *targetlist);
|
2000-08-23 23:29:15 -04:00
|
|
|
extern TupleTableSlot *ExecProject(ProjectionInfo *projInfo,
|
2001-03-21 23:01:46 -05:00
|
|
|
ExprDoneCond *isDone);
|
1996-07-09 02:22:35 -04:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* prototypes from functions in execScan.c
|
|
|
|
|
*/
|
2003-08-08 17:42:59 -04:00
|
|
|
typedef TupleTableSlot *(*ExecScanAccessMtd) (ScanState *node);
|
2000-07-11 22:37:39 -04:00
|
|
|
|
2003-08-08 17:42:59 -04:00
|
|
|
extern TupleTableSlot *ExecScan(ScanState *node, ExecScanAccessMtd accessMtd);
|
|
|
|
|
extern void ExecAssignScanProjectionInfo(ScanState *node);
|
1996-07-09 02:22:35 -04:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* prototypes from functions in execTuples.c
|
|
|
|
|
*/
|
2003-08-08 17:42:59 -04:00
|
|
|
extern void ExecInitResultTupleSlot(EState *estate, PlanState *planstate);
|
|
|
|
|
extern void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate);
|
2000-09-12 17:07:18 -04:00
|
|
|
extern TupleTableSlot *ExecInitExtraTupleSlot(EState *estate);
|
|
|
|
|
extern TupleTableSlot *ExecInitNullTupleSlot(EState *estate,
|
2001-03-21 23:01:46 -05:00
|
|
|
TupleDesc tupType);
|
2002-09-01 21:05:06 -04:00
|
|
|
extern TupleDesc ExecTypeFromTL(List *targetList, bool hasoid);
|
2003-05-06 16:26:28 -04:00
|
|
|
extern TupleDesc ExecCleanTypeFromTL(List *targetList, bool hasoid);
|
2004-05-10 18:44:49 -04:00
|
|
|
extern TupleDesc ExecTypeFromExprList(List *exprList);
|
2003-08-08 17:42:59 -04:00
|
|
|
extern void UpdateChangedParamSet(PlanState *node, Bitmapset *newchg);
|
1996-07-09 02:22:35 -04:00
|
|
|
|
2002-07-20 01:49:28 -04:00
|
|
|
typedef struct TupOutputState
|
|
|
|
|
{
|
2002-08-28 20:17:06 -04:00
|
|
|
/* use "struct" here to allow forward reference */
|
|
|
|
|
struct AttInMetadata *metadata;
|
2005-03-16 16:38:10 -05:00
|
|
|
TupleTableSlot *slot;
|
2003-05-06 16:26:28 -04:00
|
|
|
DestReceiver *dest;
|
2002-07-20 01:49:28 -04:00
|
|
|
} TupOutputState;
|
|
|
|
|
|
2003-05-06 16:26:28 -04:00
|
|
|
extern TupOutputState *begin_tup_output_tupdesc(DestReceiver *dest,
|
2003-08-03 20:43:34 -04:00
|
|
|
TupleDesc tupdesc);
|
2002-07-20 01:49:28 -04:00
|
|
|
extern void do_tup_output(TupOutputState *tstate, char **values);
|
|
|
|
|
extern void do_text_output_multiline(TupOutputState *tstate, char *text);
|
|
|
|
|
extern void end_tup_output(TupOutputState *tstate);
|
|
|
|
|
|
2002-08-28 20:17:06 -04:00
|
|
|
/*
|
|
|
|
|
* Write a single line of text given as a C string.
|
|
|
|
|
*
|
|
|
|
|
* Should only be used with a single-TEXT-attribute tupdesc.
|
|
|
|
|
*/
|
|
|
|
|
#define do_text_output_oneline(tstate, text_to_emit) \
|
2002-07-20 01:49:28 -04:00
|
|
|
do { \
|
2002-07-20 11:12:56 -04:00
|
|
|
char *values_[1]; \
|
2002-08-28 20:17:06 -04:00
|
|
|
values_[0] = (text_to_emit); \
|
2002-07-20 11:12:56 -04:00
|
|
|
do_tup_output(tstate, values_); \
|
2002-07-20 01:49:28 -04:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
|
1996-07-09 02:22:35 -04:00
|
|
|
/*
|
1999-04-16 17:27:23 -04:00
|
|
|
* prototypes from functions in execUtils.c
|
1996-07-09 02:22:35 -04:00
|
|
|
*/
|
2002-12-15 11:17:59 -05:00
|
|
|
extern EState *CreateExecutorState(void);
|
|
|
|
|
extern void FreeExecutorState(EState *estate);
|
|
|
|
|
extern ExprContext *CreateExprContext(EState *estate);
|
2000-07-11 22:37:39 -04:00
|
|
|
extern void FreeExprContext(ExprContext *econtext);
|
2003-12-18 15:21:37 -05:00
|
|
|
extern void ReScanExprContext(ExprContext *econtext);
|
2000-07-11 22:37:39 -04:00
|
|
|
|
|
|
|
|
#define ResetExprContext(econtext) \
|
|
|
|
|
MemoryContextReset((econtext)->ecxt_per_tuple_memory)
|
|
|
|
|
|
2001-01-21 19:50:07 -05:00
|
|
|
extern ExprContext *MakePerTupleExprContext(EState *estate);
|
|
|
|
|
|
|
|
|
|
/* Get an EState's per-output-tuple exprcontext, making it if first use */
|
|
|
|
|
#define GetPerTupleExprContext(estate) \
|
|
|
|
|
((estate)->es_per_tuple_exprcontext ? \
|
|
|
|
|
(estate)->es_per_tuple_exprcontext : \
|
|
|
|
|
MakePerTupleExprContext(estate))
|
|
|
|
|
|
|
|
|
|
#define GetPerTupleMemoryContext(estate) \
|
|
|
|
|
(GetPerTupleExprContext(estate)->ecxt_per_tuple_memory)
|
|
|
|
|
|
|
|
|
|
/* Reset an EState's per-output-tuple exprcontext, if one's been created */
|
|
|
|
|
#define ResetPerTupleExprContext(estate) \
|
|
|
|
|
do { \
|
|
|
|
|
if ((estate)->es_per_tuple_exprcontext) \
|
|
|
|
|
ResetExprContext((estate)->es_per_tuple_exprcontext); \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
2003-08-08 17:42:59 -04:00
|
|
|
extern void ExecAssignExprContext(EState *estate, PlanState *planstate);
|
|
|
|
|
extern void ExecAssignResultType(PlanState *planstate,
|
2002-12-15 11:17:59 -05:00
|
|
|
TupleDesc tupDesc, bool shouldFree);
|
2003-08-08 17:42:59 -04:00
|
|
|
extern void ExecAssignResultTypeFromTL(PlanState *planstate);
|
|
|
|
|
extern TupleDesc ExecGetResultType(PlanState *planstate);
|
2003-01-11 23:03:34 -05:00
|
|
|
extern ProjectionInfo *ExecBuildProjectionInfo(List *targetList,
|
2003-08-03 20:43:34 -04:00
|
|
|
ExprContext *econtext,
|
|
|
|
|
TupleTableSlot *slot);
|
2003-08-08 17:42:59 -04:00
|
|
|
extern void ExecAssignProjectionInfo(PlanState *planstate);
|
|
|
|
|
extern void ExecFreeExprContext(PlanState *planstate);
|
|
|
|
|
extern TupleDesc ExecGetScanType(ScanState *scanstate);
|
|
|
|
|
extern void ExecAssignScanType(ScanState *scanstate,
|
2002-12-15 11:17:59 -05:00
|
|
|
TupleDesc tupDesc, bool shouldFree);
|
2003-08-08 17:42:59 -04:00
|
|
|
extern void ExecAssignScanTypeFromOuterPlan(ScanState *scanstate);
|
2002-12-15 11:17:59 -05:00
|
|
|
|
2005-12-03 00:51:03 -05:00
|
|
|
extern bool ExecRelationIsTargetRelation(EState *estate, Index scanrelid);
|
|
|
|
|
|
2005-12-02 15:03:42 -05:00
|
|
|
extern Relation ExecOpenScanRelation(EState *estate, Index scanrelid);
|
|
|
|
|
extern void ExecCloseScanRelation(Relation scanrel);
|
|
|
|
|
|
2000-11-11 19:37:02 -05:00
|
|
|
extern void ExecOpenIndices(ResultRelInfo *resultRelInfo);
|
|
|
|
|
extern void ExecCloseIndices(ResultRelInfo *resultRelInfo);
|
1998-09-01 00:40:42 -04:00
|
|
|
extern void ExecInsertIndexTuples(TupleTableSlot *slot, ItemPointer tupleid,
|
2002-05-24 14:57:57 -04:00
|
|
|
EState *estate, bool is_vacuum);
|
2001-10-28 01:26:15 -05:00
|
|
|
|
2002-05-12 16:10:05 -04:00
|
|
|
extern void RegisterExprContextCallback(ExprContext *econtext,
|
2002-09-04 16:31:48 -04:00
|
|
|
ExprContextCallbackFunction function,
|
|
|
|
|
Datum arg);
|
2002-05-12 16:10:05 -04:00
|
|
|
extern void UnregisterExprContextCallback(ExprContext *econtext,
|
2002-09-04 16:31:48 -04:00
|
|
|
ExprContextCallbackFunction function,
|
|
|
|
|
Datum arg);
|
2002-05-12 16:10:05 -04:00
|
|
|
|
2001-11-05 12:46:40 -05:00
|
|
|
#endif /* EXECUTOR_H */
|