aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFujii Masao <fujii@postgresql.org>2025-03-25 00:18:27 +0900
committerFujii Masao <fujii@postgresql.org>2025-03-25 00:18:27 +0900
commitc68100aa4313cf1cef826cf2d50f67164d13ebe4 (patch)
tree27d83beac8f48efdd730fac7be0b1ada79d7532f /src
parentdfc13428a9088dd37ec8ed64de37fb1655355f9a (diff)
downloadpostgresql-c68100aa4313cf1cef826cf2d50f67164d13ebe4.tar.gz
postgresql-c68100aa4313cf1cef826cf2d50f67164d13ebe4.zip
Allow pg_recvlogical --drop-slot to work without --dbname.
When pg_recvlogical was introduced in 9.4, the --dbname option was not required for --drop-slot. Without it, pg_recvlogical --drop-slot connected using a replication connection (not tied to a specific database) and was able to drop both physical and logical replication slots, similar to pg_receivewal --drop-slot. However, commit 0c013e08cfb unintentionally changed this behavior in 9.5, making pg_recvlogical always check whether it's connected to a specific database and fail if it's not. This change was expected for --create-slot and --start, which handle logical replication slots and require a database connection, but it was unnecessary for --drop-slot, which should work with any replication connection. As a result, --dbname became a required option for --drop-slot. This commit removes that restriction, restoring the original behavior and allowing pg_recvlogical --drop-slot to work without specifying --dbname. Although this issue originated from an unintended change, it has existed for a long time without complaints or bug reports, and the documentation never explicitly stated that --drop-slot should work without --dbname. Therefore, the change is not treated as a bug fix and is applied only to master. Author: Hayato Kuroda <kuroda.hayato@fujitsu.com> Reviewed-by: Fujii Masao <masao.fujii@gmail.com> Discussion: https://postgr.es/m/b15ecf4f-e5af-4fbb-82c2-a425f453e0b2@oss.nttdata.com
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_basebackup/pg_recvlogical.c9
-rw-r--r--src/bin/pg_basebackup/t/030_pg_recvlogical.pl8
2 files changed, 14 insertions, 3 deletions
diff --git a/src/bin/pg_basebackup/pg_recvlogical.c b/src/bin/pg_basebackup/pg_recvlogical.c
index b9ea23e1426..a3447753119 100644
--- a/src/bin/pg_basebackup/pg_recvlogical.c
+++ b/src/bin/pg_basebackup/pg_recvlogical.c
@@ -944,13 +944,16 @@ main(int argc, char **argv)
#endif
/*
- * Run IDENTIFY_SYSTEM to make sure we connected using a database specific
- * replication connection.
+ * Run IDENTIFY_SYSTEM to check the connection type for each action.
+ * --create-slot and --start actions require a database-specific
+ * replication connection because they handle logical replication slots.
+ * --drop-slot can remove replication slots from any replication
+ * connection without this restriction.
*/
if (!RunIdentifySystem(conn, NULL, NULL, NULL, &db_name))
exit(1);
- if (db_name == NULL)
+ if (!do_drop_slot && db_name == NULL)
pg_fatal("could not establish database-specific replication connection");
/*
diff --git a/src/bin/pg_basebackup/t/030_pg_recvlogical.pl b/src/bin/pg_basebackup/t/030_pg_recvlogical.pl
index a6e10600161..62bbc5a3f98 100644
--- a/src/bin/pg_basebackup/t/030_pg_recvlogical.pl
+++ b/src/bin/pg_basebackup/t/030_pg_recvlogical.pl
@@ -127,4 +127,12 @@ $node->command_ok(
],
'replayed a two-phase transaction');
+$node->command_ok(
+ [
+ 'pg_recvlogical',
+ '--slot' => 'test',
+ '--drop-slot'
+ ],
+ 'drop could work without dbname');
+
done_testing();