Bug #80892 [NEW]: PDO::PARAM_INT is treated the same as PDO::PARAM_STR

From: Date: Sun, 21 Mar 2021 14:10:45 +0000
Subject: Bug #80892 [NEW]: PDO::PARAM_INT is treated the same as PDO::PARAM_STR
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-232904@lists.php.net to get a copy of this message
From:             benjamin dot morel at gmail dot com
Operating system: Linux
PHP version:      8.0.3
Package:          PDO PgSQL
Bug Type:         Bug
Bug description:PDO::PARAM_INT is treated the same as PDO::PARAM_STR

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 bug report at https://bugs.php.net/bug.php?id=80892&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=80892&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=80892&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=80892&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=80892&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=80892&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=80892&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=80892&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=80892&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=80892&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=80892&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80892&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=80892&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=80892&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=80892&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=80892&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=80892&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=80892&r=mysqlcfg


Thread (8 messages)

« previous php.bugs (#232904) next »