Re: [BUG FIX]Connection fails with whitespace after keepalives parameter value
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Fujii Masao <masao.fujii@oss.nttdata.com>, "Yuto Sasaki (Fujitsu)" <sasaki.yuto-00@fujitsu.com>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2024-10-02T02:35:19Z
Lists: pgsql-hackers
On Tue, Oct 01, 2024 at 12:29:15PM -0400, Tom Lane wrote: > Fujii Masao <masao.fujii@oss.nttdata.com> writes: >> 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. > > 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? Yes, it is a mistake to not use pqParseIntParam(), or parse_int_param() depending on the branch. This stuff has been introduced by 4f4061b2dde1, where I've spent some time making sure that leading and trailing whitespaces are discarded in this routine. See also these examples where whitespaces are OK in a connection URL: https://www.postgresql.org/message-id/20191021024020.GF1542%40paquier.xyz -- Michael
Commits
-
libpq: Discard leading and trailing spaces for parameters and values in URIs
- 430ce189fc45 18.0 landed
-
ecpg: avoid adding whitespace around '&' in connection URLs.
- f22e84df1dea 18.0 landed
-
Parse libpq's "keepalives" option more like other integer options.
- e7af9b52f679 14.14 landed
- c7a201053e3f 17.1 landed
- bb8c89dbcde7 15.9 landed
- 920d51979a99 18.0 landed
- 65f431affda8 16.5 landed
- 47d8a15deaeb 12.21 landed
- 2120eda94420 13.17 landed