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.
test.pgc
Description: test.pgc
keepalives.diffs
Description: keepalives.diffs