Skip to content

Commit 29abde6

Browse files
author
Amit Kapila
committed
Don't allow to set replication slot_name as ''.
We don't allow to create replication slot_name as an empty string ('') via SQL API pg_create_logical_replication_slot() but it is allowed to be set via Alter Subscription command. This will lead to apply worker repeatedly keep trying to stream data via slot_name '' and the user is not allowed to create the slot with that name. Author: Japin Li Reviewed-By: Ranier Vilela, Amit Kapila Backpatch-through: 10, where it was introduced Discussion: https://postgr.es/m/MEYP282MB1669CBD98E721C77CA696499B61A9@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
1 parent 04cad8f commit 29abde6

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

src/backend/commands/subscriptioncmds.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ parse_subscription_options(ParseState *pstate, List *stmt_options,
173173
/* Setting slot_name = NONE is treated as no slot name. */
174174
if (strcmp(opts->slot_name, "none") == 0)
175175
opts->slot_name = NULL;
176+
else
177+
ReplicationSlotValidateName(opts->slot_name, ERROR);
176178
}
177179
else if (IsSet(supported_opts, SUBOPT_COPY_DATA) &&
178180
strcmp(defel->defname, "copy_data") == 0)

src/test/regress/expected/subscription.out

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ ALTER SUBSCRIPTION regress_testsub SET PUBLICATION testpub2, testpub3 WITH (refr
8686
ALTER SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist2';
8787
ALTER SUBSCRIPTION regress_testsub SET (slot_name = 'newname');
8888
-- fail
89+
ALTER SUBSCRIPTION regress_testsub SET (slot_name = '');
90+
ERROR: replication slot name "" is too short
91+
-- fail
8992
ALTER SUBSCRIPTION regress_doesnotexist CONNECTION 'dbname=regress_doesnotexist2';
9093
ERROR: subscription "regress_doesnotexist" does not exist
9194
ALTER SUBSCRIPTION regress_testsub SET (create_slot = false);

src/test/regress/sql/subscription.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ ALTER SUBSCRIPTION regress_testsub SET PUBLICATION testpub2, testpub3 WITH (refr
6565
ALTER SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist2';
6666
ALTER SUBSCRIPTION regress_testsub SET (slot_name = 'newname');
6767

68+
-- fail
69+
ALTER SUBSCRIPTION regress_testsub SET (slot_name = '');
70+
6871
-- fail
6972
ALTER SUBSCRIPTION regress_doesnotexist CONNECTION 'dbname=regress_doesnotexist2';
7073
ALTER SUBSCRIPTION regress_testsub SET (create_slot = false);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy