mirror of
https://github.com/postgres/postgres.git
synced 2025-07-08 11:42:09 +03:00
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
This commit is contained in:
@ -32,7 +32,6 @@
|
||||
#include "executor/nodeSeqscan.h"
|
||||
#include "utils/rel.h"
|
||||
|
||||
static void InitScanRelation(SeqScanState *node, EState *estate, int eflags);
|
||||
static TupleTableSlot *SeqNext(SeqScanState *node);
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
@ -132,31 +131,6 @@ ExecSeqScan(PlanState *pstate)
|
||||
(ExecScanRecheckMtd) SeqRecheck);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* InitScanRelation
|
||||
*
|
||||
* Set up to access the scan relation.
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
static void
|
||||
InitScanRelation(SeqScanState *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,
|
||||
((SeqScan *) node->ss.ps.plan)->scanrelid,
|
||||
eflags);
|
||||
|
||||
node->ss.ss_currentRelation = currentRelation;
|
||||
|
||||
/* and report the scan tuple slot's rowtype */
|
||||
ExecAssignScanType(&node->ss, RelationGetDescr(currentRelation));
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* ExecInitSeqScan
|
||||
@ -189,29 +163,33 @@ ExecInitSeqScan(SeqScan *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.
|
||||
*/
|
||||
scanstate->ss.ss_currentRelation =
|
||||
ExecOpenScanRelation(estate,
|
||||
node->scanrelid,
|
||||
eflags);
|
||||
|
||||
/* and create slot with the appropriate rowtype */
|
||||
ExecInitScanTupleSlot(estate, &scanstate->ss,
|
||||
RelationGetDescr(scanstate->ss.ss_currentRelation));
|
||||
|
||||
/*
|
||||
* Initialize result slot, type and projection.
|
||||
*/
|
||||
ExecInitResultTupleSlotTL(estate, &scanstate->ss.ps);
|
||||
ExecAssignScanProjectionInfo(&scanstate->ss);
|
||||
|
||||
/*
|
||||
* initialize child expressions
|
||||
*/
|
||||
scanstate->ss.ps.qual =
|
||||
ExecInitQual(node->plan.qual, (PlanState *) scanstate);
|
||||
|
||||
/*
|
||||
* tuple table initialization
|
||||
*/
|
||||
ExecInitResultTupleSlot(estate, &scanstate->ss.ps);
|
||||
ExecInitScanTupleSlot(estate, &scanstate->ss);
|
||||
|
||||
/*
|
||||
* initialize scan relation
|
||||
*/
|
||||
InitScanRelation(scanstate, estate, eflags);
|
||||
|
||||
/*
|
||||
* Initialize result tuple type and projection info.
|
||||
*/
|
||||
ExecAssignResultTypeFromTL(&scanstate->ss.ps);
|
||||
ExecAssignScanProjectionInfo(&scanstate->ss);
|
||||
|
||||
return scanstate;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user