Re: Have pg_basebackup write "dbname" in "primary_conninfo"?

Поиск
Список
Период
Сортировка
От Amit Kapila
Тема Re: Have pg_basebackup write "dbname" in "primary_conninfo"?
Дата
Msg-id CAA4eK1LY619Lp1baFR_Po818oVGBSoGBc3TuqWApOZVFP79kdQ@mail.gmail.com
обсуждение исходный текст
Ответ на RE: Have pg_basebackup write "dbname" in "primary_conninfo"?  ("Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>)
Ответы RE: Have pg_basebackup write "dbname" in "primary_conninfo"?  ("Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>)
Re: Have pg_basebackup write "dbname" in "primary_conninfo"?  (Masahiko Sawada <sawada.mshk@gmail.com>)
Список pgsql-hackers
On Wed, Feb 21, 2024 at 7:46 AM Hayato Kuroda (Fujitsu)
<kuroda.hayato@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.



В списке pgsql-hackers по дате отправления:

Предыдущее
От: shveta malik
Дата:
Сообщение: Re: Synchronizing slots from primary to standby
Следующее
От: Amit Kapila
Дата:
Сообщение: Re: Have pg_basebackup write "dbname" in "primary_conninfo"?