]> granicus.if.org Git - postgresql/commit
Fix decoding of MULTI_INSERTs when rows other than the last are toasted.
authorAndres Freund <andres@anarazel.de>
Sun, 6 Jul 2014 13:58:01 +0000 (15:58 +0200)
committerAndres Freund <andres@anarazel.de>
Sun, 6 Jul 2014 13:59:53 +0000 (15:59 +0200)
commitd54712e7cf2e8925d1e04782a0aec88eae2be72c
treedc58a3ec43f8ba41216dd972f11be056dddc202d
parent49c279efe7858454114bd304444e95573be0804b
Fix decoding of MULTI_INSERTs when rows other than the last are toasted.

When decoding the results of a HEAP2_MULTI_INSERT (currently only
generated by COPY FROM) toast columns for all but the last tuple
weren't replaced by their actual contents before being handed to the
output plugin. The reassembled toast datums where disregarded after
every REORDER_BUFFER_CHANGE_(INSERT|UPDATE|DELETE) which is correct
for plain inserts, updates, deletes, but not multi inserts - there we
generate several REORDER_BUFFER_CHANGE_INSERTs for a single
xl_heap_multi_insert record.

To solve the problem add a clear_toast_afterwards boolean to
ReorderBufferChange's union member that's used by modifications. All
row changes but multi_inserts always set that to true, but
multi_insert sets it only for the last change generated.

Add a regression test covering decoding of multi_inserts - there was
none at all before.

Backpatch to 9.4 where logical decoding was introduced.

Bug found by Petr Jelinek.
contrib/test_decoding/expected/toast.out
contrib/test_decoding/sql/toast.sql
src/backend/replication/logical/decode.c
src/backend/replication/logical/reorderbuffer.c
src/include/replication/reorderbuffer.h