]> granicus.if.org Git - postgresql/commitdiff
Provide a function hook to let plug-ins get control around ExecutorRun.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 18 Jul 2008 18:23:47 +0000 (18:23 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 18 Jul 2008 18:23:47 +0000 (18:23 +0000)
ITAGAKI Takahiro

src/backend/executor/execMain.c
src/include/executor/executor.h

index 7da618033d88868f2323b32d95b363ad948cec38..93f780467078e3850534ece6f4c2a7e1ef86d3c8 100644 (file)
@@ -26,7 +26,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.309 2008/05/12 20:02:00 alvherre Exp $
+ *       $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.310 2008/07/18 18:23:46 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -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,11 +217,28 @@ 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;
index 2a920cebb9a5df320d64950dc51e8976de2c90e6..71cb94d4c5d072bb9f7dcdfa061e30180c4ecaf9 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/executor/executor.h,v 1.147 2008/03/28 00:21:56 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/executor/executor.h,v 1.148 2008/07/18 18:23:47 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
        ((*(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,