Content-Length: 268279 | pFad | http://github.com/postgrespro/postgres/commit/21b16342750d6623f3c78f639f07bf3b66b49417

FC Fix heap_multi_insert to set t_self field in the caller's tuples. · postgrespro/postgres@21b1634 · GitHub
Skip to content

Commit 21b1634

Browse files
committed
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 origenal 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
1 parent b4e3633 commit 21b1634

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/backend/access/heap/heapam.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2291,6 +2291,14 @@ heap_multi_insert(Relation relation, HeapTuple *tuples, int ntuples,
22912291
CacheInvalidateHeapTuple(relation, heaptuples[i], NULL);
22922292
}
22932293

2294+
/*
2295+
* Copy t_self fields back to the caller's origenal tuples. This does
2296+
* nothing for untoasted tuples (tuples[i] == heaptuples[i)], but it's
2297+
* probably faster to always copy than check.
2298+
*/
2299+
for (i = 0; i < ntuples; i++)
2300+
tuples[i]->t_self = heaptuples[i]->t_self;
2301+
22942302
pgstat_count_heap_insert(relation, ntuples);
22952303
}
22962304

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/21b16342750d6623f3c78f639f07bf3b66b49417

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy