Re: BUG? Unpublished generated columns are reported "missing" by the subscription

From: Ajin Cherian <itsajin(at)gmail(dot)com>
To: Peter Smith <smithpb2250(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG? Unpublished generated columns are reported "missing" by the subscription
Date: 2026-11-04 10:05:55
Message-ID: CAFPTHDbdVxHuJGK=NMoCvYfr0WaBDR9n2GAXWSAMQija6_vGUQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Attached is an AI assisted patch to fix the issue Peter reported.

Since v18, tablesync no longer excludes generated columns in its
pg_attribute query, and instead relies on the column list from
pg_get_publication_tables() to skip unpublished columns. When none of
a table's columns are published, that function returns attrs = NULL,
which the subscriber reads as "no column list, so replicate all
columns". So the unpublished generated columns are replicated anyway.

0002 fixes this by also fetching "gpt.attrs IS NULL" from the
publisher and, for v18+ publishers, treating it as "no columns
published".

That leaves the table with zero replicated columns, so the fix depends
on the fix for the zero-column table bug being discussed in [1].
Without it, the subscriber's COPY treats the empty column list as "all
local columns": the initial sync then loads '' instead of the local
default in text mode, or fails with "row field count is 0" in binary
mode.

To make the tests pass, I've included the v1 patch from [1], unchanged, as 0001.

0002 adds tests to 011_generated.pl for a table whose only column is
VIRTUAL, and one whose only column is STORED with
publish_generated_columns = none, in both text and binary mode.

[1] https://www.postgresql.org/message-id/CAL5_ZS1bnYkK_GrA4N4SVKYgYsMMJxL9416m%3DvECAjrcwmQkkg%40mail.gmail.com

Regards,
Ajin Cherian
Fujitsu Australia

Attachment Content-Type Size
v1-0001-Fix-initial-sync-of-zero-column-published-tables.patch application/octet-stream 7.5 KB
v1-0002-Fix-tablesync-of-tables-with-no-published-columns.patch application/octet-stream 8.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2026-11-04 10:13:45 file_fdw: Fix ANALYZE crashes with DEFAULT markers
Previous Message Amit Kapila 2026-11-04 10:01:19 Re: Avoid resetting subscription two_phase state to pending when already enabled