mirror of
https://github.com/postgres/postgres.git
synced 2025-11-06 07:49:08 +03:00
Fix incorrect output from pgoutput when using column lists.
For Updates and Deletes, we were not honoring the columns list for old tuple values while sending tuple data via pgoutput. This results in pgoutput emitting more columns than expected. This is not a problem for built-in logical replication as we simply ignore additional columns based on the relation information sent previously which didn't have those columns. However, some other users of pgoutput plugin may expect the columns as per the column list. Also, sending extra columns unnecessarily consumes network bandwidth defeating the purpose of the column list feature. Reported-by: Gunnar Morling Author: Hou Zhijie Reviewed-by: Amit Kapila Backpatch-through: 15 Discussion: https://postgr.es/m/CADGJaX9kiRZ-OH0EpWF5Fkyh1ZZYofoNRCrhapBfdk02tj5EKg@mail.gmail.com
This commit is contained in:
@@ -478,7 +478,7 @@ logicalrep_write_update(StringInfo out, TransactionId xid, Relation rel,
|
||||
pq_sendbyte(out, 'O'); /* old tuple follows */
|
||||
else
|
||||
pq_sendbyte(out, 'K'); /* old key follows */
|
||||
logicalrep_write_tuple(out, rel, oldslot, binary, NULL);
|
||||
logicalrep_write_tuple(out, rel, oldslot, binary, columns);
|
||||
}
|
||||
|
||||
pq_sendbyte(out, 'N'); /* new tuple follows */
|
||||
@@ -531,7 +531,8 @@ logicalrep_read_update(StringInfo in, bool *has_oldtuple,
|
||||
*/
|
||||
void
|
||||
logicalrep_write_delete(StringInfo out, TransactionId xid, Relation rel,
|
||||
TupleTableSlot *oldslot, bool binary)
|
||||
TupleTableSlot *oldslot, bool binary,
|
||||
Bitmapset *columns)
|
||||
{
|
||||
Assert(rel->rd_rel->relreplident == REPLICA_IDENTITY_DEFAULT ||
|
||||
rel->rd_rel->relreplident == REPLICA_IDENTITY_FULL ||
|
||||
@@ -551,7 +552,7 @@ logicalrep_write_delete(StringInfo out, TransactionId xid, Relation rel,
|
||||
else
|
||||
pq_sendbyte(out, 'K'); /* old key follows */
|
||||
|
||||
logicalrep_write_tuple(out, rel, oldslot, binary, NULL);
|
||||
logicalrep_write_tuple(out, rel, oldslot, binary, columns);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1513,7 +1513,8 @@ pgoutput_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
|
||||
break;
|
||||
case REORDER_BUFFER_CHANGE_DELETE:
|
||||
logicalrep_write_delete(ctx->out, xid, targetrel,
|
||||
old_slot, data->binary);
|
||||
old_slot, data->binary,
|
||||
relentry->columns);
|
||||
break;
|
||||
default:
|
||||
Assert(false);
|
||||
@@ -1559,7 +1560,8 @@ pgoutput_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
|
||||
|
||||
OutputPluginPrepareWrite(ctx, true);
|
||||
logicalrep_write_delete(ctx->out, xid, targetrel,
|
||||
old_slot, data->binary);
|
||||
old_slot, data->binary,
|
||||
relentry->columns);
|
||||
OutputPluginWrite(ctx, true);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user