Re: Support EXCEPT for TABLES IN SCHEMA publications

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

On Thu, Jul 30, 2026 at 11:33 AM Nisha Moond <nisha(dot)moond412(at)gmail(dot)com> wrote:
>
> On Tue, Jul 28, 2026 at 2:38 PM shveta malik <shveta(dot)malik(at)gmail(dot)com> wrote:
> >
> > Nisha, the changes in RelationBuildPublicationDesc() looks quite
> > tricky now. We are doing 'list_difference_oid' thrice:
> >
> > --for schema-pub
> > --for schmea-pubs on complete ancestor tree
> > --for all-tables pub
> >
> > Ultimately we are concatenating all individual pubids after
> > subtracting 'exceptpuboids' from each individual 'puboids' list. The
> > 'exceptpuboids' is computed only once and doesn't change with each
> > computation. Why don't we uncondiitonally do list_concat_unique_oid
> > for all pub-ids
> > and only minus 'exceptpuboids' once at the end? Won't it work? Let me
> > know if I am missing something.
> >
>
> Done as suggested. The change modifies the existing code slightly, but
> the function now seems simpler and easier to read overall. It works
> well based on my testing. I'll do a deeper analysis to ensure it
> doesn't change any existing behavior.
>
> > ~~
> >
> > I think, we can now merge 002 to 001, it will help in combined review
> > by placing except-validation logic where it should ultimately be.
> >
>
> Merged both into v24-0001.
> ~~~
>
> Attached v24 patch set.
>

I missed mentioning that, besides the comments, also fixed a bug in describe.
The bug: with v23, describe (\d t) was incorrectly showing the table
as both included and excluded in same pub -
postgres=# CREATE PUBLICATION p FOR TABLES IN SCHEMA s EXCEPT (TABLE s.t);
CREATE PUBLICATION
postgres=# \d s.t;
Table "s.t"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | |
Included in publications:
"p"
Excluded from publications:
"p"

It is now fixed in v24.

--
Thanks,
Nisha

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrey Borodin 2026-07-30 06:19:16 Re: Fix archive restore race that could unlink WAL before rename
Previous Message Thomas Munro 2026-07-30 06:13:54 Re: pg_threads.h take II