* 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
*
*
#include "postgres.h"
#include "access/hash.h"
+#include "access/heapam.h"
#include "access/relscan.h"
#include "access/tsmapi.h"
#include "executor/executor.h"
#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);
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);
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,
/* 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);
/*
/*
* 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);
/*
*/
if (node->ss.ss_currentScanDesc)
heap_endscan(node->ss.ss_currentScanDesc);
-
- /*
- * close the heap relation.
- */
- ExecCloseScanRelation(node->ss.ss_currentRelation);
}
/* ----------------------------------------------------------------