mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +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:
@ -596,6 +596,7 @@ ExecInitHashJoin(HashJoin *node, EState *estate, int eflags)
|
||||
List *lclauses;
|
||||
List *rclauses;
|
||||
List *hoperators;
|
||||
TupleDesc outerDesc, innerDesc;
|
||||
ListCell *l;
|
||||
|
||||
/* check for unsupported flags */
|
||||
@ -614,6 +615,7 @@ ExecInitHashJoin(HashJoin *node, EState *estate, int eflags)
|
||||
* managed to launch a parallel query.
|
||||
*/
|
||||
hjstate->js.ps.ExecProcNode = ExecHashJoin;
|
||||
hjstate->js.jointype = node->join.jointype;
|
||||
|
||||
/*
|
||||
* Miscellaneous initialization
|
||||
@ -622,17 +624,6 @@ ExecInitHashJoin(HashJoin *node, EState *estate, int eflags)
|
||||
*/
|
||||
ExecAssignExprContext(estate, &hjstate->js.ps);
|
||||
|
||||
/*
|
||||
* initialize child expressions
|
||||
*/
|
||||
hjstate->js.ps.qual =
|
||||
ExecInitQual(node->join.plan.qual, (PlanState *) hjstate);
|
||||
hjstate->js.jointype = node->join.jointype;
|
||||
hjstate->js.joinqual =
|
||||
ExecInitQual(node->join.joinqual, (PlanState *) hjstate);
|
||||
hjstate->hashclauses =
|
||||
ExecInitQual(node->hashclauses, (PlanState *) hjstate);
|
||||
|
||||
/*
|
||||
* initialize child nodes
|
||||
*
|
||||
@ -644,13 +635,20 @@ ExecInitHashJoin(HashJoin *node, EState *estate, int eflags)
|
||||
hashNode = (Hash *) innerPlan(node);
|
||||
|
||||
outerPlanState(hjstate) = ExecInitNode(outerNode, estate, eflags);
|
||||
outerDesc = ExecGetResultType(outerPlanState(hjstate));
|
||||
innerPlanState(hjstate) = ExecInitNode((Plan *) hashNode, estate, eflags);
|
||||
innerDesc = ExecGetResultType(innerPlanState(hjstate));
|
||||
|
||||
/*
|
||||
* Initialize result slot, type and projection.
|
||||
*/
|
||||
ExecInitResultTupleSlotTL(estate, &hjstate->js.ps);
|
||||
ExecAssignProjectionInfo(&hjstate->js.ps, NULL);
|
||||
|
||||
/*
|
||||
* tuple table initialization
|
||||
*/
|
||||
ExecInitResultTupleSlot(estate, &hjstate->js.ps);
|
||||
hjstate->hj_OuterTupleSlot = ExecInitExtraTupleSlot(estate);
|
||||
hjstate->hj_OuterTupleSlot = ExecInitExtraTupleSlot(estate, outerDesc);
|
||||
|
||||
/*
|
||||
* detect whether we need only consider the first matching inner tuple
|
||||
@ -667,21 +665,17 @@ ExecInitHashJoin(HashJoin *node, EState *estate, int eflags)
|
||||
case JOIN_LEFT:
|
||||
case JOIN_ANTI:
|
||||
hjstate->hj_NullInnerTupleSlot =
|
||||
ExecInitNullTupleSlot(estate,
|
||||
ExecGetResultType(innerPlanState(hjstate)));
|
||||
ExecInitNullTupleSlot(estate, innerDesc);
|
||||
break;
|
||||
case JOIN_RIGHT:
|
||||
hjstate->hj_NullOuterTupleSlot =
|
||||
ExecInitNullTupleSlot(estate,
|
||||
ExecGetResultType(outerPlanState(hjstate)));
|
||||
ExecInitNullTupleSlot(estate, outerDesc);
|
||||
break;
|
||||
case JOIN_FULL:
|
||||
hjstate->hj_NullOuterTupleSlot =
|
||||
ExecInitNullTupleSlot(estate,
|
||||
ExecGetResultType(outerPlanState(hjstate)));
|
||||
ExecInitNullTupleSlot(estate, outerDesc);
|
||||
hjstate->hj_NullInnerTupleSlot =
|
||||
ExecInitNullTupleSlot(estate,
|
||||
ExecGetResultType(innerPlanState(hjstate)));
|
||||
ExecInitNullTupleSlot(estate, innerDesc);
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "unrecognized join type: %d",
|
||||
@ -703,13 +697,14 @@ ExecInitHashJoin(HashJoin *node, EState *estate, int eflags)
|
||||
}
|
||||
|
||||
/*
|
||||
* initialize tuple type and projection info
|
||||
* initialize child expressions
|
||||
*/
|
||||
ExecAssignResultTypeFromTL(&hjstate->js.ps);
|
||||
ExecAssignProjectionInfo(&hjstate->js.ps, NULL);
|
||||
|
||||
ExecSetSlotDescriptor(hjstate->hj_OuterTupleSlot,
|
||||
ExecGetResultType(outerPlanState(hjstate)));
|
||||
hjstate->js.ps.qual =
|
||||
ExecInitQual(node->join.plan.qual, (PlanState *) hjstate);
|
||||
hjstate->js.joinqual =
|
||||
ExecInitQual(node->join.joinqual, (PlanState *) hjstate);
|
||||
hjstate->hashclauses =
|
||||
ExecInitQual(node->hashclauses, (PlanState *) hjstate);
|
||||
|
||||
/*
|
||||
* initialize hash-specific info
|
||||
|
Reference in New Issue
Block a user