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
|
|
|
*
|
|
|
|
|
*
|
2002-06-20 16:29:54 -04:00
|
|
|
* Portions Copyright (c) 1996-2002, 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
|
|
|
*
|
2003-01-10 18:54:24 -05:00
|
|
|
* $Id: executor.h,v 1.86 2003/01/10 23:54:24 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
|
|
|
|
1998-04-24 10:43:33 -04: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 18:55:03 -05:00
|
|
|
((slot) == NULL || (slot)->val == NULL)
|
1998-04-24 10:43:33 -04:00
|
|
|
|
1996-07-09 02:22:35 -04:00
|
|
|
/*
|
|
|
|
|
* prototypes from functions in execAmi.c
|
|
|
|
|
*/
|
2002-12-05 10:50:39 -05: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);
|
1996-07-09 02:22:35 -04:00
|
|
|
|
2003-01-10 18:54:24 -05:00
|
|
|
/*
|
|
|
|
|
* prototypes from functions in execGrouping.c
|
|
|
|
|
*/
|
|
|
|
|
extern bool execTuplesMatch(HeapTuple tuple1,
|
|
|
|
|
HeapTuple tuple2,
|
|
|
|
|
TupleDesc tupdesc,
|
|
|
|
|
int numCols,
|
|
|
|
|
AttrNumber *matchColIdx,
|
|
|
|
|
FmgrInfo *eqfunctions,
|
|
|
|
|
MemoryContext evalContext);
|
|
|
|
|
extern FmgrInfo *execTuplesMatchPrepare(TupleDesc tupdesc,
|
|
|
|
|
int numCols,
|
|
|
|
|
AttrNumber *matchColIdx);
|
|
|
|
|
extern uint32 ComputeHashFunc(Datum key, int typLen, bool byVal);
|
|
|
|
|
extern TupleHashTable BuildTupleHashTable(int numCols, AttrNumber *keyColIdx,
|
|
|
|
|
FmgrInfo *eqfunctions,
|
|
|
|
|
int nbuckets, Size entrysize,
|
|
|
|
|
MemoryContext tablecxt,
|
|
|
|
|
MemoryContext tempcxt);
|
|
|
|
|
extern TupleHashEntry LookupTupleHashEntry(TupleHashTable hashtable,
|
|
|
|
|
TupleTableSlot *slot,
|
|
|
|
|
bool *isnew);
|
|
|
|
|
extern TupleHashEntry ScanTupleHashTable(TupleHashTable hashtable,
|
|
|
|
|
TupleHashIterator *state);
|
|
|
|
|
|
1996-07-09 02:22:35 -04:00
|
|
|
/*
|
|
|
|
|
* prototypes from functions in execJunk.c
|
|
|
|
|
*/
|
2001-05-27 16:48:51 -04:00
|
|
|
extern JunkFilter *ExecInitJunkFilter(List *targetList, TupleDesc tupType,
|
2001-10-25 01:50:21 -04:00
|
|
|
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);
|
|
|
|
|
extern HeapTuple ExecRemoveJunk(JunkFilter *junkfilter, TupleTableSlot *slot);
|
1996-07-09 02:22:35 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* prototypes from functions in execMain.c
|
|
|
|
|
*/
|
2002-12-05 10:50:39 -05:00
|
|
|
extern void ExecutorStart(QueryDesc *queryDesc);
|
|
|
|
|
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);
|
|
|
|
|
extern void ExecCheckRTPerms(List *rangeTable, CmdType operation);
|
2002-12-15 11:17:59 -05:00
|
|
|
extern void ExecEndPlan(PlanState *planstate, EState *estate);
|
2002-06-26 17:58:56 -04:00
|
|
|
extern void ExecConstraints(const char *caller, 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,
|
2001-03-21 23:01:46 -05:00
|
|
|
ItemPointer tid);
|
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);
|
|
|
|
|
extern TupleTableSlot *ExecProcNode(PlanState *node);
|
1997-09-08 17:56:23 -04:00
|
|
|
extern int ExecCountSlotsNode(Plan *node);
|
2002-12-05 10:50:39 -05:00
|
|
|
extern void ExecEndNode(PlanState *node);
|
|
|
|
|
extern TupleDesc ExecGetTupType(PlanState *node);
|
1996-07-09 02:22:35 -04:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* prototypes from functions in execQual.c
|
|
|
|
|
*/
|
2000-08-24 19:34:11 -04:00
|
|
|
extern Datum GetAttributeByNum(TupleTableSlot *slot, AttrNumber attrno,
|
2001-03-21 23:01:46 -05:00
|
|
|
bool *isNull);
|
2000-08-24 19:34:11 -04:00
|
|
|
extern Datum GetAttributeByName(TupleTableSlot *slot, char *attname,
|
2001-03-21 23:01:46 -05:00
|
|
|
bool *isNull);
|
2002-12-13 14:46:01 -05:00
|
|
|
extern void init_fcache(Oid foid, FuncExprState *fcache,
|
|
|
|
|
MemoryContext fcacheCxt);
|
|
|
|
|
extern Datum ExecMakeFunctionResult(FuncExprState *fcache,
|
2001-03-21 23:01:46 -05:00
|
|
|
ExprContext *econtext,
|
|
|
|
|
bool *isNull,
|
|
|
|
|
ExprDoneCond *isDone);
|
2002-12-13 14:46:01 -05:00
|
|
|
extern Tuplestorestate *ExecMakeTableFunctionResult(ExprState *funcexpr,
|
2002-09-04 16:31:48 -04:00
|
|
|
ExprContext *econtext,
|
|
|
|
|
TupleDesc expectedDesc,
|
|
|
|
|
TupleDesc *returnDesc);
|
2002-12-13 14:46:01 -05:00
|
|
|
extern Datum ExecEvalExpr(ExprState *expression, ExprContext *econtext,
|
2001-03-21 23:01:46 -05:00
|
|
|
bool *isNull, ExprDoneCond *isDone);
|
2002-12-13 14:46:01 -05:00
|
|
|
extern Datum ExecEvalExprSwitchContext(ExprState *expression, ExprContext *econtext,
|
2001-03-21 23:01:46 -05:00
|
|
|
bool *isNull, ExprDoneCond *isDone);
|
2002-12-13 14:46:01 -05:00
|
|
|
extern ExprState *ExecInitExpr(Expr *node, PlanState *parent);
|
2002-12-13 19:17:59 -05:00
|
|
|
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
|
|
|
|
|
*/
|
2002-12-05 10:50:39 -05:00
|
|
|
typedef TupleTableSlot *(*ExecScanAccessMtd) (ScanState *node);
|
2000-07-11 22:37:39 -04:00
|
|
|
|
2002-12-05 10:50:39 -05:00
|
|
|
extern TupleTableSlot *ExecScan(ScanState *node, ExecScanAccessMtd accessMtd);
|
1996-07-09 02:22:35 -04:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* prototypes from functions in execTuples.c
|
|
|
|
|
*/
|
|
|
|
|
extern TupleTable ExecCreateTupleTable(int initialSize);
|
1999-12-09 22:56:14 -05:00
|
|
|
extern void ExecDropTupleTable(TupleTable table, bool shouldFree);
|
1997-09-07 01:04:48 -04:00
|
|
|
extern TupleTableSlot *ExecAllocTableSlot(TupleTable table);
|
2001-01-28 19:39:20 -05:00
|
|
|
extern TupleTableSlot *MakeTupleTableSlot(void);
|
1998-09-01 00:40:42 -04:00
|
|
|
extern TupleTableSlot *ExecStoreTuple(HeapTuple tuple,
|
1997-09-08 17:56:23 -04:00
|
|
|
TupleTableSlot *slot,
|
1997-09-07 01:04:48 -04:00
|
|
|
Buffer buffer,
|
|
|
|
|
bool shouldFree);
|
1997-09-08 17:56:23 -04:00
|
|
|
extern TupleTableSlot *ExecClearTuple(TupleTableSlot *slot);
|
2001-01-28 19:39:20 -05:00
|
|
|
extern void ExecSetSlotDescriptor(TupleTableSlot *slot,
|
2001-03-21 23:01:46 -05:00
|
|
|
TupleDesc tupdesc, bool shouldFree);
|
1997-09-08 17:56:23 -04:00
|
|
|
extern void ExecSetSlotDescriptorIsNew(TupleTableSlot *slot, bool isNew);
|
2002-12-05 10:50:39 -05: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);
|
2002-12-05 10:50:39 -05:00
|
|
|
extern void SetChangedParamList(PlanState *node, List *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;
|
2002-07-20 01:49:28 -04:00
|
|
|
DestReceiver *destfunc;
|
|
|
|
|
} TupOutputState;
|
|
|
|
|
|
|
|
|
|
extern TupOutputState *begin_tup_output_tupdesc(CommandDest dest, TupleDesc tupdesc);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
#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)
|
|
|
|
|
|
2002-12-15 11:17:59 -05:00
|
|
|
extern void ExecAssignExprContext(EState *estate, PlanState *planstate);
|
|
|
|
|
extern void ExecAssignResultType(PlanState *planstate,
|
|
|
|
|
TupleDesc tupDesc, bool shouldFree);
|
|
|
|
|
extern void ExecAssignResultTypeFromOuterPlan(PlanState *planstate);
|
|
|
|
|
extern void ExecAssignResultTypeFromTL(PlanState *planstate);
|
|
|
|
|
extern TupleDesc ExecGetResultType(PlanState *planstate);
|
|
|
|
|
extern void ExecAssignProjectionInfo(PlanState *planstate);
|
|
|
|
|
extern void ExecFreeExprContext(PlanState *planstate);
|
|
|
|
|
extern TupleDesc ExecGetScanType(ScanState *scanstate);
|
|
|
|
|
extern void ExecAssignScanType(ScanState *scanstate,
|
|
|
|
|
TupleDesc tupDesc, bool shouldFree);
|
|
|
|
|
extern void ExecAssignScanTypeFromOuterPlan(ScanState *scanstate);
|
|
|
|
|
|
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 */
|