* nodeTidscan.c
* Routines to support direct tid scans of relations
*
- * 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/heapam.h"
#include "access/sysattr.h"
#include "catalog/pg_type.h"
#include "executor/execdebug.h"
#include "executor/nodeTidscan.h"
#include "miscadmin.h"
-#include "optimizer/clauses.h"
+#include "nodes/nodeFuncs.h"
#include "storage/bufmgr.h"
#include "utils/array.h"
#include "utils/rel.h"
if (heap_fetch(heapRelation, snapshot, tuple, &buffer, false, NULL))
{
/*
- * store the scanned tuple in the scan tuple slot of the scan
+ * Store the scanned tuple in the scan tuple slot of the scan
* state. Eventually we will only do this and not return a tuple.
- * Note: we pass 'false' because tuples returned by amgetnext are
- * pointers onto disk pages and were not created with palloc() and
- * so should not be pfree()'d.
*/
- ExecStoreTuple(tuple, /* tuple to store */
- slot, /* slot to store in */
- buffer, /* buffer associated with tuple */
- false); /* don't pfree */
+ ExecStoreBufferHeapTuple(tuple, /* tuple to store */
+ slot, /* slot to store in */
+ buffer); /* buffer associated with
+ * tuple */
/*
* At this point we have an extra pin on the buffer, because
- * ExecStoreTuple incremented the pin count. Drop our local pin.
+ * ExecStoreHeapTuple incremented the pin count. Drop our local
+ * pin.
*/
ReleaseBuffer(buffer);
/*
* clear out tuple table slots
*/
- ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
+ if (node->ss.ps.ps_ResultTupleSlot)
+ ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
ExecClearTuple(node->ss.ss_ScanTupleSlot);
-
- /*
- * close the heap relation.
- */
- ExecCloseScanRelation(node->ss.ss_currentRelation);
}
/* ----------------------------------------------------------------
*/
ExecAssignExprContext(estate, &tidstate->ss.ps);
- /*
- * initialize child expressions
- */
- tidstate->ss.ps.qual =
- ExecInitQual(node->scan.plan.qual, (PlanState *) tidstate);
-
- TidExprListCreate(tidstate);
-
- /*
- * tuple table initialization
- */
- ExecInitResultTupleSlot(estate, &tidstate->ss.ps);
- ExecInitScanTupleSlot(estate, &tidstate->ss);
-
/*
* mark tid list as not computed yet
*/
tidstate->tss_TidPtr = -1;
/*
- * open the base relation and acquire appropriate lock on it.
+ * open the scan relation
*/
currentRelation = ExecOpenScanRelation(estate, node->scan.scanrelid, eflags);
/*
* get the scan type from the relation descriptor.
*/
- ExecAssignScanType(&tidstate->ss, RelationGetDescr(currentRelation));
+ ExecInitScanTupleSlot(estate, &tidstate->ss,
+ RelationGetDescr(currentRelation),
+ &TTSOpsBufferHeapTuple);
/*
- * Initialize result tuple type and projection info.
+ * Initialize result type and projection.
*/
- ExecAssignResultTypeFromTL(&tidstate->ss.ps);
+ ExecInitResultTypeTL(&tidstate->ss.ps);
ExecAssignScanProjectionInfo(&tidstate->ss);
+ /*
+ * initialize child expressions
+ */
+ tidstate->ss.ps.qual =
+ ExecInitQual(node->scan.plan.qual, (PlanState *) tidstate);
+
+ TidExprListCreate(tidstate);
+
/*
* all done.
*/