pgsql: Support existing publications in pg_createsubscriber.

From: Amit Kapila <akapila(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Support existing publications in pg_createsubscriber.
Date: 2025-12-17 09:55:07
Message-ID: E1vVoFO-001EDf-0E@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Support existing publications in pg_createsubscriber.

Allow pg_createsubscriber to reuse existing publications instead of
failing when they already exist on the publisher.

Previously, pg_createsubscriber would fail if any specified publication
already existed. Now, existing publications are reused as-is with their
current configuration, and non-existing publications are created
automatically with FOR ALL TABLES.

This change provides flexibility when working with mixed scenarios of
existing and new publications. Users should verify that existing
publications have the desired configuration before reusing them, and can
use --dry-run with verbose mode to see which publications will be reused
and which will be created.

Only publications created by pg_createsubscriber are cleaned up during
error cleanup operations. Pre-existing publications are preserved unless
'--clean=publications' is explicitly specified, which drops all
publications.

This feature would be helpful for pub-sub configurations where users want
to subscribe to a subset of tables from the publisher.

Author: Shubham Khanna <khannashubham1197(at)gmail(dot)com>
Reviewed-by: Euler Taveira <euler(at)eulerto(dot)com>
Reviewed-by: Peter Smith <smithpb2250(at)gmail(dot)com>
Reviewed-by: Zhijie Hou (Fujitsu) <houzj(dot)fnst(at)fujitsu(dot)com
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Reviewed-by: vignesh C <vignesh21(at)gmail(dot)com>
Reviewed-by: tianbing <tian_bing_0531(at)163(dot)com>
Discussion: https://postgr.es/m/CAHv8Rj%2BsxWutv10WiDEAPZnygaCbuY2RqiLMj2aRMH-H3iZwyA%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/85ddcc2f4cdef490276d151c80459e287bceb782

Modified Files
--------------
doc/src/sgml/ref/pg_createsubscriber.sgml | 8 ++
src/bin/pg_basebackup/pg_createsubscriber.c | 95 +++++++++++++++++-----
src/bin/pg_basebackup/t/040_pg_createsubscriber.pl | 54 ++++++++++--
3 files changed, 132 insertions(+), 25 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tomas Vondra 2025-12-17 11:07:53 Re: failed NUMA pages inquiry status: Operation not permitted
Previous Message Michael Paquier 2025-12-17 02:46:48 pgsql: Change pgstat_report_vacuum() to use Relation