1996-07-09 06:22:35 +00:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-13 23:22:53 +00:00
|
|
|
* executor.h
|
1997-09-07 05:04:48 +00:00
|
|
|
* support for the POSTGRES executor module
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
|
|
|
*
|
2003-08-04 02:40:20 +00:00
|
|
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
2000-01-26 05:58:53 +00:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
2004-01-14 23:01:55 +00:00
|
|
|
* $PostgreSQL: pgsql/src/include/executor/executor.h,v 1.105 2004/01/14 23:01:55 tgl Exp $
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef EXECUTOR_H
|
|
|
|
#define EXECUTOR_H
|
|
|
|
|
1999-07-15 23:04:24 +00:00
|
|
|
#include "executor/execdesc.h"
|
1996-11-05 08:18:44 +00:00
|
|
|
|
2002-12-05 15:50:39 +00:00
|
|
|
|
1998-04-24 14:43:33 +00:00
|
|
|
/* ----------------
|
|
|
|
* TupIsNull
|
|
|
|
*
|
|
|
|
* This is used mainly to detect when there are no more
|
|
|
|
* tuples to process.
|
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
/* return: true if tuple in slot is NULL, slot is slot to test */
|
|
|
|
#define TupIsNull(slot) \
|
2000-01-19 23:55:03 +00:00
|
|
|
((slot) == NULL || (slot)->val == NULL)
|
1998-04-24 14:43:33 +00:00
|
|
|
|
1996-07-09 06:22:35 +00:00
|
|
|
/*
|
|
|
|
* prototypes from functions in execAmi.c
|
|
|
|
*/
|
2003-08-08 21:42:59 +00:00
|
|
|
extern void ExecReScan(PlanState *node, ExprContext *exprCtxt);
|
|
|
|
extern void ExecMarkPos(PlanState *node);
|
|
|
|
extern void ExecRestrPos(PlanState *node);
|
2002-11-30 05:21:03 +00:00
|
|
|
extern bool ExecSupportsMarkRestore(NodeTag plantype);
|
2003-03-10 03:53:52 +00:00
|
|
|
extern bool ExecSupportsBackwardScan(Plan *node);
|
1996-07-09 06:22:35 +00:00
|
|
|
|
2003-01-10 23:54:24 +00:00
|
|
|
/*
|
|
|
|
* prototypes from functions in execGrouping.c
|
|
|
|
*/
|
|
|
|
extern bool execTuplesMatch(HeapTuple tuple1,
|
|
|
|
HeapTuple tuple2,
|
|
|
|
TupleDesc tupdesc,
|
|
|
|
int numCols,
|
|
|
|
AttrNumber *matchColIdx,
|
|
|
|
FmgrInfo *eqfunctions,
|
|
|
|
MemoryContext evalContext);
|
2003-01-12 04:03:34 +00:00
|
|
|
extern bool execTuplesUnequal(HeapTuple tuple1,
|
2003-08-04 00:43:34 +00:00
|
|
|
HeapTuple tuple2,
|
|
|
|
TupleDesc tupdesc,
|
|
|
|
int numCols,
|
|
|
|
AttrNumber *matchColIdx,
|
|
|
|
FmgrInfo *eqfunctions,
|
|
|
|
MemoryContext evalContext);
|
2003-01-10 23:54:24 +00:00
|
|
|
extern FmgrInfo *execTuplesMatchPrepare(TupleDesc tupdesc,
|
|
|
|
int numCols,
|
|
|
|
AttrNumber *matchColIdx);
|
2003-06-22 22:04:55 +00:00
|
|
|
extern void execTuplesHashPrepare(TupleDesc tupdesc,
|
2003-08-04 00:43:34 +00:00
|
|
|
int numCols,
|
|
|
|
AttrNumber *matchColIdx,
|
|
|
|
FmgrInfo **eqfunctions,
|
|
|
|
FmgrInfo **hashfunctions);
|
2003-01-10 23:54:24 +00:00
|
|
|
extern TupleHashTable BuildTupleHashTable(int numCols, AttrNumber *keyColIdx,
|
2003-08-04 00:43:34 +00:00
|
|
|
FmgrInfo *eqfunctions,
|
|
|
|
FmgrInfo *hashfunctions,
|
|
|
|
int nbuckets, Size entrysize,
|
|
|
|
MemoryContext tablecxt,
|
|
|
|
MemoryContext tempcxt);
|
2003-01-10 23:54:24 +00:00
|
|
|
extern TupleHashEntry LookupTupleHashEntry(TupleHashTable hashtable,
|
2003-08-04 00:43:34 +00:00
|
|
|
TupleTableSlot *slot,
|
|
|
|
bool *isnew);
|
2003-01-10 23:54:24 +00:00
|
|
|
|
1996-07-09 06:22:35 +00:00
|
|
|
/*
|
|
|
|
* prototypes from functions in execJunk.c
|
|
|
|
*/
|
2001-05-27 20:48:51 +00:00
|
|
|
extern JunkFilter *ExecInitJunkFilter(List *targetList, TupleDesc tupType,
|
2001-10-25 05:50:21 +00:00
|
|
|
TupleTableSlot *slot);
|
1998-09-01 04:40:42 +00:00
|
|
|
extern bool ExecGetJunkAttribute(JunkFilter *junkfilter, TupleTableSlot *slot,
|
1997-09-08 21:56:23 +00:00
|
|
|
char *attrName, Datum *value, bool *isNull);
|
|
|
|
extern HeapTuple ExecRemoveJunk(JunkFilter *junkfilter, TupleTableSlot *slot);
|
1996-07-09 06:22:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* prototypes from functions in execMain.c
|
|
|
|
*/
|
2003-10-01 21:30:53 +00:00
|
|
|
extern void ExecutorStart(QueryDesc *queryDesc, bool useCurrentSnapshot,
|
2003-09-25 18:58:36 +00:00
|
|
|
bool explainOnly);
|
2002-12-05 15:50:39 +00:00
|
|
|
extern TupleTableSlot *ExecutorRun(QueryDesc *queryDesc,
|
2002-09-04 20:31:48 +00:00
|
|
|
ScanDirection direction, long count);
|
2002-12-05 15:50:39 +00:00
|
|
|
extern void ExecutorEnd(QueryDesc *queryDesc);
|
2003-03-11 19:40:24 +00:00
|
|
|
extern void ExecutorRewind(QueryDesc *queryDesc);
|
2004-01-14 23:01:55 +00:00
|
|
|
extern void ExecCheckRTPerms(List *rangeTable);
|
2003-08-08 21:42:59 +00:00
|
|
|
extern void ExecEndPlan(PlanState *planstate, EState *estate);
|
2003-07-21 17:05:12 +00:00
|
|
|
extern void ExecConstraints(ResultRelInfo *resultRelInfo,
|
2001-03-22 04:01:46 +00:00
|
|
|
TupleTableSlot *slot, EState *estate);
|
2000-05-29 01:59:17 +00:00
|
|
|
extern TupleTableSlot *EvalPlanQual(EState *estate, Index rti,
|
2001-03-22 04:01:46 +00:00
|
|
|
ItemPointer tid);
|
1999-05-25 16:15:34 +00:00
|
|
|
|
1996-07-09 06:22:35 +00:00
|
|
|
/*
|
|
|
|
* prototypes from functions in execProcnode.c
|
|
|
|
*/
|
2002-12-05 15:50:39 +00:00
|
|
|
extern PlanState *ExecInitNode(Plan *node, EState *estate);
|
2003-08-08 21:42:59 +00:00
|
|
|
extern TupleTableSlot *ExecProcNode(PlanState *node);
|
1997-09-08 21:56:23 +00:00
|
|
|
extern int ExecCountSlotsNode(Plan *node);
|
2003-08-08 21:42:59 +00:00
|
|
|
extern void ExecEndNode(PlanState *node);
|
1996-07-09 06:22:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* prototypes from functions in execQual.c
|
|
|
|
*/
|
2000-08-24 23:34:11 +00:00
|
|
|
extern Datum GetAttributeByNum(TupleTableSlot *slot, AttrNumber attrno,
|
2001-03-22 04:01:46 +00:00
|
|
|
bool *isNull);
|
2000-08-24 23:34:11 +00:00
|
|
|
extern Datum GetAttributeByName(TupleTableSlot *slot, char *attname,
|
2001-03-22 04:01:46 +00:00
|
|
|
bool *isNull);
|
2003-08-08 21:42:59 +00:00
|
|
|
extern void init_fcache(Oid foid, FuncExprState *fcache,
|
2003-08-04 00:43:34 +00:00
|
|
|
MemoryContext fcacheCxt);
|
2003-08-08 21:42:59 +00:00
|
|
|
extern Datum ExecMakeFunctionResult(FuncExprState *fcache,
|
2001-03-22 04:01:46 +00:00
|
|
|
ExprContext *econtext,
|
|
|
|
bool *isNull,
|
|
|
|
ExprDoneCond *isDone);
|
2003-08-08 21:42:59 +00:00
|
|
|
extern Tuplestorestate *ExecMakeTableFunctionResult(ExprState *funcexpr,
|
2002-09-04 20:31:48 +00:00
|
|
|
ExprContext *econtext,
|
|
|
|
TupleDesc expectedDesc,
|
|
|
|
TupleDesc *returnDesc);
|
2003-08-08 21:42:59 +00:00
|
|
|
extern Datum ExecEvalExpr(ExprState *expression, ExprContext *econtext,
|
2001-03-22 04:01:46 +00:00
|
|
|
bool *isNull, ExprDoneCond *isDone);
|
2003-08-08 21:42:59 +00:00
|
|
|
extern Datum ExecEvalExprSwitchContext(ExprState *expression, ExprContext *econtext,
|
2001-03-22 04:01:46 +00:00
|
|
|
bool *isNull, ExprDoneCond *isDone);
|
2003-08-08 21:42:59 +00:00
|
|
|
extern ExprState *ExecInitExpr(Expr *node, PlanState *parent);
|
|
|
|
extern SubPlanState *ExecInitExprInitPlan(SubPlan *node, PlanState *parent);
|
2002-12-15 16:17:59 +00:00
|
|
|
extern ExprState *ExecPrepareExpr(Expr *node, EState *estate);
|
2000-01-19 23:55:03 +00:00
|
|
|
extern bool ExecQual(List *qual, ExprContext *econtext, bool resultForNull);
|
1997-09-08 21:56:23 +00:00
|
|
|
extern int ExecTargetListLength(List *targetlist);
|
2000-08-21 20:55:31 +00:00
|
|
|
extern int ExecCleanTargetListLength(List *targetlist);
|
2000-08-24 03:29:15 +00:00
|
|
|
extern TupleTableSlot *ExecProject(ProjectionInfo *projInfo,
|
2001-03-22 04:01:46 +00:00
|
|
|
ExprDoneCond *isDone);
|
1996-07-09 06:22:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* prototypes from functions in execScan.c
|
|
|
|
*/
|
2003-08-08 21:42:59 +00:00
|
|
|
typedef TupleTableSlot *(*ExecScanAccessMtd) (ScanState *node);
|
2000-07-12 02:37:39 +00:00
|
|
|
|
2003-08-08 21:42:59 +00:00
|
|
|
extern TupleTableSlot *ExecScan(ScanState *node, ExecScanAccessMtd accessMtd);
|
|
|
|
extern void ExecAssignScanProjectionInfo(ScanState *node);
|
1996-07-09 06:22:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* prototypes from functions in execTuples.c
|
|
|
|
*/
|
|
|
|
extern TupleTable ExecCreateTupleTable(int initialSize);
|
1999-12-10 03:56:14 +00:00
|
|
|
extern void ExecDropTupleTable(TupleTable table, bool shouldFree);
|
1997-09-07 05:04:48 +00:00
|
|
|
extern TupleTableSlot *ExecAllocTableSlot(TupleTable table);
|
2001-01-29 00:39:20 +00:00
|
|
|
extern TupleTableSlot *MakeTupleTableSlot(void);
|
1998-09-01 04:40:42 +00:00
|
|
|
extern TupleTableSlot *ExecStoreTuple(HeapTuple tuple,
|
1997-09-08 21:56:23 +00:00
|
|
|
TupleTableSlot *slot,
|
1997-09-07 05:04:48 +00:00
|
|
|
Buffer buffer,
|
|
|
|
bool shouldFree);
|
1997-09-08 21:56:23 +00:00
|
|
|
extern TupleTableSlot *ExecClearTuple(TupleTableSlot *slot);
|
2001-01-29 00:39:20 +00:00
|
|
|
extern void ExecSetSlotDescriptor(TupleTableSlot *slot,
|
2001-03-22 04:01:46 +00:00
|
|
|
TupleDesc tupdesc, bool shouldFree);
|
1997-09-08 21:56:23 +00:00
|
|
|
extern void ExecSetSlotDescriptorIsNew(TupleTableSlot *slot, bool isNew);
|
2003-08-08 21:42:59 +00:00
|
|
|
extern void ExecInitResultTupleSlot(EState *estate, PlanState *planstate);
|
|
|
|
extern void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate);
|
2000-09-12 21:07:18 +00:00
|
|
|
extern TupleTableSlot *ExecInitExtraTupleSlot(EState *estate);
|
|
|
|
extern TupleTableSlot *ExecInitNullTupleSlot(EState *estate,
|
2001-03-22 04:01:46 +00:00
|
|
|
TupleDesc tupType);
|
2002-09-02 01:05:06 +00:00
|
|
|
extern TupleDesc ExecTypeFromTL(List *targetList, bool hasoid);
|
2003-05-06 20:26:28 +00:00
|
|
|
extern TupleDesc ExecCleanTypeFromTL(List *targetList, bool hasoid);
|
2003-08-08 21:42:59 +00:00
|
|
|
extern void UpdateChangedParamSet(PlanState *node, Bitmapset *newchg);
|
1996-07-09 06:22:35 +00:00
|
|
|
|
2002-07-20 05:49:28 +00:00
|
|
|
typedef struct TupOutputState
|
|
|
|
{
|
2002-08-29 00:17:06 +00:00
|
|
|
/* use "struct" here to allow forward reference */
|
|
|
|
struct AttInMetadata *metadata;
|
2003-05-06 20:26:28 +00:00
|
|
|
DestReceiver *dest;
|
2002-07-20 05:49:28 +00:00
|
|
|
} TupOutputState;
|
|
|
|
|
2003-05-06 20:26:28 +00:00
|
|
|
extern TupOutputState *begin_tup_output_tupdesc(DestReceiver *dest,
|
2003-08-04 00:43:34 +00:00
|
|
|
TupleDesc tupdesc);
|
2002-07-20 05:49:28 +00: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-29 00:17:06 +00: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 05:49:28 +00:00
|
|
|
do { \
|
2002-07-20 15:12:56 +00:00
|
|
|
char *values_[1]; \
|
2002-08-29 00:17:06 +00:00
|
|
|
values_[0] = (text_to_emit); \
|
2002-07-20 15:12:56 +00:00
|
|
|
do_tup_output(tstate, values_); \
|
2002-07-20 05:49:28 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
1996-07-09 06:22:35 +00:00
|
|
|
/*
|
1999-04-16 21:27:23 +00:00
|
|
|
* prototypes from functions in execUtils.c
|
1996-07-09 06:22:35 +00:00
|
|
|
*/
|
2002-12-15 16:17:59 +00:00
|
|
|
extern EState *CreateExecutorState(void);
|
|
|
|
extern void FreeExecutorState(EState *estate);
|
|
|
|
extern ExprContext *CreateExprContext(EState *estate);
|
2000-07-12 02:37:39 +00:00
|
|
|
extern void FreeExprContext(ExprContext *econtext);
|
2003-12-18 20:21:37 +00:00
|
|
|
extern void ReScanExprContext(ExprContext *econtext);
|
2000-07-12 02:37:39 +00:00
|
|
|
|
|
|
|
#define ResetExprContext(econtext) \
|
|
|
|
MemoryContextReset((econtext)->ecxt_per_tuple_memory)
|
|
|
|
|
2001-01-22 00:50:07 +00: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 21:42:59 +00:00
|
|
|
extern void ExecAssignExprContext(EState *estate, PlanState *planstate);
|
|
|
|
extern void ExecAssignResultType(PlanState *planstate,
|
2002-12-15 16:17:59 +00:00
|
|
|
TupleDesc tupDesc, bool shouldFree);
|
2003-08-08 21:42:59 +00:00
|
|
|
extern void ExecAssignResultTypeFromOuterPlan(PlanState *planstate);
|
|
|
|
extern void ExecAssignResultTypeFromTL(PlanState *planstate);
|
|
|
|
extern TupleDesc ExecGetResultType(PlanState *planstate);
|
2003-01-12 04:03:34 +00:00
|
|
|
extern ProjectionInfo *ExecBuildProjectionInfo(List *targetList,
|
2003-08-04 00:43:34 +00:00
|
|
|
ExprContext *econtext,
|
|
|
|
TupleTableSlot *slot);
|
2003-08-08 21:42:59 +00:00
|
|
|
extern void ExecAssignProjectionInfo(PlanState *planstate);
|
|
|
|
extern void ExecFreeExprContext(PlanState *planstate);
|
|
|
|
extern TupleDesc ExecGetScanType(ScanState *scanstate);
|
|
|
|
extern void ExecAssignScanType(ScanState *scanstate,
|
2002-12-15 16:17:59 +00:00
|
|
|
TupleDesc tupDesc, bool shouldFree);
|
2003-08-08 21:42:59 +00:00
|
|
|
extern void ExecAssignScanTypeFromOuterPlan(ScanState *scanstate);
|
2002-12-15 16:17:59 +00:00
|
|
|
|
2000-11-12 00:37:02 +00:00
|
|
|
extern void ExecOpenIndices(ResultRelInfo *resultRelInfo);
|
|
|
|
extern void ExecCloseIndices(ResultRelInfo *resultRelInfo);
|
1998-09-01 04:40:42 +00:00
|
|
|
extern void ExecInsertIndexTuples(TupleTableSlot *slot, ItemPointer tupleid,
|
2002-05-24 18:57:57 +00:00
|
|
|
EState *estate, bool is_vacuum);
|
2001-10-28 06:26:15 +00:00
|
|
|
|
2002-05-12 20:10:05 +00:00
|
|
|
extern void RegisterExprContextCallback(ExprContext *econtext,
|
2002-09-04 20:31:48 +00:00
|
|
|
ExprContextCallbackFunction function,
|
|
|
|
Datum arg);
|
2002-05-12 20:10:05 +00:00
|
|
|
extern void UnregisterExprContextCallback(ExprContext *econtext,
|
2002-09-04 20:31:48 +00:00
|
|
|
ExprContextCallbackFunction function,
|
|
|
|
Datum arg);
|
2002-05-12 20:10:05 +00:00
|
|
|
|
2001-11-05 17:46:40 +00:00
|
|
|
#endif /* EXECUTOR_H */
|