Skip to content

Commit 6cc88f0

Browse files
committed
Provide a function hook to let plug-ins get control around ExecutorRun.
ITAGAKI Takahiro
1 parent 8d7af89 commit 6cc88f0

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

src/backend/executor/execMain.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*
2727
*
2828
* IDENTIFICATION
29-
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.309 2008/05/12 20:02:00 alvherre Exp $
29+
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.310 2008/07/18 18:23:46 tgl Exp $
3030
*
3131
*-------------------------------------------------------------------------
3232
*/
@@ -58,6 +58,9 @@
5858
#include "utils/tqual.h"
5959

6060

61+
/* Hook for plugins to get control in ExecutorRun() */
62+
ExecutorRun_hook_type ExecutorRun_hook = NULL;
63+
6164
typedef struct evalPlanQual
6265
{
6366
Index rti;
@@ -214,11 +217,28 @@ ExecutorStart(QueryDesc *queryDesc, int eflags)
214217
* Note: count = 0 is interpreted as no portal limit, i.e., run to
215218
* completion.
216219
*
220+
* We provide a function hook variable that lets loadable plugins
221+
* get control when ExecutorRun is called. Such a plugin would
222+
* normally call standard_ExecutorRun().
223+
*
217224
* ----------------------------------------------------------------
218225
*/
219226
TupleTableSlot *
220227
ExecutorRun(QueryDesc *queryDesc,
221228
ScanDirection direction, long count)
229+
{
230+
TupleTableSlot *result;
231+
232+
if (ExecutorRun_hook)
233+
result = (*ExecutorRun_hook) (queryDesc, direction, count);
234+
else
235+
result = standard_ExecutorRun(queryDesc, direction, count);
236+
return result;
237+
}
238+
239+
TupleTableSlot *
240+
standard_ExecutorRun(QueryDesc *queryDesc,
241+
ScanDirection direction, long count)
222242
{
223243
EState *estate;
224244
CmdType operation;

src/include/executor/executor.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/executor/executor.h,v 1.147 2008/03/28 00:21:56 tgl Exp $
10+
* $PostgreSQL: pgsql/src/include/executor/executor.h,v 1.148 2008/07/18 18:23:47 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -60,6 +60,13 @@
6060
((*(expr)->evalfunc) (expr, econtext, isNull, isDone))
6161

6262

63+
/* Hook for plugins to get control in ExecutorRun() */
64+
typedef TupleTableSlot *(*ExecutorRun_hook_type) (QueryDesc *queryDesc,
65+
ScanDirection direction,
66+
long count);
67+
extern PGDLLIMPORT ExecutorRun_hook_type ExecutorRun_hook;
68+
69+
6370
/*
6471
* prototypes from functions in execAmi.c
6572
*/
@@ -136,6 +143,8 @@ extern HeapTuple ExecRemoveJunk(JunkFilter *junkfilter, TupleTableSlot *slot);
136143
extern void ExecutorStart(QueryDesc *queryDesc, int eflags);
137144
extern TupleTableSlot *ExecutorRun(QueryDesc *queryDesc,
138145
ScanDirection direction, long count);
146+
extern TupleTableSlot *standard_ExecutorRun(QueryDesc *queryDesc,
147+
ScanDirection direction, long count);
139148
extern void ExecutorEnd(QueryDesc *queryDesc);
140149
extern void ExecutorRewind(QueryDesc *queryDesc);
141150
extern void InitResultRelInfo(ResultRelInfo *resultRelInfo,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy