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

2024-03-20 Thread vignesh C
On Wed, 20 Mar 2024 at 17:09, Amit Kapila wrote: > > On Tue, Mar 19, 2024 at 5:18 PM Hayato Kuroda (Fujitsu) > wrote: > > > > Thanks for giving comments! > > > > > This behavior makes sense to me. But do we want to handle the case of > > > using environment variables too? > > > > Yeah, v5 does

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

2024-03-20 Thread Masahiko Sawada
On Wed, Mar 20, 2024 at 2:24 PM vignesh C wrote: > > On Tue, 19 Mar 2024 at 17:18, Hayato Kuroda (Fujitsu) > wrote: > > > > Dear Sawada-san, > > > > Thanks for giving comments! > > > > > This behavior makes sense to me. But do we want to handle the case of > > > using environment variables too?

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

2024-03-20 Thread Masahiko Sawada
On Tue, Mar 19, 2024 at 8:48 PM Hayato Kuroda (Fujitsu) wrote: > > Dear Sawada-san, > > Thanks for giving comments! > > > This behavior makes sense to me. But do we want to handle the case of > > using environment variables too? > > Yeah, v5 does not consider which libpq parameters are specified

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

2024-03-20 Thread Amit Kapila
On Tue, Mar 19, 2024 at 5:18 PM Hayato Kuroda (Fujitsu) wrote: > > Thanks for giving comments! > > > This behavior makes sense to me. But do we want to handle the case of > > using environment variables too? > > Yeah, v5 does not consider which libpq parameters are specified by environment >

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

2024-03-19 Thread vignesh C
On Tue, 19 Mar 2024 at 17:18, Hayato Kuroda (Fujitsu) wrote: > > Dear Sawada-san, > > Thanks for giving comments! > > > This behavior makes sense to me. But do we want to handle the case of > > using environment variables too? > > Yeah, v5 does not consider which libpq parameters are specified by

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

2024-03-19 Thread Hayato Kuroda (Fujitsu)
Dear Sawada-san, Thanks for giving comments! > This behavior makes sense to me. But do we want to handle the case of > using environment variables too? Yeah, v5 does not consider which libpq parameters are specified by environment variables. Such a variable should be used when the dbname is

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

2024-03-18 Thread Masahiko Sawada
On Thu, Mar 14, 2024 at 11:46 PM vignesh C wrote: > > On Thu, 14 Mar 2024 at 15:49, Amit Kapila wrote: > > > > On Thu, Mar 14, 2024 at 1:45 PM Masahiko Sawada > > wrote: > > > > > > On Thu, Mar 14, 2024 at 2:27 PM Amit Kapila > > > wrote: > > > > > > > > On Thu, Mar 14, 2024 at 5:57 AM

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

2024-03-14 Thread vignesh C
On Thu, 14 Mar 2024 at 15:49, Amit Kapila wrote: > > On Thu, Mar 14, 2024 at 1:45 PM Masahiko Sawada wrote: > > > > On Thu, Mar 14, 2024 at 2:27 PM Amit Kapila wrote: > > > > > > On Thu, Mar 14, 2024 at 5:57 AM Masahiko Sawada > > > wrote: > > > > > > > > This fact makes me think that the

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

2024-03-14 Thread Amit Kapila
On Thu, Mar 14, 2024 at 1:45 PM Masahiko Sawada wrote: > > On Thu, Mar 14, 2024 at 2:27 PM Amit Kapila wrote: > > > > On Thu, Mar 14, 2024 at 5:57 AM Masahiko Sawada > > wrote: > > > > > > This fact makes me think that the slotsync worker might be able to > > > accept the primary_conninfo

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

2024-03-14 Thread Masahiko Sawada
On Thu, Mar 14, 2024 at 2:27 PM Amit Kapila wrote: > > On Thu, Mar 14, 2024 at 5:57 AM Masahiko Sawada wrote: > > > > This fact makes me think that the slotsync worker might be able to > > accept the primary_conninfo value even if there is no dbname in the > > value. That is, if there is no

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

2024-03-14 Thread shveta malik
On Thu, Mar 14, 2024 at 10:57 AM Amit Kapila wrote: > > On Thu, Mar 14, 2024 at 5:57 AM Masahiko Sawada wrote: > > > > This fact makes me think that the slotsync worker might be able to > > accept the primary_conninfo value even if there is no dbname in the > > value. That is, if there is no

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

2024-03-13 Thread Amit Kapila
On Thu, Mar 14, 2024 at 5:57 AM Masahiko Sawada wrote: > > This fact makes me think that the slotsync worker might be able to > accept the primary_conninfo value even if there is no dbname in the > value. That is, if there is no dbname in the primary_conninfo, it uses > the username in accordance

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

2024-03-13 Thread Masahiko Sawada
On Fri, Feb 23, 2024 at 3:05 PM Amit Kapila wrote: > > On Wed, Feb 21, 2024 at 7:46 AM Hayato Kuroda (Fujitsu) > 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: > > > > ``` >

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

2024-03-13 Thread vignesh C
On Wed, 13 Mar 2024 at 16:58, Amit Kapila wrote: > > On Tue, Mar 12, 2024 at 5:13 PM vignesh C wrote: > > > > On Mon, 11 Mar 2024 at 17:16, Amit Kapila wrote: > > > > > > On Tue, Feb 27, 2024 at 2:07 PM Hayato Kuroda (Fujitsu) > > > wrote: > > > > > > > > > PSA the patch for implementing it.

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

2024-03-13 Thread Amit Kapila
On Tue, Mar 12, 2024 at 5:13 PM vignesh C wrote: > > On Mon, 11 Mar 2024 at 17:16, Amit Kapila wrote: > > > > On Tue, Feb 27, 2024 at 2:07 PM Hayato Kuroda (Fujitsu) > > wrote: > > > > > > > PSA the patch for implementing it. It is basically same as Ian's one. > > > > However, this patch still

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

2024-03-12 Thread vignesh C
On Mon, 11 Mar 2024 at 17:16, Amit Kapila wrote: > > On Tue, Feb 27, 2024 at 2:07 PM Hayato Kuroda (Fujitsu) > wrote: > > > > > PSA the patch for implementing it. It is basically same as Ian's one. > > > However, this patch still cannot satisfy the condition 3). > > > > > > `pg_basebackup -D

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

2024-03-11 Thread Amit Kapila
On Tue, Feb 27, 2024 at 2:07 PM Hayato Kuroda (Fujitsu) wrote: > > > PSA the patch for implementing it. It is basically same as Ian's one. > > However, this patch still cannot satisfy the condition 3). > > > > `pg_basebackup -D data_N2 -d "user=postgres" -R` > > -> dbname would not be appeared in

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

