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 ccbafe61b8961cd97dd4b0872d659ade0234d599..676f771acd92a63c383138b84b6acbc5a9f861ae 100644 (file)
@@ -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 ad375e85320da6c3ffaaa6744e046328c19ba5b7..a58f4ac1e7fb44923533805a4bf08f1cf5f01ad4 100644 (file)
        ((*(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,