Re: Skipping schema changes in publication
vignesh C <vignesh21@gmail.com>
From: vignesh C <vignesh21@gmail.com>
To: Shlok Kyal <shlok.kyal.oss@gmail.com>
Cc: shveta malik <shveta.malik@gmail.com>,
Dilip Kumar <dilipbalaut@gmail.com>, Amit Kapila <amit.kapila16@gmail.com>, Peter Smith <smithpb2250@gmail.com>, "Zhijie Hou (Fujitsu)" <houzj.fnst@fujitsu.com>, YeXiu <1518981153@qq.com>, Ian Lawrence Barwick <barwick@gmail.com>, Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-02-03T16:52:52Z
Lists: pgsql-hackers
Attachments
- v39-0001-Skip-publishing-the-tables-specified-in-EXCEPT-T.patch (application/x-patch) patch v39-0001
- v39-0002-handle-EXCEPT-TABLE-correctly-with-partitioned-t.patch (application/x-patch) patch v39-0002
On Mon, 2 Feb 2026 at 17:18, Shlok Kyal <shlok.kyal.oss@gmail.com> wrote:
>
> I reviewed v38-0002-handle-EXCEPT-TABLE-correctly-with-partitioned-approach-1.patch
> patch. Here are my comments:
>
> 4. While testing, I noticed that the new query introduced in tablesync
> can be invoked for "FOR TABLE". SHould we only call it for "ALL
> TABLES" publications?
> + if (server_version >= 190000 && !is_partition &&
> + lrel->relkind == RELKIND_PARTITIONED_TABLE)
> + {
> + resetStringInfo(&cmd);
> +
> + /*
> + * This query recursively traverses the inheritance (partition) tree
> + * starting from the given table OID and determines which leaf
> + * relations should be included for replication. Exclusion propagates
> + * from parent to child, and a relation is also treated as excluded if
> + * it is explicitly marked with prexcept = true in pg_publication_rel
> + * for the specified publications. The final result returns only
> + * non excluded leaf relations.
> + */
> Test:
> Create publication for table sc1.t1 using (publish_via_partition_root
> = true) and create subscription on it. In subscriber logs we can see
> the logs for the new query.
> sc1.t1 has the same structure as in comment 1.
We will not know if it is a table publication or all tables
publication from here. Also there can be a possibility of multiple
publications. We will invoke it and handle it from the publisher to
return appropriate tables.
Thanks for the review and detailed comments. All remaining feedback
has been addressed in the attached v39 patch.
In addition, the SQL query previously used to compute the set of
effective tables has been replaced with a C implementation. The SQL
approach had become increasingly complex and difficult to reason
about, especially as more publication combinations were added.
Implementing this logic in C significantly improves readability and
maintainability, and makes it easier to handle complex scenarios, such
as:
a) Multiple publications where one publication has no EXCEPT tables
and another does.
b) Multiple publications where one publication is an ALL TABLES
publication with EXCEPT, while another is a table-specific
publication.
c) Multiple publications where none of the publications define any
EXCEPT tables.
Peter's comments from [1] and Shveta's comments form [2] will be
addressed in the next version.
[1] - https://www.postgresql.org/message-id/CAHut%2BPsiWwmNSuCXTWM0iPDm3yGskLts-fukELTB__rbBids-A%40mail.gmail.com
[2] - https://www.postgresql.org/message-id/CAJpy0uAOvtMBP-oV9Tgoznt5-UsE2dzAjZW3eJmgKcU-X-vEzg%40mail.gmail.com
Regards,
Vignesh
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix miscellaneous issues in EXCEPT publication clause.
- 6b0550c45d13 19 (unreleased) landed
-
Change syntax of EXCEPT TABLE clause in publication commands.
- 5984ea868eee 19 (unreleased) landed
-
Add support for EXCEPT TABLE in ALTER PUBLICATION.
- 493f8c6439cf 19 (unreleased) landed
-
Allow table exclusions in publications via EXCEPT TABLE.
- fd366065e06a 19 (unreleased) landed
-
Add wait_for_subscription_sync for TAP tests.
- 0c20dd33db16 16.0 cited