From: Chao Li <li.evan.chao@gmail.com>
To: vignesh C <vignesh21@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Review items for EXCEPT TABLE publication
Date: Thu, 10 Sep 2026 15:53:45 +0800
Message-ID: <D700C437-EDF2-4442-90AD-E1D45F9E50AE@gmail.com> (raw)
In-Reply-To: <CALDaNm1r2MkGu6h8zgU1Kj1sX-FcMQ7wGTeLSnhx-5joiyXEvg@mail.gmail.com>
References: <CALDaNm1r2MkGu6h8zgU1Kj1sX-FcMQ7wGTeLSnhx-5joiyXEvg@mail.gmail.com>
> On Sep 10, 2026, at 13:39, vignesh C <vignesh21@gmail.com> wrote:
>
> Finding #5: SET UNLOGGED on an excluded table produces an unrestorable
> catalog state
>
> CREATE PUBLICATION ... FOR ALL TABLES EXCEPT (...) correctly rejects
> unlogged tables. However, ALTER TABLE ... SET UNLOGGED does not
> perform the same check. Its publication check uses
> GetRelationIncludedPublications(), which ignores pg_publication_rel
> rows marked as prexcept.
> As a result, the following currently succeeds:
> CREATE TABLE t (a int);
> CREATE PUBLICATION p FOR ALL TABLES EXCEPT (TABLE t);
> ALTER TABLE t SET UNLOGGED;
>
> This leaves an unlogged table in the publication's EXCEPT list, even
> though an unlogged table cannot be added to an EXCEPT clause directly.
> This causes failures when restoring a dump or running pg_upgrade.
> For example, pg_dump produces:
> CREATE PUBLICATION pub1 FOR ALL TABLES EXCEPT (TABLE ONLY public.t1)
> WITH (publish = 'insert, update, delete, truncate');
> where t1 is an unlogged table. Restoring the dump fails with:
> ERROR: cannot specify relation "public.t1" in the publication EXCEPT clause
> DETAIL: This operation is not supported for unlogged tables.
>
> A similar error is seen during pg_upgrade:
> ERROR: cannot specify relation "public.t1" in the publication EXCEPT clause
> DETAIL: This operation is not supported for unlogged tables.
>
> The fix is to reject changing a table to UNLOGGED when it is
> referenced in a publication's EXCEPT clause, similar to the existing
> check for tables included in a publication.
>
>
> Regards,
> Vignesh
> <v1-0001-Fix-ALTER-PUBLICATION-race-with-concurrent-SET-AL.patch><v1-0005-Prevent-unlogged-tables-in-publication-EXCEPT-cla.patch><v1-0003-Fix-missing-check-in-test_except_root_partition.patch><v1-0002-Fix-ALTER-PUBLICATION-validation-race.patch><v1-0004-Fix-test-to-use-a-fresh-subscription.patch>
For v1-0005, the code change itself looks good to me.
However, I have some concern about the design. Since a table in the EXCEPT list is not published anyway, do we really need to reject SET UNLOGGED? Would it make more sense to remove the table from the EXCEPT list and emit a NOTICE to inform the user?
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: li.evan.chao@gmail.com, vignesh21@gmail.com
Subject: Re: Review items for EXCEPT TABLE publication
In-Reply-To: <D700C437-EDF2-4442-90AD-E1D45F9E50AE@gmail.com>
References: <CALDaNm1r2MkGu6h8zgU1Kj1sX-FcMQ7wGTeLSnhx-5joiyXEvg@mail.gmail.com> <D700C437-EDF2-4442-90AD-E1D45F9E50AE@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox