Re: Allow specifying a dbname in pg_basebackup connection string

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Daniel Gustafsson <daniel@yesql.se>
Cc: Jelte Fennema <me@jeltef.nl>, Jim Jones <jim.jones@uni-muenster.de>, Tristen Raab <tristen.raab@highgo.ca>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Jelte Fennema <github-tech@jeltef.nl>
Date: 2024-11-04T18:57:32Z
Lists: pgsql-hackers

Attachments

Daniel Gustafsson <daniel@yesql.se> writes:
> +1 on your patch, reading through I can't see anything it misses.  Maybe a
> comment above the change with a note on why dbname is tested for NULL there
> would be good?

I thought Jelte's suggestion of clarifying the first comment was good:

-    /* pg_recvlogical uses dbname only; others use connection_string only. */
+    /*
+     * pg_recvlogical uses dbname only; others use connection_string only.
+     * (Note: both variables will be NULL if there's no command line options.)
+     */
     Assert(dbname == NULL || connection_string == NULL);

Also, I realized that the associated documentation is pretty much a
lie:

        ... any database
        name in the connection string will be ignored
        by <productname>PostgreSQL</productname>.

Maybe that's true for a very narrow interpretation of "PostgreSQL",
but I think most people would consider that pg_basebackup's lookup
of ~/.pgpass entries is covered.  I'm intending to go with the
attached.

			regards, tom lane

Commits

  1. pg_basebackup, pg_receivewal: fix failure to find password in ~/.pgpass.

  2. Allow dbname in pg_basebackup/pg_receivewal connstring