Incorrect messages emitted from pgoutput when using column lists

From: Gunnar Morling <gunnar(dot)morling(at)googlemail(dot)com>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Incorrect messages emitted from pgoutput when using column lists
Date: 2022-11-24 17:13:59
Message-ID: CADGJaX9kiRZ-OH0EpWF5Fkyh1ZZYofoNRCrhapBfdk02tj5EKg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

I'd like to test the column list feature for logical replication added
in Postgres 15 [1], and it seems I am getting unexpected events for
UPDATEs. Here are steps for reproducing:

CREATE TABLE test (
id SERIAL NOT NULL PRIMARY KEY,
a VARCHAR(255) NOT NULL,
b VARCHAR(255) NOT NULL
);

CREATE PUBLICATION test_publication FOR TABLE test (id, a);
CREATE UNIQUE INDEX test_publication_idx ON test (id, a);
ALTER TABLE test REPLICA IDENTITY USING INDEX test_publication_idx;

SELECT * FROM pg_create_logical_replication_slot('test_slot', 'pgoutput');

INSERT INTO test values (default, 'aaa', 'bbb');
UPDATE test set b='bbbbbb' where id = 1;
UPDATE test set a='aaaaaa' where id = 1;

Then consume the events using any client, for instance Debezium, or a
bespoke consumer application. What I observed is this:

- The 'R' event sent for the table looks as expected, i.e. without the
"b" column
- The event sent for the INSERT looks as expected
- The event for the first UPDATE (column not part of the column list)
looks as expected
- The event for the second UPDATE (column is part of the column list)
looks wrong; specifically, its TupleData part: it has a column count
of 3 (rather than 2), with the 'n' byte identifying the value of the
third column (b) as a null value

I would expect that I always get events which reflect the structure of
the previously sent `R` event. If that's not the case, I'm not sure
how I would interpret the subsequent events. So I suppose this is a
bug?

Thanks for any advice and help,

--Gunnar

[1] http://amitkapila16.blogspot.com/2022/11/logical-replication-improvements-in.html

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2022-11-24 17:16:35 Re: BUG #17694: In JSONPath expressions, characters between leading $ and dot appear to be ignored
Previous Message Roman Garcia 2022-11-24 17:12:28 Re: BUG #17696: Creation of deferrable initially deferred constraint breaks before transaction commit