Rely on executor utils to build targetlist for DML RETURNING.
This is useful because it gets rid of the sole direct user of ExecAssignResultType(). A future commit will likely make use of that and combine creating the targetlist with the initialization of the result slot. But it seems like good code hygiene anyway. Author: Andres Freund Discussion: https://postgr.es/m/20170901064131.tazjxwus3k2w3ybh@alap3.anarazel.de
This commit is contained in:
parent
d02974e32e
commit
4717fdb14c
@ -1828,7 +1828,6 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
|
|||||||
int nplans = list_length(node->plans);
|
int nplans = list_length(node->plans);
|
||||||
ResultRelInfo *saved_resultRelInfo;
|
ResultRelInfo *saved_resultRelInfo;
|
||||||
ResultRelInfo *resultRelInfo;
|
ResultRelInfo *resultRelInfo;
|
||||||
TupleDesc tupDesc;
|
|
||||||
Plan *subplan;
|
Plan *subplan;
|
||||||
ListCell *l;
|
ListCell *l;
|
||||||
int i;
|
int i;
|
||||||
@ -2068,12 +2067,11 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
|
|||||||
* Initialize result tuple slot and assign its rowtype using the first
|
* Initialize result tuple slot and assign its rowtype using the first
|
||||||
* RETURNING list. We assume the rest will look the same.
|
* RETURNING list. We assume the rest will look the same.
|
||||||
*/
|
*/
|
||||||
tupDesc = ExecTypeFromTL((List *) linitial(node->returningLists),
|
mtstate->ps.plan->targetlist = (List *) linitial(node->returningLists);
|
||||||
false);
|
|
||||||
|
|
||||||
/* Set up a slot for the output of the RETURNING projection(s) */
|
/* Set up a slot for the output of the RETURNING projection(s) */
|
||||||
ExecInitResultTupleSlot(estate, &mtstate->ps);
|
ExecInitResultTupleSlot(estate, &mtstate->ps);
|
||||||
ExecAssignResultType(&mtstate->ps, tupDesc);
|
ExecAssignResultTypeFromTL(&mtstate->ps);
|
||||||
slot = mtstate->ps.ps_ResultTupleSlot;
|
slot = mtstate->ps.ps_ResultTupleSlot;
|
||||||
|
|
||||||
/* Need an econtext too */
|
/* Need an econtext too */
|
||||||
@ -2126,9 +2124,9 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
|
|||||||
* We still must construct a dummy result tuple type, because InitPlan
|
* We still must construct a dummy result tuple type, because InitPlan
|
||||||
* expects one (maybe should change that?).
|
* expects one (maybe should change that?).
|
||||||
*/
|
*/
|
||||||
tupDesc = ExecTypeFromTL(NIL, false);
|
mtstate->ps.plan->targetlist = NIL;
|
||||||
ExecInitResultTupleSlot(estate, &mtstate->ps);
|
ExecInitResultTupleSlot(estate, &mtstate->ps);
|
||||||
ExecAssignResultType(&mtstate->ps, tupDesc);
|
ExecAssignResultTypeFromTL(&mtstate->ps);
|
||||||
|
|
||||||
mtstate->ps.ps_ExprContext = NULL;
|
mtstate->ps.ps_ExprContext = NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user