mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
logical decoding: old/newtuple in spooled UPDATE changes was switched around.
Somehow I managed to flip the order of restoring old & new tuples when de-spooling a change in a large transaction from disk. This happens to only take effect when a change is spooled to disk which has old/new versions of the tuple. That only is the case for UPDATEs where he primary key changed or where replica identity is changed to FULL. The tests didn't catch this because either spooled updates, or updates that changed primary keys, were tested; not both at the same time. Found while adding tests for the following commit. Backpatch: 9.4, where logical decoding was added
This commit is contained in:
@ -2335,18 +2335,6 @@ ReorderBufferRestoreChange(ReorderBuffer *rb, ReorderBufferTXN *txn,
|
||||
case REORDER_BUFFER_CHANGE_UPDATE:
|
||||
case REORDER_BUFFER_CHANGE_DELETE:
|
||||
case REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT:
|
||||
if (change->data.tp.newtuple)
|
||||
{
|
||||
Size len = offsetof(ReorderBufferTupleBuf, t_data) +
|
||||
((ReorderBufferTupleBuf *) data)->tuple.t_len;
|
||||
|
||||
change->data.tp.newtuple = ReorderBufferGetTupleBuf(rb);
|
||||
memcpy(change->data.tp.newtuple, data, len);
|
||||
change->data.tp.newtuple->tuple.t_data =
|
||||
&change->data.tp.newtuple->t_data.header;
|
||||
data += len;
|
||||
}
|
||||
|
||||
if (change->data.tp.oldtuple)
|
||||
{
|
||||
Size len = offsetof(ReorderBufferTupleBuf, t_data) +
|
||||
@ -2358,6 +2346,18 @@ ReorderBufferRestoreChange(ReorderBuffer *rb, ReorderBufferTXN *txn,
|
||||
&change->data.tp.oldtuple->t_data.header;
|
||||
data += len;
|
||||
}
|
||||
|
||||
if (change->data.tp.newtuple)
|
||||
{
|
||||
Size len = offsetof(ReorderBufferTupleBuf, t_data) +
|
||||
((ReorderBufferTupleBuf *) data)->tuple.t_len;
|
||||
|
||||
change->data.tp.newtuple = ReorderBufferGetTupleBuf(rb);
|
||||
memcpy(change->data.tp.newtuple, data, len);
|
||||
change->data.tp.newtuple->tuple.t_data =
|
||||
&change->data.tp.newtuple->t_data.header;
|
||||
data += len;
|
||||
}
|
||||
break;
|
||||
case REORDER_BUFFER_CHANGE_INTERNAL_SNAPSHOT:
|
||||
{
|
||||
|
Reference in New Issue
Block a user