Re: Allow specifying a dbname in pg_basebackup connection string

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Daniel Gustafsson <daniel(at)yesql(dot)se>
Cc: Jelte Fennema <me(at)jeltef(dot)nl>, Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>, Tristen Raab <tristen(dot)raab(at)highgo(dot)ca>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Jelte Fennema <github-tech(at)jeltef(dot)nl>
Subject: Re: Allow specifying a dbname in pg_basebackup connection string
Date: 2024-11-04 17:14:16
Message-ID: 2702546.1730740456@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Daniel Gustafsson <daniel(at)yesql(dot)se> writes:
> On 18 Sep 2023, at 14:11, Daniel Gustafsson <daniel(at)yesql(dot)se> wrote:
>> Unless something sticks out in a second pass over it I will go ahead and apply
>> it.

> And applied, closing the CF entry.

I believe this patch (commit cca97ce6a) is the cause of bug #18685,
which reports that pg_basebackup fails to use ~/.pgpass for
connections [1]. Specifically, it replaced this code:

- keywords[i] = "dbname";
- values[i] = dbname == NULL ? "replication" : dbname;

with this code:

+ keywords[i] = "dbname";
+ values[i] = dbname;

perhaps under the illusion that dbname and connection_string can't
both be NULL. But that ends in passing no dbname to libpq, rather
than passing "replication" which is the correct thing. Apparently
that has no effect on the server connection, but it does break
matching of such connections to ~/.pgpass.

I think the attached will fix it, but I wonder if there are edge
cases I'm not thinking of.

regards, tom lane

[1] https://www.postgresql.org/message-id/18685-fee2dd142b9688f1%40postgresql.org

Attachment Content-Type Size
fix-pg_basebackup-pgpass-matching.patch text/x-diff 485 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2024-11-04 17:17:54 Re: define pg_structiszero(addr, s, r)
Previous Message Heikki Linnakangas 2024-11-04 17:11:58 Re: pgsql: Implement pg_wal_replay_wait() stored procedure