aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/analyze.c2
-rw-r--r--src/backend/commands/copy.c29
-rw-r--r--src/backend/commands/trigger.c4
3 files changed, 25 insertions, 10 deletions
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index da757f09747..8ac868ad733 100644
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -1452,7 +1452,7 @@ acquire_inherited_sample_rows(Relation onerel, int elevel,
{
HeapTuple newtup;
- newtup = do_convert_tuple(rows[numrows + j], map);
+ newtup = execute_attr_map_tuple(rows[numrows + j], map);
heap_freetuple(rows[numrows + j]);
rows[numrows + j] = newtup;
}
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index 2d5bc8add68..32706fad90f 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -31,6 +31,7 @@
#include "commands/trigger.h"
#include "executor/execPartition.h"
#include "executor/executor.h"
+#include "executor/tuptable.h"
#include "foreign/fdwapi.h"
#include "libpq/libpq.h"
#include "libpq/pqformat.h"
@@ -2691,6 +2692,7 @@ CopyFrom(CopyState cstate)
if (proute)
{
int leaf_part_index;
+ TupleConversionMap *map;
/*
* Away we go ... If we end up not finding a partition after all,
@@ -2862,14 +2864,27 @@ CopyFrom(CopyState cstate)
/*
* We might need to convert from the parent rowtype to the
- * partition rowtype. Don't free the already stored tuple as it
- * may still be required for a multi-insert batch.
+ * partition rowtype.
*/
- tuple = ConvertPartitionTupleSlot(proute->parent_child_tupconv_maps[leaf_part_index],
- tuple,
- proute->partition_tuple_slot,
- &slot,
- false);
+ map = proute->parent_child_tupconv_maps[leaf_part_index];
+ if (map != NULL)
+ {
+ TupleTableSlot *new_slot;
+ MemoryContext oldcontext;
+
+ Assert(proute->partition_tuple_slots != NULL &&
+ proute->partition_tuple_slots[leaf_part_index] != NULL);
+ new_slot = proute->partition_tuple_slots[leaf_part_index];
+ slot = execute_attr_map_slot(map->attrMap, slot, new_slot);
+
+ /*
+ * Get the tuple in the per-tuple context, so that it will be
+ * freed after each batch insert.
+ */
+ oldcontext = MemoryContextSwitchTo(GetPerTupleMemoryContext(estate));
+ tuple = ExecCopySlotTuple(slot);
+ MemoryContextSwitchTo(oldcontext);
+ }
tuple->t_tableOid = RelationGetRelid(resultRelInfo->ri_RelationDesc);
}
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index b2de1cc3915..136f9f06275 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -5786,7 +5786,7 @@ AfterTriggerSaveEvent(EState *estate, ResultRelInfo *relinfo,
if (map != NULL)
{
- HeapTuple converted = do_convert_tuple(oldtup, map);
+ HeapTuple converted = execute_attr_map_tuple(oldtup, map);
tuplestore_puttuple(old_tuplestore, converted);
pfree(converted);
@@ -5806,7 +5806,7 @@ AfterTriggerSaveEvent(EState *estate, ResultRelInfo *relinfo,
tuplestore_puttuple(new_tuplestore, original_insert_tuple);
else if (map != NULL)
{
- HeapTuple converted = do_convert_tuple(newtup, map);
+ HeapTuple converted = execute_attr_map_tuple(newtup, map);
tuplestore_puttuple(new_tuplestore, converted);
pfree(converted);