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
|
|
|
*
|
|
|
|
*
|
2002-06-20 20:29:54 +00:00
|
|
|
* Portions Copyright (c) 1996-2002, 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
|
|
|
*
|
2002-08-30 23:59:46 +00:00
|
|
|
* $Id: executor.h,v 1.76 2002/08/30 23:59:46 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
|
|
|
|
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
|
|
|
|
*/
|
1997-09-08 21:56:23 +00:00
|
|
|
extern void ExecReScan(Plan *node, ExprContext *exprCtxt, Plan *parent);
|
|
|
|
extern void ExecMarkPos(Plan *node);
|
|
|
|
extern void ExecRestrPos(Plan *node);
|
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);
|
2001-01-29 00:39:20 +00:00
|
|
|
extern void ExecFreeJunkFilter(JunkFilter *junkfilter);
|
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
|
|
|
|
*/
|
1997-09-08 21:56:23 +00:00
|
|
|
extern TupleDesc ExecutorStart(QueryDesc *queryDesc, EState *estate);
|
1999-05-25 16:15:34 +00:00
|
|
|
extern TupleTableSlot *ExecutorRun(QueryDesc *queryDesc, EState *estate,
|
2002-02-27 19:36:13 +00:00
|
|
|
ScanDirection direction, long count);
|
1997-09-08 21:56:23 +00:00
|
|
|
extern void ExecutorEnd(QueryDesc *queryDesc, EState *estate);
|
2002-06-26 21:58:56 +00:00
|
|
|
extern void ExecConstraints(const char *caller, 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
|
|
|
|
*/
|
1997-09-08 21:56:23 +00:00
|
|
|
extern bool ExecInitNode(Plan *node, EState *estate, Plan *parent);
|
|
|
|
extern TupleTableSlot *ExecProcNode(Plan *node, Plan *parent);
|
|
|
|
extern int ExecCountSlotsNode(Plan *node);
|
|
|
|
extern void ExecEndNode(Plan *node, Plan *parent);
|
2001-01-29 00:39:20 +00:00
|
|
|
extern TupleDesc ExecGetTupType(Plan *node);
|
1996-07-09 06:22:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* prototypes from functions in execQual.c
|
|
|
|
*/
|
1998-09-01 04:40:42 +00:00
|
|
|
extern Datum ExecEvalParam(Param *expression, ExprContext *econtext,
|
1997-09-08 21:56:23 +00:00
|
|
|
bool *isNull);
|
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);
|
2000-08-24 03:29:15 +00:00
|
|
|
extern Datum ExecMakeFunctionResult(FunctionCachePtr fcache,
|
2001-03-22 04:01:46 +00:00
|
|
|
List *arguments,
|
|
|
|
ExprContext *econtext,
|
|
|
|
bool *isNull,
|
|
|
|
ExprDoneCond *isDone);
|
2002-08-30 00:28:41 +00:00
|
|
|
extern Tuplestorestate *ExecMakeTableFunctionResult(Expr *funcexpr,
|
|
|
|
ExprContext *econtext,
|
2002-08-30 23:59:46 +00:00
|
|
|
TupleDesc expectedDesc,
|
2002-08-30 00:28:41 +00:00
|
|
|
TupleDesc *returnDesc);
|
2000-07-12 02:37:39 +00:00
|
|
|
extern Datum ExecEvalExpr(Node *expression, ExprContext *econtext,
|
2001-03-22 04:01:46 +00:00
|
|
|
bool *isNull, ExprDoneCond *isDone);
|
2000-07-12 02:37:39 +00:00
|
|
|
extern Datum ExecEvalExprSwitchContext(Node *expression, ExprContext *econtext,
|
2001-03-22 04:01:46 +00:00
|
|
|
bool *isNull, ExprDoneCond *isDone);
|
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
|
|
|
|
*/
|
2000-07-12 02:37:39 +00:00
|
|
|
typedef TupleTableSlot *(*ExecScanAccessMtd) (Scan *node);
|
|
|
|
|
|
|
|
extern TupleTableSlot *ExecScan(Scan *node, ExecScanAccessMtd accessMtd);
|
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);
|
|
|
|
extern void ExecInitResultTupleSlot(EState *estate, CommonState *commonstate);
|
1998-09-01 04:40:42 +00:00
|
|
|
extern void ExecInitScanTupleSlot(EState *estate,
|
1997-09-08 21:56:23 +00:00
|
|
|
CommonScanState *commonscanstate);
|
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-07-20 05:16:59 +00:00
|
|
|
extern TupleDesc ExecTypeFromTL(List *targetList, hasoid_t withoid);
|
1998-02-26 04:46:47 +00:00
|
|
|
extern void SetChangedParamList(Plan *node, List *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;
|
2002-07-20 05:49:28 +00: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-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
|
|
|
*/
|
1997-09-08 02:41:22 +00:00
|
|
|
extern void ResetTupleCount(void);
|
1997-09-08 21:56:23 +00:00
|
|
|
extern void ExecAssignExprContext(EState *estate, CommonState *commonstate);
|
1998-09-01 04:40:42 +00:00
|
|
|
extern void ExecAssignResultType(CommonState *commonstate,
|
2001-03-22 04:01:46 +00:00
|
|
|
TupleDesc tupDesc, bool shouldFree);
|
1998-09-01 04:40:42 +00:00
|
|
|
extern void ExecAssignResultTypeFromOuterPlan(Plan *node,
|
1997-09-08 21:56:23 +00:00
|
|
|
CommonState *commonstate);
|
|
|
|
extern void ExecAssignResultTypeFromTL(Plan *node, CommonState *commonstate);
|
|
|
|
extern TupleDesc ExecGetResultType(CommonState *commonstate);
|
|
|
|
extern void ExecAssignProjectionInfo(Plan *node, CommonState *commonstate);
|
|
|
|
extern void ExecFreeProjectionInfo(CommonState *commonstate);
|
1999-04-16 21:27:23 +00:00
|
|
|
extern void ExecFreeExprContext(CommonState *commonstate);
|
1997-09-08 21:56:23 +00:00
|
|
|
extern TupleDesc ExecGetScanType(CommonScanState *csstate);
|
1998-09-01 04:40:42 +00:00
|
|
|
extern void ExecAssignScanType(CommonScanState *csstate,
|
2001-03-22 04:01:46 +00:00
|
|
|
TupleDesc tupDesc, bool shouldFree);
|
1998-09-01 04:40:42 +00:00
|
|
|
extern void ExecAssignScanTypeFromOuterPlan(Plan *node,
|
1997-09-08 21:56:23 +00:00
|
|
|
CommonScanState *csstate);
|
1996-07-09 06:22:35 +00:00
|
|
|
|
2000-07-12 02:37:39 +00:00
|
|
|
extern ExprContext *MakeExprContext(TupleTableSlot *slot,
|
2001-03-22 04:01:46 +00:00
|
|
|
MemoryContext queryContext);
|
2000-07-12 02:37:39 +00:00
|
|
|
extern void FreeExprContext(ExprContext *econtext);
|
|
|
|
|
|
|
|
#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)
|
|
|
|
|
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,
|
|
|
|
ExprContextCallbackFunction function,
|
|
|
|
Datum arg);
|
|
|
|
extern void UnregisterExprContextCallback(ExprContext *econtext,
|
|
|
|
ExprContextCallbackFunction function,
|
|
|
|
Datum arg);
|
|
|
|
|
2001-11-05 17:46:40 +00:00
|
|
|
#endif /* EXECUTOR_H */
|