From: | "Yuto Sasaki (Fujitsu)" <sasaki(dot)yuto-00(at)fujitsu(dot)com> |
---|---|
To: | "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | [BUG FIX]Connection fails with whitespace after keepalives parameter value |
Date: | 2024-10-01 05:11:21 |
Message-ID: | TY2PR01MB36286A7B97B9A15793335D18C1772@TY2PR01MB3628.jpnprd01.prod.outlook.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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.
Proposed fix: strtol() can be replaced with pqParseIntParam() like other paramters.
This skips whitespaces.
Concerns:
1. This fix may limit parameter values to integers only.
Example: keepalives=2147483648 (values larger than INT_MAX can't be read)
2. Whitespace after '=' that was previously not read will now be read.
Example: keepalives= 1 (previously couldn't be read, now read as 1)
3. This issue was introduced in previous versions (as far as I could verify,
from 9.0), so we may need to consider backpatching if necessary.
These concerns warrant further discussion.
I'd appreciate your review of this patch and these concerns. Thank you.
Attachment | Content-Type | Size |
---|---|---|
test.pgc | application/octet-stream | 578 bytes |
keepalives.diffs | application/octet-stream | 2.6 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Junwang Zhao | 2024-10-01 05:23:07 | Re: general purpose array_sort |
Previous Message | Hunaid Sohail | 2024-10-01 04:27:29 | Re: Psql meta-command conninfo+ |