Bug #80892 [PATCH]: PDO::PARAM_INT is treated the same as PDO::PARAM_STR
| From: | mbeccati@php.net | Date: | Wed, 24 Mar 2021 13:21:51 +0000 |
| Subject: | Bug #80892 [PATCH]: PDO::PARAM_INT is treated the same as PDO::PARAM_STR | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-232965@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80892&edit=1
ID: 80892
Patch added by: mbeccati@php.net
Reported by: benjamin dot morel at gmail dot com
Summary: PDO::PARAM_INT is treated the same as PDO::PARAM_STR
Status: Assigned
Type: Bug
Package: PDO PgSQL
Operating System: Linux
PHP Version: 8.0.3
Assigned To: mbeccati
Block user comment: N
Private report: N
New Comment:
The following pull request has been associated:
Patch Name: Fix bug #80892 PDO::PARAM_INT on pdo_pgsql
On GitHub: https://github.com/php/php-src/pull/6801
Patch: https://github.com/php/php-src/pull/6801.patch
Previous Comments:
------------------------------------------------------------------------
[2021-03-21 14:11:56] benjamin dot morel at gmail dot com
Sorry, typo. Should read:
> should respect PDO::PARAM_INT just like the mysql driver does.
------------------------------------------------------------------------
[2021-03-21 14:10:45] benjamin dot morel at gmail dot com
Description:
------------
As reported on https://externals.io/message/113521
The test script below fails because the pgsql driver seems to treat everything as PARAM_STR, despite
being explicitly requested to bind the value as PARAM_INT; the "?" placeholder is
therefore replaced with the string '4326' instead of the integer 4326.
The problem is, in PostGIS, the ST_Transform() function has different signatures with different
behaviours depending on whether the second parameter is an integer or a string.
As far as I can see, because of this issue, there is no way to pass an actual integer to a function
without using explicit, PostgreSQL-specific CAST syntax.
I believe this is a bug and the pgsql driver should respect PDO::PARAM_STR just like the mysql
driver does.
Test script:
---------------
$pdo = new PDO('pgsql:host=localhost;port=5432', 'postgres',
'postgres');
$statement = $pdo->prepare("
SELECT ST_AsText(
ST_Transform(
ST_GeomFromText('POINT(0 0)', 2154),
?
)
)
");
$statement->bindValue(1, 4326, PDO::PARAM_INT);
$statement->execute();
Expected result:
----------------
POINT(...)
Actual result:
--------------
PDOException: SQLSTATE[XX000]: Internal error: 7 ERROR: could not parse proj string '4326'
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80892&edit=1