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. diff --git a/src/bin/pg_basebackup/streamutil.c b/src/bin/pg_basebackup/streamutil.c index 30b3d9a377e..9b864825462 100644 --- a/src/bin/pg_basebackup/streamutil.c +++ b/src/bin/pg_basebackup/streamutil.c @@ -74,7 +74,10 @@ GetConnection(void) PQconninfoOption *conn_opt; char *err_msg = NULL; - /* 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); /* @@ -120,12 +123,12 @@ GetConnection(void) keywords = pg_malloc0((argcount + 1) * sizeof(*keywords)); values = pg_malloc0((argcount + 1) * sizeof(*values)); keywords[i] = "dbname"; - values[i] = dbname; + values[i] = (dbname == NULL) ? "replication" : dbname; i++; } keywords[i] = "replication"; - values[i] = dbname == NULL ? "true" : "database"; + values[i] = (dbname == NULL) ? "true" : "database"; i++; keywords[i] = "fallback_application_name"; values[i] = progname;