Re: Support EXCEPT for TABLES IN SCHEMA publications

From: vignesh C <vignesh21(at)gmail(dot)com>
To: Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>
Cc: shveta malik <shveta(dot)malik(at)gmail(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Support EXCEPT for TABLES IN SCHEMA publications
Date: 2026-08-07 11:56:49
Message-ID: CALDaNm2r8LURFmXd_MZePU3UqnY=Za6Tt1ig7jWOjofRBdDSJg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 4 Aug 2026 at 14:11, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com> wrote:
>
> Attached is the v25 patch set addressing all of the above, as well as
> Shlok's and Peter's comments in [1] and [2].

I noticed what appears to be an unexpected behavior with publications
involving inherited tables and wanted to check whether this is
intentional. The following steps reproduce the behavior:
CREATE SCHEMA s1;
CREATE SCHEMA s2;
CREATE TABLE s1.parent (a int);
CREATE TABLE s2.child (b int) INHERITS (s1.parent);

-- Create a publication excluding the parent table
CREATE PUBLICATION p FOR TABLES IN SCHEMA s1 EXCEPT (TABLE s1.parent);

The publication excludes both the parent and child tables:
postgres=# \dRp+
Publication p
Owner | All tables | All sequences | Inserts | Updates |
Deletes | Truncates | Generated columns | Via root | Description
----------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------+-------------
test | f | f | t | t | t
| t | none | f |
Tables from schemas:
"s1"
Except tables:
"s1.parent"
"s2.child"

Now remove the schema from the publication:
ALTER PUBLICATION p DROP TABLES IN SCHEMA s1;

After doing so, the publication still retains the child table in the
exclusion list:
postgres=# \dRp+
Publication p
Owner | All tables | All sequences | Inserts | Updates |
Deletes | Truncates | Generated columns | Via root | Description
----------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------+-------------
test | f | f | t | t | t
| t | none | f |
Except tables:
"s2.child"

My question is whether it is intentional to retain the automatically
added exclusion for s2.child after dropping all tables from schema s1
from the publication. This also appears to have implications for
pg_dump. Since the publication no longer contains any schema entries,
pg_dump generates:
CREATE PUBLICATION p WITH (publish = 'insert, update, delete, truncate');

The dumped definition does not include the retained EXCEPT (TABLE
s2.child) state, so restoring the dump would not recreate the original
publication.
Thoughts?

Regards,
Vignesh

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2026-08-07 12:31:47 Re: Redesign per-backend statistics
Previous Message Ashutosh Sharma 2026-08-07 11:31:22 Re: [PATCH] Release replication slot on error in SQL-callable slot functions