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

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: "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-01 16:10:22
Message-ID: 464ea63f-9a73-4684-951e-a2cdf1bbcc24@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2024/10/01 14:11, Yuto Sasaki (Fujitsu) wrote:
> Hi hackers,
> I've discovered a bug in ECPG that causes database connection failures. This issue
> appears to stem from libpq layer.
> Found bug: The EXEC SQL CONNECT TO statement fails to connect to the database.
> Specifically, the following code:
> ```c
> EXEC SQL CONNECT TO tcp:postgresql://localhost:5432/postgres?keepalives=1
> &keepalives_idle=1 USER yuto;
> ```
> When precompiled and executed, this code fails to connect to the database.
> Error message:
> ```
> failed: keepalives parameter must be an integer
> ```
> Steps to reproduce: The issue can be reproduced using the attached pgc file.
> Root cause: The method for parsing the keepalives parameter in the useKeepalives
> function of the libpq library is not appropriate. Specifically, it doesn't
> account for whitespace following the numeric value.

Is a connection URL with whitespace, like "tcp:postgresql://localhost:5432/postgres?keepalives=1 & ...",
considered valid? If not, the issue seems to be that ecpg adds unnecessary whitespace
to the connection URL, especially after the "&" character.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-10-01 16:29:15 Re: [BUG FIX]Connection fails with whitespace after keepalives parameter value
Previous Message Robert Haas 2024-10-01 16:06:19 Re: pg_verifybackup: TAR format backup verification