summaryrefslogtreecommitdiff
path: root/src/backend/access/heap/heapam.c
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2012-02-13 10:14:49 +0200
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2012-02-13 10:20:50 +0200
commit21b16342750d6623f3c78f639f07bf3b66b49417 (patch)
tree7f7dc4b7647ea1ad7e2c2ab3be9cac38b7aa1689 /src/backend/access/heap/heapam.c
parentb4e3633ac42ed7af21bce611234ccbf820098644 (diff)
Fix heap_multi_insert to set t_self field in the caller's tuples.
If tuples were toasted, heap_multi_insert didn't update the ctid on the original tuples. This caused a failure if there was an after trigger (including a foreign key), on the table, and a tuple got toasted. Per off-list report and test case from Ted Phelps
Diffstat (limited to 'src/backend/access/heap/heapam.c')
-rw-r--r--src/backend/access/heap/heapam.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index 99a431a95ff..c910863e273 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -2291,6 +2291,14 @@ heap_multi_insert(Relation relation, HeapTuple *tuples, int ntuples,
CacheInvalidateHeapTuple(relation, heaptuples[i], NULL);
}
+ /*
+ * Copy t_self fields back to the caller's original tuples. This does
+ * nothing for untoasted tuples (tuples[i] == heaptuples[i)], but it's
+ * probably faster to always copy than check.
+ */
+ for (i = 0; i < ntuples; i++)
+ tuples[i]->t_self = heaptuples[i]->t_self;
+
pgstat_count_heap_insert(relation, ntuples);
}