diff options
| author | Amit Kapila | 2026-06-08 06:49:29 +0000 |
|---|---|---|
| committer | Amit Kapila | 2026-06-08 06:49:29 +0000 |
| commit | 6ce035ffff444479e63ea6276d56e33cc8b991d9 (patch) | |
| tree | 7b817946b6dd9c8af40aaa4cc6fe3c6a777a523b /src/bin | |
| parent | b20c952ce70370b22ea7a206d7b674a322397d28 (diff) | |
pg_createsubscriber: Fix duplicate publication name rejection.
pg_createsubscriber rejected duplicate --publication values while parsing
command-line options, even when the duplicate names referred to
publications in different databases. Since publication names are
database-local objects, the same name is perfectly valid across multiple
databases.
This restriction was not a practical problem before commit 85ddcc2f4c,
which added support for reusing pre-existing publications. After that
change, users who have identically-named publications in multiple
databases (a common convention) could not use the feature without renaming
their publications.
The analogous restriction on --subscription names is intentionally kept as
they are reused as replication slot names, which are cluster-global, so
allowing duplicate subscription names without additional guards could
cause a slot-name collision. That work is left for a future release.
Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Shlok Kyal <shlok.kyal.oss@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Discussion: https://postgr.es/m/B08A7C89-B3DE-4C1D-A671-32AD8BAB7E22@gmail.com
Diffstat (limited to 'src/bin')
| -rw-r--r-- | src/bin/pg_basebackup/pg_createsubscriber.c | 9 | ||||
| -rw-r--r-- | src/bin/pg_basebackup/t/040_pg_createsubscriber.pl | 19 |
2 files changed, 6 insertions, 22 deletions
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index cb16a608002..4d705778454 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -2381,13 +2381,8 @@ main(int argc, char **argv) opt.config_file = pg_strdup(optarg); break; case 2: - if (!simple_string_list_member(&opt.pub_names, optarg)) - { - simple_string_list_append(&opt.pub_names, optarg); - num_pubs++; - } - else - pg_fatal("publication \"%s\" specified more than once for --publication", optarg); + simple_string_list_append(&opt.pub_names, optarg); + num_pubs++; break; case 3: if (!simple_string_list_member(&opt.replslot_names, optarg)) diff --git a/src/bin/pg_basebackup/t/040_pg_createsubscriber.pl b/src/bin/pg_basebackup/t/040_pg_createsubscriber.pl index 858082c70df..9252d1c3c5c 100644 --- a/src/bin/pg_basebackup/t/040_pg_createsubscriber.pl +++ b/src/bin/pg_basebackup/t/040_pg_createsubscriber.pl @@ -74,18 +74,6 @@ command_fails( '--pgdata' => $datadir, '--publisher-server' => 'port=5432', '--publication' => 'foo1', - '--publication' => 'foo1', - '--database' => 'pg1', - '--database' => 'pg2', - ], - 'duplicate publication name'); -command_fails( - [ - 'pg_createsubscriber', - '--verbose', - '--pgdata' => $datadir, - '--publisher-server' => 'port=5432', - '--publication' => 'foo1', '--database' => 'pg1', '--database' => 'pg2', ], @@ -346,7 +334,8 @@ is($node_s->safe_psql($db1, "SELECT COUNT(*) FROM pg_publication"), $node_s->stop; -# dry run mode on node S +# dry run mode on node S. Use the same publication name for different +# databases, since publication names are database-local. command_ok( [ 'pg_createsubscriber', @@ -357,8 +346,8 @@ command_ok( '--publisher-server' => $node_p->connstr($db1), '--socketdir' => $node_s->host, '--subscriber-port' => $node_s->port, - '--publication' => 'pub1', - '--publication' => 'pub2', + '--publication' => 'same_pub', + '--publication' => 'same_pub', '--subscription' => 'sub1', '--subscription' => 'sub2', '--database' => $db1, |
