1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* executor.h
|
1997-09-07 07:04:48 +02:00
|
|
|
* support for the POSTGRES executor module
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*
|
2002-06-20 22:29:54 +02:00
|
|
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2002-08-29 02:17:06 +02:00
|
|
|
* $Id: executor.h,v 1.74 2002/08/29 00:17:06 tgl Exp $
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef EXECUTOR_H
|
|
|
|
#define EXECUTOR_H
|
|
|
|
|
1999-07-16 01:04:24 +02:00
|
|
|
#include "executor/execdesc.h"
|
1996-11-05 09:18:44 +01:00
|
|
|
|
1998-04-24 16:43:33 +02: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-20 00:55:03 +01:00
|
|
|
((slot) == NULL || (slot)->val == NULL)
|
1998-04-24 16:43:33 +02:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/*
|
|
|
|
* prototypes from functions in execAmi.c
|
|
|
|
*/
|
1997-09-08 23:56:23 +02:00
|
|
|
extern void ExecReScan(Plan *node, ExprContext *exprCtxt, Plan *parent);
|
|
|
|
extern void ExecMarkPos(Plan *node);
|
|
|
|
extern void ExecRestrPos(Plan *node);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* prototypes from functions in execJunk.c
|
|
|
|
*/
|
2001-05-27 22:48:51 +02:00
|
|
|
extern JunkFilter *ExecInitJunkFilter(List *targetList, TupleDesc tupType,
|
2001-10-25 07:50:21 +02:00
|
|
|
TupleTableSlot *slot);
|
2001-01-29 01:39:20 +01:00
|
|
|
extern void ExecFreeJunkFilter(JunkFilter *junkfilter);
|
1998-09-01 06:40:42 +02:00
|
|
|
extern bool ExecGetJunkAttribute(JunkFilter *junkfilter, TupleTableSlot *slot,
|
1997-09-08 23:56:23 +02:00
|
|
|
char *attrName, Datum *value, bool *isNull);
|
|
|
|
extern HeapTuple ExecRemoveJunk(JunkFilter *junkfilter, TupleTableSlot *slot);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* prototypes from functions in execMain.c
|
|
|
|
*/
|
1997-09-08 23:56:23 +02:00
|
|
|
extern TupleDesc ExecutorStart(QueryDesc *queryDesc, EState *estate);
|
1999-05-25 18:15:34 +02:00
|
|
|
extern TupleTableSlot *ExecutorRun(QueryDesc *queryDesc, EState *estate,
|
2002-02-27 20:36:13 +01:00
|
|
|
ScanDirection direction, long count);
|
1997-09-08 23:56:23 +02:00
|
|
|
extern void ExecutorEnd(QueryDesc *queryDesc, EState *estate);
|
2002-06-26 23:58:56 +02:00
|
|
|
extern void ExecConstraints(const char *caller, ResultRelInfo *resultRelInfo,
|
2001-03-22 05:01:46 +01:00
|
|
|
TupleTableSlot *slot, EState *estate);
|
2000-05-29 03:59:17 +02:00
|
|
|
extern TupleTableSlot *EvalPlanQual(EState *estate, Index rti,
|
2001-03-22 05:01:46 +01:00
|
|
|
ItemPointer tid);
|
1999-05-25 18:15:34 +02:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/*
|
|
|
|
* prototypes from functions in execProcnode.c
|
|
|
|
*/
|
1997-09-08 23:56:23 +02: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 01:39:20 +01:00
|
|
|
extern TupleDesc ExecGetTupType(Plan *node);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* prototypes from functions in execQual.c
|
|
|
|
*/
|
1998-09-01 06:40:42 +02:00
|
|
|
extern Datum ExecEvalParam(Param *expression, ExprContext *econtext,
|
1997-09-08 23:56:23 +02:00
|
|
|
bool *isNull);
|
2000-08-25 01:34:11 +02:00
|
|
|
extern Datum GetAttributeByNum(TupleTableSlot *slot, AttrNumber attrno,
|
2001-03-22 05:01:46 +01:00
|
|
|
bool *isNull);
|
2000-08-25 01:34:11 +02:00
|
|
|
extern Datum GetAttributeByName(TupleTableSlot *slot, char *attname,
|
2001-03-22 05:01:46 +01:00
|
|
|
bool *isNull);
|
2000-08-24 05:29:15 +02:00
|
|
|
extern Datum ExecMakeFunctionResult(FunctionCachePtr fcache,
|
2001-03-22 05:01:46 +01:00
|
|
|
List *arguments,
|
|
|
|
ExprContext *econtext,
|
|
|
|
bool *isNull,
|
|
|
|
ExprDoneCond *isDone);
|
2000-07-12 04:37:39 +02:00
|
|
|
extern Datum ExecEvalExpr(Node *expression, ExprContext *econtext,
|
2001-03-22 05:01:46 +01:00
|
|
|
bool *isNull, ExprDoneCond *isDone);
|
2000-07-12 04:37:39 +02:00
|
|
|
extern Datum ExecEvalExprSwitchContext(Node *expression, ExprContext *econtext,
|
2001-03-22 05:01:46 +01:00
|
|
|
bool *isNull, ExprDoneCond *isDone);
|
2000-01-20 00:55:03 +01:00
|
|
|
extern bool ExecQual(List *qual, ExprContext *econtext, bool resultForNull);
|
1997-09-08 23:56:23 +02:00
|
|
|
extern int ExecTargetListLength(List *targetlist);
|
2000-08-21 22:55:31 +02:00
|
|
|
extern int ExecCleanTargetListLength(List *targetlist);
|
2000-08-24 05:29:15 +02:00
|
|
|
extern TupleTableSlot *ExecProject(ProjectionInfo *projInfo,
|
2001-03-22 05:01:46 +01:00
|
|
|
ExprDoneCond *isDone);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* prototypes from functions in execScan.c
|
|
|
|
*/
|
2000-07-12 04:37:39 +02:00
|
|
|
typedef TupleTableSlot *(*ExecScanAccessMtd) (Scan *node);
|
|
|
|
|
|
|
|
extern TupleTableSlot *ExecScan(Scan *node, ExecScanAccessMtd accessMtd);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* prototypes from functions in execTuples.c
|
|
|
|
*/
|
|
|
|
extern TupleTable ExecCreateTupleTable(int initialSize);
|
1999-12-10 04:56:14 +01:00
|
|
|
extern void ExecDropTupleTable(TupleTable table, bool shouldFree);
|
1997-09-07 07:04:48 +02:00
|
|
|
extern TupleTableSlot *ExecAllocTableSlot(TupleTable table);
|
2001-01-29 01:39:20 +01:00
|
|
|
extern TupleTableSlot *MakeTupleTableSlot(void);
|
1998-09-01 06:40:42 +02:00
|
|
|
extern TupleTableSlot *ExecStoreTuple(HeapTuple tuple,
|
1997-09-08 23:56:23 +02:00
|
|
|
TupleTableSlot *slot,
|
1997-09-07 07:04:48 +02:00
|
|
|
Buffer buffer,
|
|
|
|
bool shouldFree);
|
1997-09-08 23:56:23 +02:00
|
|
|
extern TupleTableSlot *ExecClearTuple(TupleTableSlot *slot);
|
2001-01-29 01:39:20 +01:00
|
|
|
extern void ExecSetSlotDescriptor(TupleTableSlot *slot,
|
2001-03-22 05:01:46 +01:00
|
|
|
TupleDesc tupdesc, bool shouldFree);
|
1997-09-08 23:56:23 +02:00
|
|
|
extern void ExecSetSlotDescriptorIsNew(TupleTableSlot *slot, bool isNew);
|
|
|
|
extern void ExecInitResultTupleSlot(EState *estate, CommonState *commonstate);
|
1998-09-01 06:40:42 +02:00
|
|
|
extern void ExecInitScanTupleSlot(EState *estate,
|
1997-09-08 23:56:23 +02:00
|
|
|
CommonScanState *commonscanstate);
|
2000-09-12 23:07:18 +02:00
|
|
|
extern TupleTableSlot *ExecInitExtraTupleSlot(EState *estate);
|
|
|
|
extern TupleTableSlot *ExecInitNullTupleSlot(EState *estate,
|
2001-03-22 05:01:46 +01:00
|
|
|
TupleDesc tupType);
|
2002-07-20 07:16:59 +02:00
|
|
|
extern TupleDesc ExecTypeFromTL(List *targetList, hasoid_t withoid);
|
1998-02-26 05:46:47 +01:00
|
|
|
extern void SetChangedParamList(Plan *node, List *newchg);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
2002-07-20 07:49:28 +02:00
|
|
|
typedef struct TupOutputState
|
|
|
|
{
|
2002-08-29 02:17:06 +02:00
|
|
|
/* use "struct" here to allow forward reference */
|
|
|
|
struct AttInMetadata *metadata;
|
2002-07-20 07:49:28 +02: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 02:17:06 +02: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 07:49:28 +02:00
|
|
|
do { \
|
2002-07-20 17:12:56 +02:00
|
|
|
char *values_[1]; \
|
2002-08-29 02:17:06 +02:00
|
|
|
values_[0] = (text_to_emit); \
|
2002-07-20 17:12:56 +02:00
|
|
|
do_tup_output(tstate, values_); \
|
2002-07-20 07:49:28 +02:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/*
|
1999-04-16 23:27:23 +02:00
|
|
|
* prototypes from functions in execUtils.c
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
extern void ResetTupleCount(void);
|
1997-09-08 23:56:23 +02:00
|
|
|
extern void ExecAssignExprContext(EState *estate, CommonState *commonstate);
|
1998-09-01 06:40:42 +02:00
|
|
|
extern void ExecAssignResultType(CommonState *commonstate,
|
2001-03-22 05:01:46 +01:00
|
|
|
TupleDesc tupDesc, bool shouldFree);
|
1998-09-01 06:40:42 +02:00
|
|
|
extern void ExecAssignResultTypeFromOuterPlan(Plan *node,
|
1997-09-08 23:56:23 +02: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 23:27:23 +02:00
|
|
|
extern void ExecFreeExprContext(CommonState *commonstate);
|
1997-09-08 23:56:23 +02:00
|
|
|
extern TupleDesc ExecGetScanType(CommonScanState *csstate);
|
1998-09-01 06:40:42 +02:00
|
|
|
extern void ExecAssignScanType(CommonScanState *csstate,
|
2001-03-22 05:01:46 +01:00
|
|
|
TupleDesc tupDesc, bool shouldFree);
|
1998-09-01 06:40:42 +02:00
|
|
|
extern void ExecAssignScanTypeFromOuterPlan(Plan *node,
|
1997-09-08 23:56:23 +02:00
|
|
|
CommonScanState *csstate);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
2000-07-12 04:37:39 +02:00
|
|
|
extern ExprContext *MakeExprContext(TupleTableSlot *slot,
|
2001-03-22 05:01:46 +01:00
|
|
|
MemoryContext queryContext);
|
2000-07-12 04:37:39 +02:00
|
|
|
extern void FreeExprContext(ExprContext *econtext);
|
|
|
|
|
|
|
|
#define ResetExprContext(econtext) \
|
|
|
|
MemoryContextReset((econtext)->ecxt_per_tuple_memory)
|
|
|
|
|
2001-01-22 01:50:07 +01: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 01:37:02 +01:00
|
|
|
extern void ExecOpenIndices(ResultRelInfo *resultRelInfo);
|
|
|
|
extern void ExecCloseIndices(ResultRelInfo *resultRelInfo);
|
1998-09-01 06:40:42 +02:00
|
|
|
extern void ExecInsertIndexTuples(TupleTableSlot *slot, ItemPointer tupleid,
|
2002-05-24 20:57:57 +02:00
|
|
|
EState *estate, bool is_vacuum);
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2002-05-12 22:10:05 +02:00
|
|
|
extern void RegisterExprContextCallback(ExprContext *econtext,
|
|
|
|
ExprContextCallbackFunction function,
|
|
|
|
Datum arg);
|
|
|
|
extern void UnregisterExprContextCallback(ExprContext *econtext,
|
|
|
|
ExprContextCallbackFunction function,
|
|
|
|
Datum arg);
|
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* EXECUTOR_H */
|