2024-02-27 Thread Amit Kapila
On Tue, Feb 27, 2024 at 2:00 PM Hayato Kuroda (Fujitsu) wrote: > > > We do append dbname=replication even in libpqrcv_connect for .pgpass > > lookup as mentioned in comments. See below: > > libpqrcv_connect() > > { > > > > else > > { > > /* > > * The database name is ignored by the server in

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

2024-02-27 Thread Hayato Kuroda (Fujitsu)
> PSA the patch for implementing it. It is basically same as Ian's one. > However, this patch still cannot satisfy the condition 3). > > `pg_basebackup -D data_N2 -d "user=postgres" -R` > -> dbname would not be appeared in primary_conninfo. > > This is because `if (connection_string)` case in

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

2024-02-27 Thread Hayato Kuroda (Fujitsu)
Dear Amit, > We do append dbname=replication even in libpqrcv_connect for .pgpass > lookup as mentioned in comments. See below: > libpqrcv_connect() > { > > else > { > /* > * The database name is ignored by the server in replication mode, > * but specify "replication" for .pgpass lookup. >

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

2024-02-27 Thread Hayato Kuroda (Fujitsu)
Dear Amit, > 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. I have proposed the

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

2024-02-22 Thread Amit Kapila
On Wed, Feb 21, 2024 at 8:34 AM Kyotaro Horiguchi wrote: > > At Tue, 20 Feb 2024 19:56:10 +0530, Robert Haas wrote > in > > It seems like maybe somebody should look into why this is happening, > > and perhaps fix it. > > GetConnection()@streamutil.c wants to ensure conninfo has a fallback >

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

2024-02-22 Thread Amit Kapila
On Wed, Feb 21, 2024 at 7:46 AM Hayato Kuroda (Fujitsu) 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 ... > > > ``` >

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

2024-02-20 Thread Ajin Cherian
On Wed, Feb 21, 2024 at 4:09 PM Hayato Kuroda (Fujitsu) < kuroda.hay...@fujitsu.com> wrote: > Dear Horiguchi-san, > > > GetConnection()@streamutil.c wants to ensure conninfo has a fallback > > database name ("replication"). However, the function seems to be > > ignoring the case where neither

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

2024-02-20 Thread Hayato Kuroda (Fujitsu)
Dear Horiguchi-san, > GetConnection()@streamutil.c wants to ensure conninfo has a fallback > database name ("replication"). However, the function seems to be > ignoring the case where neither dbname nor connection string is given, > which is the first case Kuroda-san raised. The second case is

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

2024-02-20 Thread Ajin Cherian
On Wed, Feb 21, 2024 at 2:04 PM Kyotaro Horiguchi wrote: > > Although I haven't looked the original thread, it seems that the > dbname is used only by pg_sync_replication_slots(). If it is true, > couldn't we make the SQL function require a database name to make a > connection, instead of

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

2024-02-20 Thread Ajin Cherian
On Wed, Feb 21, 2024 at 2:04 PM Kyotaro Horiguchi wrote: > > About the proposed patch, pg_basebackup cannot verify the validity of > the dbname. It could be problematic. > > Although I haven't looked the original thread, it seems that the > dbname is used only by pg_sync_replication_slots(). If

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

2024-02-20 Thread Kyotaro Horiguchi
At Tue, 20 Feb 2024 19:56:10 +0530, Robert Haas wrote in > It seems like maybe somebody should look into why this is happening, > and perhaps fix it. GetConnection()@streamutil.c wants to ensure conninfo has a fallback database name ("replication"). However, the function seems to be ignoring

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

2024-02-20 Thread Hayato Kuroda (Fujitsu)
Dear Robert, > > 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: > >

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

2024-02-20 Thread Robert Haas
On Tue, Feb 20, 2024 at 5:58 PM Hayato Kuroda (Fujitsu) wrote: > > Seems weird to me. You don't use dbname=replication to ask for a > > replication connection, so why would we ever end up with that > > anywhere? And especially in only one of two such closely related > > cases? > > Just FYI - here

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

2024-02-20 Thread Hayato Kuroda (Fujitsu)
Dear Robert, > Seems weird to me. You don't use dbname=replication to ask for a > replication connection, so why would we ever end up with that > anywhere? And especially in only one of two such closely related > cases? Just FYI - here is an extreme case. And note that I have applied proposed

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

2024-02-20 Thread Robert Haas
On Tue, Feb 20, 2024 at 4:18 PM Hayato Kuroda (Fujitsu) wrote: > I found an inconsistency. When I ran ` pg_basebackup -D data_N2 -U postgres > -R`, > dbname would be set as username. > > ``` > primary_conninfo = 'user=postgres ... dbname=postgres > ``` > > However, when I ran `pg_basebackup -D

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

2024-02-20 Thread Hayato Kuroda (Fujitsu)
Dear Ian, Thanks for making the patch. > With the addition of "pg_sync_replication_slots()", there is now a use-case > for > including "dbname" in "primary_conninfo" and the docs have changed from > stating [1]: > > Do not specify a database name in the primary_conninfo string. > > to [2]:

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

2024-02-19 Thread Amit Kapila
On Tue, Feb 20, 2024 at 5:04 AM Ian Lawrence Barwick wrote: > > > With the addition of "pg_sync_replication_slots()", there is now a use-case > for > including "dbname" in "primary_conninfo" and the docs have changed from > stating [1]: > > Do not specify a database name in the

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

2024-02-19 Thread Jelte Fennema-Nio
On Tue, 20 Feb 2024 at 00:34, Ian Lawrence Barwick wrote: > With the addition of "pg_sync_replication_slots()", there is now a use-case > for > including "dbname" in "primary_conninfo" and the docs have changed from > stating [1]: > > Do not specify a database name in the primary_conninfo

Have pg_basebackup write "dbname" in "primary_conninfo"?

2024-02-19 Thread Ian Lawrence Barwick
Hi Hi With the addition of "pg_sync_replication_slots()", there is now a use-case for including "dbname" in "primary_conninfo" and the docs have changed from stating [1]: Do not specify a database name in the primary_conninfo string. to [2]: For replication slot synchronization (see