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

From: shveta malik <shveta(dot)malik(at)gmail(dot)com>
To: Peter Smith <smithpb2250(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, shveta malik <shvetamalik(at)gmail(dot)com>
Subject: Re: BUG? Unpublished generated columns are reported "missing" by the subscription
Date: 2026-11-04 03:33:13
Message-ID: CAJpy0uDVTQvQ1h7375rOyMMJze+sJFMCYNm0Sv1Q_m=PQZaAMA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Nov 4, 2026 at 6:31 AM Peter Smith <smithpb2250(at)gmail(dot)com> wrote:
>
> (This was discovered while investigating a similar topic [1]).
>
> AFAIK generated columns should not normally be logically replicated:
> - VIRTUAL gencols, never
> - STORED gencols, according to the 'publish_generated_columns' parameter
>
> So, why does the subscription tablesync complain below that the column
> name "a" does not exist, given that it will not be replicated anyway?
>
> For example, at the publisher-side
>
> test_pub=# CREATE TABLE T_GENCOLS(a int generated always as (99) VIRTUAL);
> CREATE TABLE
> test_pub=# insert into t_gencols default values;
> INSERT 0 1
> test_pub=# insert into t_gencols default values;
> INSERT 0 1
> test_pub=# insert into t_gencols default values;
> INSERT 0 1
> test_pub=# select * from t_gencols;
> a
> ----
> 99
> 99
> 99
> (3 rows)
> test_pub=# CREATE PUBLICATION pub1 FOR TABLE t_gencols;
> CREATE PUBLICATION
>
> Then, on the subscriber-side
>
> test_sub=# create table t_gencols(local_col text default
> 'subscriber-gencol-default');
> CREATE TABLE
> test_sub=# create subscription sub1 connection 'dbname=test_pub'
> publication pub1;
> NOTICE: created replication slot "sub1" on publisher
> CREATE SUBSCRIPTION
> test_sub=#
> 2026-11-04 09:57:53.983 AEDT [345164] LOG: logical replication apply
> worker for subscription "sub1" has started
> 2026-11-04 09:57:53.995 AEDT [345166] LOG: logical replication table
> synchronization worker for subscription "sub1", table "t_gencols" has
> started
> 2026-11-04 09:57:54.059 AEDT [345166] ERROR: logical replication
> target relation "public.t_gencols" is missing replicated column: "a"
>
> ~~~
>
> OTOH, when the subscription is created with parameter copy_data=false
> then it works as expected for normal replication, therefore I suspect
> this may be a tablesync-only problem, probably in function
> fetch_remote_table_info() although I have not yet debugged/proved
> that.
>
> Thoughts?

+1, a genuine problem in tablesync, should be addressed. It appears
to be a corner case where the table has no publishable columns at all.
I verified that tablesync works correctly when the table also has
at-least one ordinary column (not generated one).

thanks
Shveta

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Paul A Jungwirth 2026-11-04 04:11:41 Re: Reject wholerow references where ColumnRef is forbidden
Previous Message shihao zhong 2026-11-04 03:32:25 Re: Fix ReadStream handling when heap rescan strategy changes