Re: [BUG FIX]Connection fails with whitespace after keepalives parameter value

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, "Yuto Sasaki (Fujitsu)" <sasaki(dot)yuto-00(at)fujitsu(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [BUG FIX]Connection fails with whitespace after keepalives parameter value
Date: 2024-10-02 21:39:31
Message-ID: 148583.1727905171@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com> writes:
> On 2024/10/02 11:35, Michael Paquier wrote:
>> On Tue, Oct 01, 2024 at 12:29:15PM -0400, Tom Lane wrote:
>>> I agree with Sasaki-san that useKeepalives seems rather bogus: almost
>>> every other place in fe-connect.c uses pqParseIntParam rather than
>>> calling strtol directly, so why not this one?

> I have no objection to improving the handling of the keepalives parameter.
> OTOH, I think ecpg might have an issue when converting the connection URI.

I went ahead and pushed Sasaki-san's patch. I think anything we might
do in ecpg is probably just cosmetic and wouldn't get back-patched.

> In the converted URI, whitespace is added before and after the ? character.
> In my quick test, ECPGconnect() seems to handle this without error,
> but when I tried the same URI in psql, it returned an error:
> $ psql "postgresql://localhost:5432/postgres?keepalives=1 & keepalives_idle=1 & keepalives_interval=1 & keepalives_count=2"
> psql: error: invalid URI query parameter: " keepalives_idle"

Interesting. This is unhappy about the space before a parameter name,
not the space after a parameter value, so it's a different issue.
But it's weird that ecpg takes it while libpq doesn't. Could libecpg
be modifying/reassembling the URI string? I didn't look.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2024-10-02 22:44:49 Re: On disable_cost
Previous Message Alena Rybakina 2024-10-02 19:41:41 Re: On disable_cost