On Wed, Feb 21, 2024 at 7:46 AM Hayato Kuroda (Fujitsu) <kuroda.hay...@fujitsu.com> wrote: > > > > Just FYI - here is an extreme case. And note that I have applied proposed > > > patch. > > > > > > When `pg_basebackup -D data_N2 -R` is used: > > > ``` > > > primary_conninfo = 'user=hayato ... dbname=hayato ... > > > ``` > > > > > > But when `pg_basebackup -d "" -D data_N2 -R` is used: > > > ``` > > > primary_conninfo = 'user=hayato ... dbname=replication > > > ``` > > > > It seems like maybe somebody should look into why this is happening, > > and perhaps fix it. > > I think this caused from below part [1] in GetConnection(). > > If both dbname and connection_string are the NULL, we will enter the else part > and NULL would be substituted - {"dbnmae", NULL} key-value pair is generated > only here. > > Then, in PQconnectdbParams()->PQconnectStartParams->pqConnectOptions2(), > the strange part would be found and replaced to the username [2]. > > I think if both the connection string and the dbname are NULL, it should be > considered as the physical replication connection. here is a patch to fix it. >
When dbname is NULL or not given, it defaults to username. This follows the specs of the connection string. See (dbname # The database name. Defaults to be the same as the user name...) [1]. Your patch breaks that specs, so I don't think it is correct. [1] - https://www.postgresql.org/docs/devel/libpq-connect.html#LIBPQ-CONNSTRING -- With Regards, Amit Kapila.