From 7d279ea7b5d0943f66c52497abd5db473234569f Mon Sep 17 00:00:00 2001 From: tgl Date: Fri, 18 Jul 2008 18:23:47 +0000 Subject: [PATCH] Provide a function hook to let plug-ins get control around ExecutorRun. ITAGAKI Takahiro --- src/backend/executor/execMain.c | 20 ++++++++++++++++++++ src/include/executor/executor.h | 9 +++++++++ 2 files changed, 29 insertions(+) diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index ccbafe61b8..676f771acd 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -58,6 +58,9 @@ #include "utils/tqual.h" +/* Hook for plugins to get control in ExecutorRun() */ +ExecutorRun_hook_type ExecutorRun_hook = NULL; + typedef struct evalPlanQual { Index rti; @@ -214,12 +217,29 @@ ExecutorStart(QueryDesc *queryDesc, int eflags) * Note: count = 0 is interpreted as no portal limit, i.e., run to * completion. * + * We provide a function hook variable that lets loadable plugins + * get control when ExecutorRun is called. Such a plugin would + * normally call standard_ExecutorRun(). + * * ---------------------------------------------------------------- */ TupleTableSlot * ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, long count) { + TupleTableSlot *result; + + if (ExecutorRun_hook) + result = (*ExecutorRun_hook) (queryDesc, direction, count); + else + result = standard_ExecutorRun(queryDesc, direction, count); + return result; +} + +TupleTableSlot * +standard_ExecutorRun(QueryDesc *queryDesc, + ScanDirection direction, long count) +{ EState *estate; CmdType operation; DestReceiver *dest; diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h index ad375e8532..a58f4ac1e7 100644 --- a/src/include/executor/executor.h +++ b/src/include/executor/executor.h @@ -60,6 +60,13 @@ ((*(expr)->evalfunc) (expr, econtext, isNull, isDone)) +/* Hook for plugins to get control in ExecutorRun() */ +typedef TupleTableSlot *(*ExecutorRun_hook_type) (QueryDesc *queryDesc, + ScanDirection direction, + long count); +extern PGDLLIMPORT ExecutorRun_hook_type ExecutorRun_hook; + + /* * prototypes from functions in execAmi.c */ @@ -136,6 +143,8 @@ extern HeapTuple ExecRemoveJunk(JunkFilter *junkfilter, TupleTableSlot *slot); extern void ExecutorStart(QueryDesc *queryDesc, int eflags); extern TupleTableSlot *ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, long count); +extern TupleTableSlot *standard_ExecutorRun(QueryDesc *queryDesc, + ScanDirection direction, long count); extern void ExecutorEnd(QueryDesc *queryDesc); extern void ExecutorRewind(QueryDesc *queryDesc); extern void InitResultRelInfo(ResultRelInfo *resultRelInfo, -- 2.11.4.GIT