diff options
author | Andres Freund <andres@anarazel.de> | 2018-02-16 21:17:38 -0800 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2018-02-16 21:17:38 -0800 |
commit | ad7dbee368a7cd9e595d2a957be784326b08c943 (patch) | |
tree | a4846e24bf9f2d78b7c8dfb04323ef984aede517 /src/backend/executor/nodeSamplescan.c | |
parent | bf6c614a2f2c58312b3be34a47e7fb7362e07bcb (diff) | |
download | postgresql-ad7dbee368a7cd9e595d2a957be784326b08c943.tar.gz postgresql-ad7dbee368a7cd9e595d2a957be784326b08c943.zip |
Allow tupleslots to have a fixed tupledesc, use in executor nodes.
The reason for doing so is that it will allow expression evaluation to
optimize based on the underlying tupledesc. In particular it will
allow to JIT tuple deforming together with the expression itself.
For that expression initialization needs to be moved after the
relevant slots are initialized - mostly unproblematic, except in the
case of nodeWorktablescan.c.
After doing so there's no need for ExecAssignResultType() and
ExecAssignResultTypeFromTL() anymore, as all former callers have been
converted to create a slot with a fixed descriptor.
When creating a slot with a fixed descriptor, tts_values/isnull can be
allocated together with the main slot, reducing allocation overhead
and increasing cache density a bit.
Author: Andres Freund
Discussion: https://postgr.es/m/20171206093717.vqdxe5icqttpxs3p@alap3.anarazel.de
Diffstat (limited to 'src/backend/executor/nodeSamplescan.c')
-rw-r--r-- | src/backend/executor/nodeSamplescan.c | 70 |
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 |