aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeSamplescan.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/executor/nodeSamplescan.c')
-rw-r--r--src/backend/executor/nodeSamplescan.c70
1 files changed, 24 insertions, 46 deletions
diff --git a/src/backend/executor/nodeSamplescan.c b/src/backend/executor/nodeSamplescan.c
index e88cd187373..872d6e5735e 100644
--- a/src/backend/executor/nodeSamplescan.c
+++ b/src/backend/executor/nodeSamplescan.c
@@ -26,7 +26,6 @@
#include "utils/rel.h"
#include "utils/tqual.h"
-static void InitScanRelation(SampleScanState *node, EState *estate, int eflags);
static TupleTableSlot *SampleNext(SampleScanState *node);
static void tablesample_init(SampleScanState *scanstate);
static HeapTuple tablesample_getnext(SampleScanState *scanstate);
@@ -107,35 +106,6 @@ ExecSampleScan(PlanState *pstate)
}
/* ----------------------------------------------------------------
- * InitScanRelation
- *
- * Set up to access the scan relation.
- * ----------------------------------------------------------------
- */
-static void
-InitScanRelation(SampleScanState *node, EState *estate, int eflags)
-{
- Relation currentRelation;
-
- /*
- * get the relation object id from the relid'th entry in the range table,
- * open that relation and acquire appropriate lock on it.
- */
- currentRelation = ExecOpenScanRelation(estate,
- ((SampleScan *) node->ss.ps.plan)->scan.scanrelid,
- eflags);
-
- node->ss.ss_currentRelation = currentRelation;
-
- /* we won't set up the HeapScanDesc till later */
- node->ss.ss_currentScanDesc = NULL;
-
- /* and report the scan tuple slot's rowtype */
- ExecAssignScanType(&node->ss, RelationGetDescr(currentRelation));
-}
-
-
-/* ----------------------------------------------------------------
* ExecInitSampleScan
* ----------------------------------------------------------------
*/
@@ -165,31 +135,39 @@ ExecInitSampleScan(SampleScan *node, EState *estate, int eflags)
ExecAssignExprContext(estate, &scanstate->ss.ps);
/*
- * initialize child expressions
+ * 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.
*/
- scanstate->ss.ps.qual =
- ExecInitQual(node->scan.plan.qual, (PlanState *) scanstate);
+ scanstate->ss.ss_currentRelation =
+ ExecOpenScanRelation(estate,
+ node->scan.scanrelid,
+ eflags);
- scanstate->args = ExecInitExprList(tsc->args, (PlanState *) scanstate);
- scanstate->repeatable =
- ExecInitExpr(tsc->repeatable, (PlanState *) scanstate);
+ /* we won't set up the HeapScanDesc till later */
+ scanstate->ss.ss_currentScanDesc = NULL;
- /*
- * tuple table initialization
- */
- ExecInitResultTupleSlot(estate, &scanstate->ss.ps);
- ExecInitScanTupleSlot(estate, &scanstate->ss);
+ /* and create slot with appropriate rowtype */
+ ExecInitScanTupleSlot(estate, &scanstate->ss,
+ RelationGetDescr(scanstate->ss.ss_currentRelation));
/*
- * initialize scan relation
+ * Initialize result slot, type and projection.
+ * tuple table and result tuple initialization
*/
- InitScanRelation(scanstate, estate, eflags);
+ ExecInitResultTupleSlotTL(estate, &scanstate->ss.ps);
+ ExecAssignScanProjectionInfo(&scanstate->ss);
/*
- * Initialize result tuple type and projection info.
+ * initialize child expressions
*/
- ExecAssignResultTypeFromTL(&scanstate->ss.ps);
- ExecAssignScanProjectionInfo(&scanstate->ss);
+ scanstate->ss.ps.qual =
+ ExecInitQual(node->scan.plan.qual, (PlanState *) scanstate);
+
+ scanstate->args = ExecInitExprList(tsc->args, (PlanState *) scanstate);
+ scanstate->repeatable =
+ ExecInitExpr(tsc->repeatable, (PlanState *) scanstate);
/*
* If we don't have a REPEATABLE clause, select a random seed. We want to