Re: Support EXCEPT for TABLES IN SCHEMA publications

From: shveta malik <shveta(dot)malik(at)gmail(dot)com>
To: Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>
Cc: 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, shveta malik <shveta(dot)malik(at)gmail(dot)com>
Subject: Re: Support EXCEPT for TABLES IN SCHEMA publications
Date: 2026-07-01 10:24:19
Message-ID: CAJpy0uBWqmkfqM1_fADsP3reZTjqy0J_k0-M5EQ2DAaWdDGM=w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jul 1, 2026 at 3:42 PM Nisha Moond <nisha(dot)moond412(at)gmail(dot)com> wrote:
>
> During tests, I found one behavior that needs discussion:
>
> Consider a partition hierarchy where the root table is in schema s2, a
> child partition is in schema s1, and the publication includes both
> schemas but excludes only the root table.

This is the exact scenario I had in mind when reviewing
'get_rel_sync_entry-->GetTopMostAncestorInPublication' flow, thus I
suggested adding comments about intentionally fetching the 'Exclude
list' only for the Root. I was about to test it in my next review
cycle.

The first thought is that if root is excluded, the partition should
also be excluded to maintain consistency with the 'ALL TABLES Except
ROOT' behaviour. But then it needs to be documented too. This is my
initial understanding, but I will think more when I resume the review.

> Test case:
> -- Root of the partition tree lives in s2
> CREATE TABLE s2.parent (id int) PARTITION BY LIST (id);
>
> -- Child partition lives in s1
> CREATE TABLE s1.part PARTITION OF s2.parent FOR VALUES IN (1, 2, 3);
>
> -- Publication covers BOTH schemas, but EXCEPTs only s2.parent
> CREATE PUBLICATION p FOR TABLES IN SCHEMA s1, TABLES IN SCHEMA s2
> EXCEPT (TABLE s2.parent);
>
> Currently, if the root is excluded, all child partitions are also
> excluded, meaning s1.part is not published. However, s1 never excluded
> 'part' explicitly, so the behavior may not be intuitive.
>
> We need to decide whether child partitions should always remain
> excluded when the root is excluded (regardless of schema), or whether
> schema membership should still allow publication.
>
> I've added an XXX comment in pg_publication.c to track this until we
> conclude on the expected behavior. Suggestions are welcome.
>
> --
> Thanks,
> Nisha

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nazir Bilal Yavuz 2026-07-01 10:25:00 Re: meson vs. llvm bitcode files
Previous Message shveta malik 2026-07-01 10:16:43 Re: Support EXCEPT for TABLES IN SCHEMA publications