diff options
author | Tomas Vondra | 2021-08-12 19:32:53 +0000 |
---|---|---|
committer | Tomas Vondra | 2021-08-12 20:10:06 +0000 |
commit | 650663b4cb4714a34d7171981de4392486a85f86 (patch) | |
tree | 29c47029a6ea80442541f29a86a5b5c11bcfbe70 /src/backend/executor/nodeModifyTable.c | |
parent | ba958299eaf3d2f55bddb8efb037091d14ca6fd0 (diff) |
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
Diffstat (limited to 'src/backend/executor/nodeModifyTable.c')
-rw-r--r-- | src/backend/executor/nodeModifyTable.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c index c24684aa6fe..d328856ae5b 100644 --- a/src/backend/executor/nodeModifyTable.c +++ b/src/backend/executor/nodeModifyTable.c @@ -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++; |