pgsql: Fix logical decoding to ignore updates without a new tuple.

From: Masahiko Sawada <msawada(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix logical decoding to ignore updates without a new tuple.
Date: 2026-09-11 17:55:13
Message-ID: E1x55Sy-00000004T2k-2xt4@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix logical decoding to ignore updates without a new tuple.

REPACK (CONCURRENTLY) suppresses logical decoding of the changes it
applies to the transient heap. For an update, suppression keeps the
tuple data out of the WAL record, but the record itself is still
written, and decoding turned it into a change carrying neither a new
nor an old tuple. An output plugin that asks for the changes made by
heap rewrites therefore outputs an UPDATE with no data at all,
reported under the name of the table being repacked.

Ignore such records, as decoding already does for inserts. Updates on
catalog relations don't carry the new tuple either, so we ignore them
too. For deletes, REPACK sets XLH_DELETE_NO_LOGICAL instead.

Backpatch to v19, where REPACK (CONCURRENTLY) was introduced.

Reported-by: Thom Brown <thom(at)linux(dot)com>
Reviewed-by: Zhijie Hou (Fujitsu) <houzj(dot)fnst(at)fujitsu(dot)com>
Reviewed-by: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Discussion: https://postgr.es/m/CAA-aLv7L_-dOuHXjLh0Di66dExdOb=uTOzR=jtrqCmV0Wxyd2Q@mail.gmail.com
Backpatch-through: 19

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3a3524e9acf4b22e7b3100a3710be3adffe89874

Modified Files
--------------
src/backend/replication/logical/decode.c | 9 ++++
.../injection_points/expected/repack_decode.out | 48 +++++++++++++++++++++-
.../injection_points/specs/repack_decode.spec | 25 +++++++++++
3 files changed, 81 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Masahiko Sawada 2026-09-11 17:55:19 pgsql: Fix logical decoding to ignore updates without a new tuple.
Previous Message Peter Eisentraut 2026-09-11 17:36:14 pgsql: pg_ctl: Silence warnings about unused global variables