Re: Support EXCEPT for TABLES IN SCHEMA publications

From: Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>
To: Peter Smith <smithpb2250(at)gmail(dot)com>
Cc: shveta malik <shveta(dot)malik(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Support EXCEPT for TABLES IN SCHEMA publications
Date: 2026-06-02 08:57:24
Message-ID: CABdArM76MZ4dYC87zCv67fVY9t5aFLd2nD5tNBxFFizESyBOSg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jun 1, 2026 at 12:59 PM Peter Smith <smithpb2250(at)gmail(dot)com> wrote:
>
> Hi Nisha.
>
> Some review comments for patch v8-0004.
>

Thanks for the review.

> ======
> src/backend/commands/publicationcmds.c
>
> AlterPublicationSchemaExceptTables:
>
> 1.
> + /* Collect OIDs of the desired new EXCEPT list. */
> + foreach_ptr(PublicationRelInfo, pri, rels)
> + {
> + newexceptrelids = lappend_oid(newexceptrelids,
> + RelationGetRelid(pri->relation));
> + }
>
> Block braces {} not needed.
>

Fixed.

> ~~~
>
> 2.
> + if (!OidIsValid(proid))
> + continue; /* already gone */
> +
> + ObjectAddressSet(obj, PublicationRelRelationId, proid);
> + performDeletion(&obj, DROP_CASCADE, 0);
>
> SUGGESTION
> if (OidIsValid(proid))
> {
> ObjectAddressSet(obj, PublicationRelRelationId, proid);
> performDeletion(&obj, DROP_CASCADE, 0);
> }
>

Fixed. A similar pattern was also used in PublicationDropSchemas(),
and I have fixed that as well.

> ======
> src/test/subscription/t/037_except.pl
>
> 3.
> I think you had used the SQL exactly as I previously suggested, but I
> made a mistake:
> It should say "SELECT count(*)" instead of "SELECT a".
>
> So it returns either 0 or 1 row.
>
> e.g. #1
> $result =
> $node_subscriber->safe_psql('postgres',
> "SELECT count(*) FROM sch1.tab_excluded WHERE a = 7");
> is($result, qq(1),
> 'ALTER ... SET TABLES IN SCHEMA EXCEPT: newly included table is replicated'
> );
> $result =
> $node_subscriber->safe_psql('postgres',
> "SELECT count(*) FROM sch1.tab_published WHERE a = 7");
> is($result, qq(0),
> 'ALTER ... SET TABLES IN SCHEMA EXCEPT: now-excluded table is not
> replicated'
> );
>
> e.g. #2
> $result =
> $node_subscriber->safe_psql('postgres',
> "SELECT count(*) FROM sch1.tab_published WHERE a = 8");
> is($result, qq(1),
> 'ALTER ... SET TABLES IN SCHEMA (no EXCEPT): tab_published
> replicated after except list cleared'
> );
> $result =
> $node_subscriber->safe_psql('postgres',
> "SELECT count(*) FROM sch1.tab_excluded WHERE a = 8");
> is($result, qq(1),
> 'ALTER ... SET TABLES IN SCHEMA (no EXCEPT): tab_excluded
> replicated after except list cleared'
> );
>

Thanks for pointing that out; I overlooked your earlier suggestion.
I've now updated as suggested.

Attached is the updated v9 patch set.

--
Thanks,
Nisha

Attachment Content-Type Size
v9-0001-Support-EXCEPT-clause-for-schema-level-publicatio.patch application/octet-stream 46.8 KB
v9-0002-Add-EXCEPT-support-to-ALTER-PUBLICATION-ADD-TABLE.patch application/octet-stream 22.3 KB
v9-0003-Add-EXCEPT-support-to-ALTER-PUBLICATION-SET-TABLE.patch application/octet-stream 25.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-06-02 09:17:18 Re: pg_createsubscriber: allow duplicate publication names
Previous Message Amit Kapila 2026-06-02 08:57:13 Re: pg_createsubscriber: allow duplicate publication names