Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rcfAA-001KSb-7H for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Feb 2024 05:28:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rcfA8-002sBV-Ln for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Feb 2024 05:28:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rcfA8-002sBN-B6 for pgsql-hackers@lists.postgresql.org; Wed, 21 Feb 2024 05:28:56 +0000 Received: from mail-yw1-x1134.google.com ([2607:f8b0:4864:20::1134]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rcfA1-0007Qb-Gz for pgsql-hackers@postgresql.org; Wed, 21 Feb 2024 05:28:55 +0000 Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-607d8506099so61073937b3.0 for ; Tue, 20 Feb 2024 21:28:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708493328; x=1709098128; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=a7bAVCNgFy/RC/dAEDcsylxe1RbOjYxLfsBfIqjFX7k=; b=AjUaVSuJBUPIudEK6Msv4FthXaxV4i2sYmjOkP89pbdRgqERzrCPSrGue54OwOW5Ls SubsL+f+96LHKN8u9OyO6r+ELdCbrR0lR1dF+90b6vLxRcvn70UCOmlCRPoRb5Hz6qLM 4AVBvQhd/+6xWvhGwBhUdDwguOJZvW2EknNyPqMsvFmwpJ0L7eR6+dW8AHKFnn7sgpO+ HphX87YTJrSOSaAut21Re8AM+EU15ec4urxpqprEYduNtjA2T7o5x6pdObkD21fZ7ekL txFli/SVh5pUGw+FIl8UCBe6BoLszzctL6VPlOeL5+4RN2uMeWc8LP/wuIgjr4uWAOiH zkuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708493328; x=1709098128; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=a7bAVCNgFy/RC/dAEDcsylxe1RbOjYxLfsBfIqjFX7k=; b=Sof4fPy6AmHm6i9cXNh7vseiow2ABT/pNB6ap4OcKm/FLj2jlyzPuhHELMok0S7zG5 0aB1wwcfrJt9lu7NEYe8hLXSEbBbnWzPo5RHhGY4C5sXk+ImJNptc3yS1L8BkVrdZCJT Iy11jZz66vb4EDQjwJ2TA1OrH2lIYQQVLGjehyvpLJ+e0cYkQ7FP1UWQ8pcNAqTBDcDR jvNzdA5UCXsU+YLsgi6f111JtOUejlOQOIxaqE6KU8YH5uspkdyy9sFt4fdWbQtUO5FC 3nlk925bJ7BCGV30KaFBWC53F/7pn4+b9qth7rbAjqF9hncIGzwGncjSLvCfYioSaDid aJOA== X-Forwarded-Encrypted: i=1; AJvYcCUPq0PZLuiE08Ddq8c1XQFojltbQ6lSRgmOaz+cmp7Q/+SS98JsOGqLxe1LDCwf/DDMKr0mXsA0wUvkQDjI2Ehq5qiYj0LYQPAGUSoh X-Gm-Message-State: AOJu0YwSgiirmw0naBbzM6zJy6xjGXoNBIhD0Ciad4cC+j7tKMP1bEXL A6cDqtUP3FETXlOWac/srcupB38/+V6rumcy4L/fkost6h8dzf4alMYgjnK4qIB/cazr+r8JCvR b/kg5tnqFN07/XlJWlLvLx6ICjMo= X-Google-Smtp-Source: AGHT+IG5PvVkvPpIWu7DBTqtFjuWUgtqqJdZCahtI/czgvXZyvmcr8A57uSrBeJHnNGxpjCAjWmmhylO8/YERZLNtak= X-Received: by 2002:a05:690c:d1a:b0:607:9918:8c7b with SMTP id cn26-20020a05690c0d1a00b0060799188c7bmr18992774ywb.22.1708493328029; Tue, 20 Feb 2024 21:28:48 -0800 (PST) MIME-Version: 1.0 References: <20240221.120424.79274783106518358.horikyota.ntt@gmail.com> In-Reply-To: From: Ajin Cherian Date: Wed, 21 Feb 2024 16:28:36 +1100 Message-ID: Subject: Re: Have pg_basebackup write "dbname" in "primary_conninfo"? To: "Hayato Kuroda (Fujitsu)" Cc: Kyotaro Horiguchi , "barwick@gmail.com" , "pgsql-hackers@postgresql.org" , "robertmhaas@gmail.com" Content-Type: multipart/alternative; boundary="000000000000eb1b990611dd9946" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000eb1b990611dd9946 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Feb 21, 2024 at 4:09=E2=80=AFPM Hayato Kuroda (Fujitsu) < kuroda.hayato@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 dbname nor connection string is given, > > which is the first case Kuroda-san raised. The second case is the > > intended behavior of the function. > > > > > /* pg_recvlogical uses dbname only; others use connection_string > only. > > */ > > > Assert(dbname =3D=3D NULL || connection_string =3D=3D NULL); > > > > And the function incorrectly assumes that the connection string > > requires "dbname=3Dreplication". > > > > > * Merge the connection info inputs given in form of connection > string, > > > * options and default values (dbname=3Dreplication, > replication=3Dtrue, > > etc.) > > > > But the name is a pseudo database name only used by pg_hba.conf > > (maybe) , which cannot be used as an actual database name (without > > quotation marks, or unless it is actually created). The function > > should not add the fallback database name because the connection > > string for physical replication connection doesn't require the dbname > > parameter. (attached patch) > > I was also missing, but the requirement was that the dbname should be > included > only when the dbname option was explicitly specified [1]. Even mine and > yours > cannot handle like that. Libpq function > PQconnectdbParams()->pqConnectOptions2() > fills all the parameter to PGconn, at that time the information whether i= t > is > intentionally specified or not is discarded. Then, > GenerateRecoveryConfig() would > just write down all the connection parameters from PGconn, they cannot > recognize. > > Well, one option is that if a default dbname should be written to the configuration file, then "postgres' is a better option than "replication" or "username" as the default option, at least a db of that name exists. regards, Ajin Cherian Fujitsu Australia --000000000000eb1b990611dd9946 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Wed, Feb 21, 2024 at 4:09=E2=80=AF= PM Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com> wrote:
Dear Horiguchi-san,

> GetConnection()@streamutil.c wants to ensure conninfo has a fallback > database name ("replication"). However, the function seems t= o be
> ignoring the case where neither dbname nor connection string is given,=
> which is the first case Kuroda-san raised. The second case is the
> intended behavior of the function.
>
> >=C2=A0 =C2=A0 =C2=A0/* pg_recvlogical uses dbname only; others use= connection_string only.
> */
> >=C2=A0 =C2=A0 =C2=A0Assert(dbname =3D=3D NULL || connection_string= =3D=3D NULL);
>
> And the function incorrectly assumes that the connection string
> requires "dbname=3Dreplication".
>
> >=C2=A0 =C2=A0 =C2=A0 * Merge the connection info inputs given in f= orm of connection string,
> >=C2=A0 =C2=A0 =C2=A0 * options and default values (dbname=3Dreplic= ation, replication=3Dtrue,
> etc.)
>
> But the name is a pseudo database name only used by pg_hba.conf
> (maybe) , which cannot be used as an actual database name (without
> quotation marks, or unless it is actually created). The function
> should not add the fallback database name because the connection
> string for physical replication connection doesn't require the dbn= ame
> parameter. (attached patch)

I was also missing, but the requirement was that the dbname should be inclu= ded
only when the dbname option was explicitly specified [1]. Even mine and you= rs
cannot handle like that. Libpq function PQconnectdbParams()->pqConnectOp= tions2()
fills all the parameter to PGconn, at that time the information whether it = is
intentionally specified or not is discarded. Then, GenerateRecoveryConfig()= would
just write down all the connection parameters from PGconn, they cannot reco= gnize.

Well, one option is that = if a default dbname should be written to the configuration file, then "= ;postgres' is a better option than "replication" or "use= rname" as the default option, at least a db of that name exists.
=

regards,
Ajin Cherian
= Fujitsu Australia
--000000000000eb1b990611dd9946--