Bug #80892 [Asn->Csd]: PDO::PARAM_INT is treated the same as PDO::PARAM_STR
Edit report at https://bugs.php.net/bug.php?id=80892&edit=1
ID: 80892
Updated by: git@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
+Status: Closed
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:
Automatic comment on behalf of mbeccati
Revision: https://github.com/php/php-src/commit/340a06778c39054c7d715bceab82175840d92443
Log: Fix #80892: PDO::PARAM_INT is treated the same as PDO::PARAM_STR
Previous Comments:
------------------------------------------------------------------------
[2021-03-24 13:21:51] mbeccati@php.net
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
------------------------------------------------------------------------
[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
Thread (8 messages)