]> granicus.if.org Git - postgresql/blobdiff - src/backend/executor/nodeSamplescan.c
Make some small planner API cleanups.
[postgresql] / src / backend / executor / nodeSamplescan.c
index 15177dbed7a1f101eefa6a3ff2cb4061ac206c2c..da4a65fd30ad99b65027ece482844f62f8b0ec91 100644 (file)
@@ -3,7 +3,7 @@
  * nodeSamplescan.c
  *       Support routines for sample scans of relations (table sampling).
  *
- * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  *
@@ -15,6 +15,7 @@
 #include "postgres.h"
 
 #include "access/hash.h"
+#include "access/heapam.h"
 #include "access/relscan.h"
 #include "access/tsmapi.h"
 #include "executor/executor.h"
@@ -24,7 +25,6 @@
 #include "storage/predicate.h"
 #include "utils/builtins.h"
 #include "utils/rel.h"
-#include "utils/tqual.h"
 
 static TupleTableSlot *SampleNext(SampleScanState *node);
 static void tablesample_init(SampleScanState *scanstate);
@@ -63,10 +63,9 @@ SampleNext(SampleScanState *node)
        slot = node->ss.ss_ScanTupleSlot;
 
        if (tuple)
-               ExecStoreTuple(tuple,   /* tuple to store */
-                                          slot,        /* slot to store in */
-                                          node->ss.ss_currentScanDesc->rs_cbuf,        /* tuple's buffer */
-                                          false);      /* don't pfree this pointer */
+               ExecStoreBufferHeapTuple(tuple, /* tuple to store */
+                                                                slot,  /* slot to store in */
+                                                                node->ss.ss_currentScanDesc->rs_cbuf); /* tuple's buffer */
        else
                ExecClearTuple(slot);
 
@@ -135,10 +134,7 @@ ExecInitSampleScan(SampleScan *node, EState *estate, int eflags)
        ExecAssignExprContext(estate, &scanstate->ss.ps);
 
        /*
-        * Initialize scan relation.
-        *
-        * Get the relation object id from the relid'th entry in the range table,
-        * open that relation and acquire appropriate lock on it.
+        * open the scan relation
         */
        scanstate->ss.ss_currentRelation =
                ExecOpenScanRelation(estate,
@@ -150,13 +146,13 @@ ExecInitSampleScan(SampleScan *node, EState *estate, int eflags)
 
        /* and create slot with appropriate rowtype */
        ExecInitScanTupleSlot(estate, &scanstate->ss,
-                                                 RelationGetDescr(scanstate->ss.ss_currentRelation));
+                                                 RelationGetDescr(scanstate->ss.ss_currentRelation),
+                                                 &TTSOpsBufferHeapTuple);
 
        /*
-        * Initialize result slot, type and projection. tuple table and result
-        * tuple initialization
+        * Initialize result type and projection.
         */
-       ExecInitResultTupleSlotTL(estate, &scanstate->ss.ps);
+       ExecInitResultTypeTL(&scanstate->ss.ps);
        ExecAssignScanProjectionInfo(&scanstate->ss);
 
        /*
@@ -215,7 +211,8 @@ ExecEndSampleScan(SampleScanState *node)
        /*
         * clean out the tuple table
         */
-       ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
+       if (node->ss.ps.ps_ResultTupleSlot)
+               ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
        ExecClearTuple(node->ss.ss_ScanTupleSlot);
 
        /*
@@ -223,11 +220,6 @@ ExecEndSampleScan(SampleScanState *node)
         */
        if (node->ss.ss_currentScanDesc)
                heap_endscan(node->ss.ss_currentScanDesc);
-
-       /*
-        * close the heap relation.
-        */
-       ExecCloseScanRelation(node->ss.ss_currentRelation);
 }
 
 /* ----------------------------------------------------------------