RE: pg_recvlogical requires -d but not described on the documentation
Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com>
From: "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>
To: 'Fujii Masao' <masao.fujii@oss.nttdata.com>, "David G. Johnston" <david.g.johnston@gmail.com>
Cc: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>, "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>, 'vignesh C' <vignesh21@gmail.com>
Date: 2025-03-18T09:17:21Z
Lists: pgsql-hackers
Dear Fujii-san, David,
> > BTW, I'm curious why --dbname isn't required for the --drop-slot action.
>
> I'm analyzing around here...
>
Actually, replication slots can be dropped from another database where it created,
or even from the streaming replication connection.
I forked the new thread which fixes the description [1].
Based on the fact, there are two approaches to fix:
1. Fix not to raise fatal error like:
```
@@ -950,7 +950,7 @@ main(int argc, char **argv)
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");
```
db_name == NULL means that streaming replication connection has been established,
so other operations are not allowed.
2. Fix documentation
We keep the current restriction and clarify it. For the reportability, it is
OK for me to also modify the code like:
```
@@ -881,7 +881,7 @@ main(int argc, char **argv)
exit(1);
}
- if (!do_drop_slot && dbname == NULL)
+ if (dbname == NULL)
```
Thought?
[1]: https://www.postgresql.org/message-id/OSCPR01MB14966C6BE304B5BB2E58D4009F5DE2%40OSCPR01MB14966.jpnprd01.prod.outlook.com
Best regards,
Hayato Kuroda
FUJITSU LIMITED
Commits
-
Allow pg_recvlogical --drop-slot to work without --dbname.
- c68100aa4313 18.0 landed
-
doc: Clarify required options for each action in pg_recvlogical.
- dfc13428a908 18.0 landed
-
Refactor replication connection code of various pg_basebackup utilities.
- 0c013e08cfbe 9.5.0 cited