Re: pg_createsubscriber: allow duplicate publication names - Mailing list pgsql-hackers

From Shlok Kyal
Subject Re: pg_createsubscriber: allow duplicate publication names
Date
Msg-id CANhcyEXUhVBjAJN4U=6qisLejMRfzbJXAiSW8JK3EMVHoTOV+w@mail.gmail.com
Whole thread
In response to pg_createsubscriber: allow duplicate publication names  (Chao Li <li.evan.chao@gmail.com>)
List pgsql-hackers
On Mon, 1 Jun 2026 at 18:43, Chao Li <li.evan.chao@gmail.com> wrote:
>
> Hi,
>
> While testing “Support existing publications in pg_createsubscriber”, I noticed that it doesn’t allow the same
publicationname even when the publications are from different databases. 
>
> A simple repro:
> ```
> % createdb db1
> % createdb db2
> % psql db1 -c 'CREATE PUBLICATION app_pub FOR ALL TABLES'
> % psql db2 -c 'CREATE PUBLICATION app_pub FOR ALL TABLES'
> CREATE PUBLICATION
> CREATE PUBLICATION
> % pg_createsubscriber --dry-run --pgdata <data-dir> --publisher-server postgres --database db1 --database db2
--publicationapp_pub --publication app_pub 
> pg_createsubscriber: error: publication "app_pub" specified more than once for --publication
> ```
>
> The rejection is not introduced by this feature, but previously it was not a real problem because the specified
publicationnames would always be created. After this feature, it may become an issue, since the feature intends to use
existingpublications, and users may have defined publications with the same name in different databases. So the current
restrictionbecomes a limitation of the new feature. I don’t think we should leave this limitation in PG19. 
>
> Since pg_createsubscriber already ensures that duplicate database names cannot be specified, we can just remove the
duplicatepublication name check. 
>
> See the attached patch for details.
>

Hi Chao-san,

I was able to reproduce the scenario and agree with your analysis.

Each --database option is associated with a corresponding
--publication option, and duplicate database names are not allowed.
And also, since publications are database-local objects, there is no
need to reject duplicate publication names.

The proposed changes look good to me.

Thanks,
Shlok Kyal



pgsql-hackers by date:

Previous
From: Álvaro Herrera
Date:
Subject: Re: pgsql: Advance restart_lsn more eagerly in LogicalConfirmReceivedLocati
Next
From: Diego Frias
Date:
Subject: [PATCH] Fix recognizing 0x11A7 as a Hangul T syllable in Unicode normalization