From b1008c1f01ff5cd35d2394bde2532c40781e696f Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 4 Nov 2024 14:36:04 -0500 Subject: pg_basebackup, pg_receivewal: fix failure to find password in ~/.pgpass. Sloppy refactoring in commit cca97ce6a caused these programs to pass dbname = NULL to libpq if there was no "--dbname" switch on the command line, where before "replication" would be passed. This didn't break things completely, because the source server doesn't care about the dbname specified for a physical replication connection. However, it did cause libpq to fail to match a ~/.pgpass entry that has "replication" in the dbname field. Restore the previous behavior of passing "replication". Also, closer inspection shows that if you do specify a dbname in the connection string, that is what will be matched to ~/.pgpass, not "replication". This was the pre-existing behavior so we should not change it, but the SGML docs were pretty misleading about it. Improve that. Per bug #18685 from Toshi Harada. Back-patch to v17 where the error crept in. Discussion: https://postgr.es/m/18685-fee2dd142b9688f1@postgresql.org Discussion: https://postgr.es/m/2702546.1730740456@sss.pgh.pa.us --- doc/src/sgml/ref/pg_basebackup.sgml | 16 ++++++++++------ doc/src/sgml/ref/pg_receivewal.sgml | 13 ++++++++----- 2 files changed, 18 insertions(+), 11 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/ref/pg_basebackup.sgml b/doc/src/sgml/ref/pg_basebackup.sgml index 4f99340c1dd..c2d721208b1 100644 --- a/doc/src/sgml/ref/pg_basebackup.sgml +++ b/doc/src/sgml/ref/pg_basebackup.sgml @@ -807,14 +807,18 @@ PostgreSQL documentation will override any conflicting command line options. - The option is called --dbname for consistency with other + This option is called --dbname for consistency with other client applications, but because pg_basebackup doesn't connect to any particular database in the cluster, any database - name in the connection string will be ignored - by PostgreSQL. Middleware, or proxies, used in - connecting to PostgreSQL might however - utilize the value. The database name specified in connection string can - also be used by + name included in the connection string will be ignored by the server. + However, a database name supplied that way overrides the default + database name (replication) for purposes of + looking up the replication connection's password + in ~/.pgpass. Similarly, middleware or proxies + used in connecting to PostgreSQL might + utilize the name for purposes such as connection routing. The + database name can also be used + by logical replication slot synchronization. diff --git a/doc/src/sgml/ref/pg_receivewal.sgml b/doc/src/sgml/ref/pg_receivewal.sgml index 8944eee2a36..9e353a068e5 100644 --- a/doc/src/sgml/ref/pg_receivewal.sgml +++ b/doc/src/sgml/ref/pg_receivewal.sgml @@ -315,13 +315,16 @@ PostgreSQL documentation will override any conflicting command line options. - The option is called --dbname for consistency with other + This option is called --dbname for consistency with other client applications, but because pg_receivewal doesn't connect to any particular database in the cluster, any database - name in the connection string will be ignored by - PostgreSQL. Middleware, or proxies, used in - connecting to PostgreSQL might however - utilize the value. + name included in the connection string will be ignored by the server. + However, a database name supplied that way overrides the default + database name (replication) for purposes of + looking up the replication connection's password + in ~/.pgpass. Similarly, middleware or proxies + used in connecting to PostgreSQL might + utilize the name for purposes such as connection routing. -- cgit v1.2.3