Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wrWv0-000OsJ-25 for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Aug 2026 08:24:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wrWuz-008N3J-27 for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Aug 2026 08:24:05 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wrWuz-008N1W-0d for pgsql-hackers@lists.postgresql.org; Wed, 05 Aug 2026 08:24:05 +0000 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wrW4Y-00000000ILZ-1h6N for pgsql-hackers@lists.postgresql.org; Wed, 05 Aug 2026 07:29:56 +0000 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-ca913a601fbso575328a12.3 for ; Wed, 05 Aug 2026 00:29:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785914994; x=1786519794; darn=lists.postgresql.org; h=to:cc:date:message-id:subject:mime-version:content-type:from:from :to:cc:subject:date:message-id:reply-to:content-type; bh=F/WTls4WLcD7iutRHFflTOoQMH8WcDLKLIZrc2X+b5c=; b=mv3d6Lf/OdfrHPwx2e1qB2yrK6+omwLbnBBDFyhPhf1nwZpewuT5fHY2QCXHq5gIvj +8YHil9TcVYayTLeDhhfjrU2jcIcsKWnrLe7kz9/MoNm4+u6YEPF/Z+W3ndmK7Qk5ftV gqhvh8aWU9FAgagZNP2TRfghk8ouxFN1i8KTTLTRMfZIEAh56q/idyNoSVrfB//3DQHX s7RcPvCerRdTwdtqmBBAyp0rQd1uIveOY+bnOkGKECwjqKWW8kZMLqtgmZbYJeZJf9Mf kQQfzpCEvwsepMTlxmbgPf/7IMNPSihPiAIHNlgaJ81tbawLOazSKFTlAMfBrLXYKTr+ /n9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785914994; x=1786519794; h=to:cc:date:message-id:subject:mime-version:content-type:from :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=F/WTls4WLcD7iutRHFflTOoQMH8WcDLKLIZrc2X+b5c=; b=f6e0Cz6FCP54Id7BJVKyoWkO/xybpPsZOWQ5nn5VmDTaNARlw/riE69qmTrDaqFAw9 Te0PfO9dnFe7nUiXlS9lvQwL8X+gmjC8L8ejg/0sRipq2K2jaK9YQsZ0p1CQW455lh8V gijog69BlE8dSzeAXKWyERVCf1xjRBHi+tmTY4OTrmzvPUqHp8reKVs5dHy/DlHnECuY Z/dZYchibRXFLKXUg3QAh+vXAIw/AOO+5Q4cdA7OQ8TE5ZZbAXKUp6nM97lmbqswwVGG TT2J6dKShQp72meo7Z9LLZgbWtW4dZ3Iel17cbHyYaGFDmLc0WPni3Iyzigu6OO1ztIe IBdA== X-Gm-Message-State: AOJu0YxON5GYQqTVKt2ZWogBaEZYyOMpo3JuE6vRhAhDkvnEb6blvTKI YfueDffNgnbSSLjUhaYpOilk9d4Cdrs6TZ9DX4PyIuU48QBtIEP7qUNaJNAdiQ== X-Gm-Gg: AR+sD138Kt0s/FIlBo5XFW95L7hbQS3ZRC/bYCKnZ9P14OJ8iptuGoMc1yTNqake4ND Sfbmasv2jSuI7123S1GlixMTrwZjbVSg9gM75LipOPY2ra9ZTfHYcuauOk7WvI9SEKSg8yN4yh3 x9bNWxFoLvGGUrWREO31Gl3lp46RAJTJucSYh2iJWsHf9XZEye+FV3t5/VBOEcPpjVHIL/tISPJ ximMZ1q1EjYdy2J6kVt0ZR6TkSAsLcqLs14NO7CXjNfTLYNUXiFjnT1Hp3rrO5Rq7HbXfKIgJgj MlRsTNiUcIOVPSRKWQ6NaOwjVsVZ8IOJzXRvIVJvDfHNnw43Dc+fO1JGQugUplrZ39zNyiT4968 Y24Rwtl1pYiLtH7zv/yE241yEhpas2GZjITDoaLNWVlM2aFJvW3x65Pyv3ESt8SrR0okho7BT1I swkbQ5Ss46xaXyO4Almz/SoJN/JVqfRD5u3xhmkGcC6mJoOBE+cIZDGwqYJhcoWPoJQP/CTITFP ls1TQlU X-Received: by 2002:a05:6300:6684:b0:3c3:b57b:627d with SMTP id adf61e73a8af0-3cb85df12b8mr5854458637.12.1785914993635; Wed, 05 Aug 2026 00:29:53 -0700 (PDT) Received: from smtpclient.apple ([185.135.79.125]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315863b0c54sm14410564eec.5.2026.08.05.00.29.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Aug 2026 00:29:52 -0700 (PDT) From: Chao Li Content-Type: multipart/mixed; boundary="Apple-Mail=_0C786DC6-6570-4837-BB21-BB2B4B05AD74" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: pg_createsubscriber: allow duplicate subscription names Message-Id: <2B037930-9B7F-41D3-98B3-E50FFD94C01A@gmail.com> Date: Wed, 5 Aug 2026 15:29:17 +0800 Cc: Amit Kapila , "Hayato Kuroda (Fujitsu)" To: PostgreSQL Hackers X-Mailer: Apple Mail (2.3864.600.51.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_0C786DC6-6570-4837-BB21-BB2B4B05AD74 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hi, This is follow-up work to patch [1], which fixed a bug in PG19 by = allowing pg_createsubscriber to accept duplicate publication names, = since publication names are unique per database. In the review thread, Amit suggested allowing duplicate subscription = names as well, because subscription names are also unique per database. = However, that required more work because when slot names are not = specified, subscription names are used as slot names, and slot names = must be unique per cluster. For that reason, the change was deferred to = v20. Here it is. The code changes are actually small. When slot names are = specified, we can allow duplicate subscription names. Doc and test = changes are included. See the attached patch for details. [1] = https://www.postgresql.org/message-id/B08A7C89-B3DE-4C1D-A671-32AD8BAB7E22= %40gmail.com Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/ --Apple-Mail=_0C786DC6-6570-4837-BB21-BB2B4B05AD74 Content-Disposition: attachment; filename=v1-0001-pg_createsubscriber-Allow-duplicate-subscription-.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="v1-0001-pg_createsubscriber-Allow-duplicate-subscription-.patch" Content-Transfer-Encoding: quoted-printable =46rom=20cf6c42de2558b86bcee54c0b629385b8141f3054=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20"Chao=20Li=20(Evan)"=20=0A= Date:=20Wed,=205=20Aug=202026=2015:11:13=20+0800=0ASubject:=20[PATCH=20= v1]=20pg_createsubscriber:=20Allow=20duplicate=20subscription=20names=0A=0A= Subscription=20names=20are=20database-local,=20so=20the=20same=20name=20= can=20be=20used=20in=0Adifferent=20databases.=20=20However,=20= pg_createsubscriber=20rejected=20duplicate=0A--subscription=20values=20= unconditionally.=0A=0AAllow=20duplicate=20subscription=20names=20when=20= distinct=20replication=20slot=20names=0Aare=20specified=20explicitly.=20=20= Continue=20to=20reject=20them=20when=0A--replication-slot=20is=20= omitted,=20because=20subscription=20names=20are=20then=20reused=0Aas=20= replication=20slot=20names,=20which=20must=20be=20unique=20within=20a=20= cluster.=0A=0AAdd=20tests=20and=20update=20the=20documentation.=0A=0A= Suggested-by:=20Amit=20Kapila=20=0AAuthor:=20= Chao=20Li=20=0AReviewed-by:=0ADiscussion:=20= https://postgr.es/m/=0A---=0A=20= doc/src/sgml/ref/pg_createsubscriber.sgml=20=20=20=20=20|=20=204=20+++-=0A= =20src/bin/pg_basebackup/pg_createsubscriber.c=20=20=20|=2019=20= +++++++++------=0A=20.../t/040_pg_createsubscriber.pl=20=20=20=20=20=20=20= =20=20=20=20=20=20=20|=2024=20+++++++++++++++----=0A=203=20files=20= changed,=2035=20insertions(+),=2012=20deletions(-)=0A=0Adiff=20--git=20= a/doc/src/sgml/ref/pg_createsubscriber.sgml=20= b/doc/src/sgml/ref/pg_createsubscriber.sgml=0Aindex=20= 193f60628bc..60d7c8e2a2d=20100644=0A---=20= a/doc/src/sgml/ref/pg_createsubscriber.sgml=0A+++=20= b/doc/src/sgml/ref/pg_createsubscriber.sgml=0A@@=20-362,7=20+362,9=20@@=20= PostgreSQL=20documentation=0A=20=20=20=20=20=20=20=20is=20reported.=20=20= The=20order=20of=20the=20multiple=20subscription=20name=20switches=20= must=0A=20=20=20=20=20=20=20=20match=20the=20order=20of=20database=20= switches.=20=20If=20this=20option=20is=20not=20specified,=0A=20=20=20=20=20= =20=20=20a=20generated=20name=20is=20assigned=20to=20the=20subscription=20= name.=20This=20option=20cannot=0A-=20=20=20=20=20=20=20be=20used=20= together=20with=20.=0A+=20=20=20=20=20=20=20be=20= used=20together=20with=20.=20=20The=20same=20= subscription=20name=0A+=20=20=20=20=20=20=20can=20be=20used=20in=20= different=20databases=20only=20when=20distinct=20replication=20slot=0A+=20= =20=20=20=20=20=20names=20are=20specified=20with=20= .=0A=20=20=20=20=20=20=20=0A=20= =20=20=20=20=20=0A=20=20=20=20=20=0Adiff=20= --git=20a/src/bin/pg_basebackup/pg_createsubscriber.c=20= b/src/bin/pg_basebackup/pg_createsubscriber.c=0Aindex=20= 20b354aed56..dcf8422dd92=20100644=0A---=20= a/src/bin/pg_basebackup/pg_createsubscriber.c=0A+++=20= b/src/bin/pg_basebackup/pg_createsubscriber.c=0A@@=20-2262,6=20+2262,7=20= @@=20main(int=20argc,=20char=20**argv)=0A=20=0A=20=09int=09=09=09c;=0A=20= =09int=09=09=09option_index;=0A+=09bool=09=09duplicate_sub_name=20=3D=20= false;=0A=20=0A=20=09char=09=20=20=20*pub_base_conninfo;=0A=20=09char=09=20= =20=20*sub_base_conninfo;=0A@@=20-2394,13=20+2395,10=20@@=20main(int=20= argc,=20char=20**argv)=0A=20=09=09=09=09=09pg_fatal("replication=20slot=20= \"%s\"=20specified=20more=20than=20once=20for=20--replication-slot",=20= optarg);=0A=20=09=09=09=09break;=0A=20=09=09=09case=204:=0A-=09=09=09=09= if=20(!simple_string_list_member(&opt.sub_names,=20optarg))=0A-=09=09=09=09= {=0A-=09=09=09=09=09simple_string_list_append(&opt.sub_names,=20optarg);=0A= -=09=09=09=09=09num_subs++;=0A-=09=09=09=09}=0A-=09=09=09=09else=0A-=09=09= =09=09=09pg_fatal("subscription=20\"%s\"=20specified=20more=20than=20= once=20for=20--subscription",=20optarg);=0A+=09=09=09=09if=20= (simple_string_list_member(&opt.sub_names,=20optarg))=0A+=09=09=09=09=09= duplicate_sub_name=20=3D=20true;=0A+=09=09=09=09= simple_string_list_append(&opt.sub_names,=20optarg);=0A+=09=09=09=09= num_subs++;=0A=20=09=09=09=09break;=0A=20=09=09=09case=205:=0A=20=09=09=09= =09if=20(!simple_string_list_member(&opt.objecttypes_to_clean,=20= optarg))=0A@@=20-2587,6=20+2585,13=20@@=20main(int=20argc,=20char=20= **argv)=0A=20=09=09=09=09=09=09=09num_replslots,=20num_dbs);=0A=20=09=09= exit(1);=0A=20=09}=0A+=09if=20(duplicate_sub_name=20&&=20num_replslots=20= =3D=3D=200)=0A+=09{=0A+=09=09pg_log_error("duplicate=20subscription=20= names=20require=20distinct=20replication=20slot=20names");=0A+=09=09= pg_log_error_detail("When=20replication=20slot=20names=20are=20not=20= specified,=20subscription=20names=20are=20used,=20but=20replication=20= slot=20names=20must=20be=20unique=20within=20a=20cluster.");=0A+=09=09= pg_log_error_hint("Specify=20a=20unique=20--replication-slot=20name=20= for=20each=20database.");=0A+=09=09exit(1);=0A+=09}=0A=20=0A=20=09/*=20= Verify=20the=20object=20types=20specified=20for=20removal=20from=20the=20= subscriber=20*/=0A=20=09for=20(SimpleStringListCell=20*cell=20=3D=20= opt.objecttypes_to_clean.head;=20cell;=20cell=20=3D=20cell->next)=0Adiff=20= --git=20a/src/bin/pg_basebackup/t/040_pg_createsubscriber.pl=20= b/src/bin/pg_basebackup/t/040_pg_createsubscriber.pl=0Aindex=20= 9252d1c3c5c..82fb4394bea=20100644=0A---=20= a/src/bin/pg_basebackup/t/040_pg_createsubscriber.pl=0A+++=20= b/src/bin/pg_basebackup/t/040_pg_createsubscriber.pl=0A@@=20-91,6=20= +91,19=20@@=20command_fails(=0A=20=09=09'--database'=20=3D>=20'pg2',=0A=20= =09],=0A=20=09'wrong=20number=20of=20subscription=20names');=0A= +command_fails_like(=0A+=09[=0A+=09=09'pg_createsubscriber',=0A+=09=09= '--verbose',=0A+=09=09'--pgdata'=20=3D>=20$datadir,=0A+=09=09= '--publisher-server'=20=3D>=20'port=3D5432',=0A+=09=09'--subscription'=20= =3D>=20'bar1',=0A+=09=09'--subscription'=20=3D>=20'bar1',=0A+=09=09= '--database'=20=3D>=20'pg1',=0A+=09=09'--database'=20=3D>=20'pg2',=0A+=09= ],=0A+=09qr/duplicate=20subscription=20names=20require=20distinct=20= replication=20slot=20names/,=0A+=09'duplicate=20subscription=20names=20= without=20replication=20slot=20names');=0A=20command_fails(=0A=20=09[=0A=20= =09=09'pg_createsubscriber',=0A@@=20-334,8=20+347,9=20@@=20= is($node_s->safe_psql($db1,=20"SELECT=20COUNT(*)=20FROM=20= pg_publication"),=0A=20=0A=20$node_s->stop;=0A=20=0A-#=20dry=20run=20= mode=20on=20node=20S.=20Use=20the=20same=20publication=20name=20for=20= different=0A-#=20databases,=20since=20publication=20names=20are=20= database-local.=0A+#=20dry=20run=20mode=20on=20node=20S.=20Use=20the=20= same=20publication=20and=20subscription=20names=20for=0A+#=20different=20= databases,=20since=20both=20names=20are=20database-local.=20Distinct=20= replication=0A+#=20slot=20names=20are=20required=20because=20replication=20= slots=20are=20cluster-global.=0A=20command_ok(=0A=20=09[=0A=20=09=09= 'pg_createsubscriber',=0A@@=20-348,8=20+362,10=20@@=20command_ok(=0A=20=09= =09'--subscriber-port'=20=3D>=20$node_s->port,=0A=20=09=09= '--publication'=20=3D>=20'same_pub',=0A=20=09=09'--publication'=20=3D>=20= 'same_pub',=0A-=09=09'--subscription'=20=3D>=20'sub1',=0A-=09=09= '--subscription'=20=3D>=20'sub2',=0A+=09=09'--subscription'=20=3D>=20= 'same_sub',=0A+=09=09'--subscription'=20=3D>=20'same_sub',=0A+=09=09= '--replication-slot'=20=3D>=20'slot1',=0A+=09=09'--replication-slot'=20= =3D>=20'slot2',=0A=20=09=09'--database'=20=3D>=20$db1,=0A=20=09=09= '--database'=20=3D>=20$db2,=0A=20=09=09'--logdir'=20=3D>=20$logdir,=0A--=20= =0A2.50.1=20(Apple=20Git-155)=0A=0A= --Apple-Mail=_0C786DC6-6570-4837-BB21-BB2B4B05AD74--