]> granicus.if.org Git - postgresql/blobdiff - src/backend/executor/nodeBitmapIndexscan.c
Make some small planner API cleanups.
[postgresql] / src / backend / executor / nodeBitmapIndexscan.c
index 8e1df079b3728d69cdcae13b1eeec538bb469311..bd837d3cd8e13c5a146461e6553afc02697faf21 100644 (file)
@@ -3,7 +3,7 @@
  * nodeBitmapIndexscan.c
  *       Routines to support bitmapped index scans of relations
  *
- * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  *
@@ -21,6 +21,7 @@
  */
 #include "postgres.h"
 
+#include "access/genam.h"
 #include "executor/execdebug.h"
 #include "executor/nodeBitmapIndexscan.h"
 #include "executor/nodeIndexscan.h"
 #include "utils/memutils.h"
 
 
+/* ----------------------------------------------------------------
+ *             ExecBitmapIndexScan
+ *
+ *             stub for pro forma compliance
+ * ----------------------------------------------------------------
+ */
+static TupleTableSlot *
+ExecBitmapIndexScan(PlanState *pstate)
+{
+       elog(ERROR, "BitmapIndexScan node does not support ExecProcNode call convention");
+       return NULL;
+}
+
 /* ----------------------------------------------------------------
  *             MultiExecBitmapIndexScan(node)
  * ----------------------------------------------------------------
@@ -73,12 +87,14 @@ MultiExecBitmapIndexScan(BitmapIndexScanState *node)
        if (node->biss_result)
        {
                tbm = node->biss_result;
-               node->biss_result = NULL;               /* reset for next time */
+               node->biss_result = NULL;       /* reset for next time */
        }
        else
        {
                /* XXX should we use less than work_mem for this? */
-               tbm = tbm_create(work_mem * 1024L);
+               tbm = tbm_create(work_mem * 1024L,
+                                                ((BitmapIndexScan *) node->ss.ps.plan)->isshared ?
+                                                node->ss.ps.state->es_query_dsa : NULL);
        }
 
        /*
@@ -206,10 +222,20 @@ ExecInitBitmapIndexScan(BitmapIndexScan *node, EState *estate, int eflags)
        indexstate = makeNode(BitmapIndexScanState);
        indexstate->ss.ps.plan = (Plan *) node;
        indexstate->ss.ps.state = estate;
+       indexstate->ss.ps.ExecProcNode = ExecBitmapIndexScan;
 
        /* normally we don't make the result bitmap till runtime */
        indexstate->biss_result = NULL;
 
+       /*
+        * We do not open or lock the base relation here.  We assume that an
+        * ancestor BitmapHeapScan node is holding AccessShareLock (or better) on
+        * the heap relation throughout the execution of the plan tree.
+        */
+
+       indexstate->ss.ss_currentRelation = NULL;
+       indexstate->ss.ss_currentScanDesc = NULL;
+
        /*
         * Miscellaneous initialization
         *
@@ -226,15 +252,6 @@ ExecInitBitmapIndexScan(BitmapIndexScan *node, EState *estate, int eflags)
         * sub-parts corresponding to runtime keys (see below).
         */
 
-       /*
-        * We do not open or lock the base relation here.  We assume that an
-        * ancestor BitmapHeapScan node is holding AccessShareLock (or better) on
-        * the heap relation throughout the execution of the plan tree.
-        */
-
-       indexstate->ss.ss_currentRelation = NULL;
-       indexstate->ss.ss_currentScanDesc = NULL;
-
        /*
         * If we are just doing EXPLAIN (ie, aren't going to run the plan), stop
         * here.  This allows an index-advisor plugin to EXPLAIN a plan containing
@@ -252,7 +269,7 @@ ExecInitBitmapIndexScan(BitmapIndexScan *node, EState *estate, int eflags)
         */
        relistarget = ExecRelationIsTargetRelation(estate, node->scan.scanrelid);
        indexstate->biss_RelationDesc = index_open(node->indexid,
-                                                                        relistarget ? NoLock : AccessShareLock);
+                                                                                          relistarget ? NoLock : AccessShareLock);
 
        /*
         * Initialize index-specific scan state
@@ -266,7 +283,6 @@ ExecInitBitmapIndexScan(BitmapIndexScan *node, EState *estate, int eflags)
         */
        ExecIndexBuildScanKeys((PlanState *) indexstate,
                                                   indexstate->biss_RelationDesc,
-                                                  node->scan.scanrelid,
                                                   node->indexqual,
                                                   false,
                                                   &indexstate->biss_ScanKeys,