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: 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-06-16 10:44:09
Message-ID: CABdArM4peXa8W9AYw6OHWmBuP4kkN3e01TcrUq_arWQLacoiNw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jun 16, 2026 at 1:53 PM Peter Smith <smithpb2250(at)gmail(dot)com> wrote:
>
> Some review comments for v13-0001.
>
> ======
> doc/src/sgml/ref/create_publication.sgml
>
> 1.
> <para>
> Marks the publication as one that replicates changes for all tables in
> the specified list of schemas, including tables created in the future.
> + Tables listed in the <literal>EXCEPT</literal> clause for a given schema
> + are excluded from the publication.
> </para>
>
> Given Amit's suggestion [1] to modify the EXCEPT text for FOR ALL
> TABLES, perhaps there also needs to be an equivalent note for ALL
> TABLES IN SCHEMA. Maybe wait to see what happens [1], then you can use
> similar wording.
>

Okay, noted. Let's first wait for the conclusion on this.

> ======
> src/backend/commands/publicationcmds.c
>
> RemovePublicationExceptForRelation:
>
> 2.
> +/*
> + * Remove any EXCEPT clause entries for a relation from schema publications.
> + * Called when a table changes schema (ALTER TABLE ... SET SCHEMA), so that
> + * a schema-scoped exclusion does not silently follow the table to its new
> + * schema.
> + */
> +void
> +RemovePublicationExceptForRelation(Oid relid, Oid oldNspOid, Oid newNspOid)
> +{
>
> There's nothing about that function name to indicate it is only for
> SCHEMA publications.
> There must be a better -- e.g. 'MaybeRemoveExclusionFromSchemaPub', or
> whatever...
>

I've renamed it to RemoveSchemaPubExceptForRel to keep it consistent
with the neighboring function names. Let me know if it works.

> ~~~
>
> 3.
> + ereport(DEBUG2,
> + errmsg_internal("auto-drop exclusion of table %s from publication
> %s: table moved to schema %s",
> + quote_qualified_identifier(get_namespace_name(oldNspOid),
> + get_rel_name(relid)),
> + get_publication_name(pubid, false),
> + quote_identifier(get_namespace_name(newNspOid))));
>
> Even though this is a debugging message, for consistency, we might as
> well quote everything the same as normal messages do:
>
> "auto-drop exclusion of table \"%s\" from publication \"%s\": table
> moved to schema \"%s\""
>

Fixed.
~~~

Also added a test as per Zsolt's suggestion at [1].
I moved all documentation changes into a separate 0004 patch to make
doc review easier.

Please find the attached v14 patches.

[1] https://www.postgresql.org/message-id/CAN4CZFPZnckA9-MPt6xj1QsRQTVKs3ZoKgdZ%2BQG1xa%3D%3DUD46Xw%40mail.gmail.com

--
Thanks,
Nisha

Attachment Content-Type Size
v14-0001-Support-EXCEPT-clause-for-schema-level-publicati.patch application/octet-stream 60.4 KB
v14-0002-Add-EXCEPT-support-to-ALTER-PUBLICATION-ADD-TABL.patch application/octet-stream 18.6 KB
v14-0003-Add-EXCEPT-support-to-ALTER-PUBLICATION-SET-TABL.patch application/octet-stream 23.2 KB
v14-0004-Documentation-Patch.patch application/octet-stream 10.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ewan Young 2026-06-16 10:51:48 Re: 004_timeline_switch TAP test may fail
Previous Message Ashutosh Sharma 2026-06-16 10:42:43 Re: synchronized_standby_slots behavior inconsistent with quorum-based synchronous replication