mirror of
https://github.com/postgres/postgres.git
synced 2025-04-25 21:42:33 +03:00
Use appropriate tuple descriptor in FDW batching
The FDW batching code was using the same tuple descriptor both for all slots (regular and plan slots), but that's incorrect - the subplan may use a different descriptor. Currently this is benign, because batching is used only for INSERTs, and in that case the descriptors always match. But that would change if we allow batching UPDATEs. Fix by copying the appropriate tuple descriptor. Backpatch to 14, where the FDW batching was implemented. Author: Amit Langote Backpatch-through: 14, where FDW batching was added Discussion: https://postgr.es/m/CA%2BHiwqEWd5B0-e-RvixGGUrNvGkjH2s4m95%3DJcwUnyV%3Df0rAKQ%40mail.gmail.com
This commit is contained in:
parent
ba958299ea
commit
650663b4cb
@ -709,17 +709,19 @@ ExecInsert(ModifyTableState *mtstate,
|
||||
* keep them across batches. To mitigate an inefficiency in how
|
||||
* resource owner handles objects with many references (as with
|
||||
* many slots all referencing the same tuple descriptor) we copy
|
||||
* the tuple descriptor for each slot.
|
||||
* the appropriate tuple descriptor for each slot.
|
||||
*/
|
||||
if (resultRelInfo->ri_NumSlots >= resultRelInfo->ri_NumSlotsInitialized)
|
||||
{
|
||||
TupleDesc tdesc = CreateTupleDescCopy(slot->tts_tupleDescriptor);
|
||||
TupleDesc plan_tdesc =
|
||||
CreateTupleDescCopy(planSlot->tts_tupleDescriptor);
|
||||
|
||||
resultRelInfo->ri_Slots[resultRelInfo->ri_NumSlots] =
|
||||
MakeSingleTupleTableSlot(tdesc, slot->tts_ops);
|
||||
|
||||
resultRelInfo->ri_PlanSlots[resultRelInfo->ri_NumSlots] =
|
||||
MakeSingleTupleTableSlot(tdesc, planSlot->tts_ops);
|
||||
MakeSingleTupleTableSlot(plan_tdesc, planSlot->tts_ops);
|
||||
|
||||
/* remember how many batch slots we initialized */
|
||||
resultRelInfo->ri_NumSlotsInitialized++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user