From: goetas at lignano dot it Operating system: ubuntu 10.04 PHP version: 5.3.25 Package: PDO related Bug Type: Bug Bug description:Postgres prepared statement positional parameter casting
Description: ------------ Using a prepared statement with positional parameters will produce unexpected behaviour when casting these parameters. Test script: --------------- // pdo $pdo = new \PDO("pgsql:host=localhost;dbname=db", "user", "pwd"); $pdo->setAttribute (\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); $st = $pdo->prepare('SELECT ?::char as i'); $st->bindValue(1, '1'); $st->execute(); var_dump($st->fetch()); // return false $st = $pdo->prepare('SELECT (?)::char as i'); $st->bindValue(1, '1'); $st->execute(); var_dump($st->fetch()); // return array(1) { ["i"]=> string(1) "1" } // old pg extension $dbconn = pg_connect("host=localhost dbname=superdpi user=postgres password=df54tb70"); $result = pg_prepare($dbconn, "my_query", 'SELECT $1::char as i'); $result = pg_execute($dbconn, "my_query", array("1")); var_dump(pg_fetch_assoc ( $result)); // return array(1) { ["i"]=> string(1) "1" } Expected result: ---------------- array(2) { ["i"]=> string(1) "1" [0]=> string(1) "1" } array(2) { ["i"]=> string(1) "1" [0]=> string(1) "1" } array(1) { ["i"]=> string(1) "1" } Actual result: -------------- bool(false) array(2) { ["i"]=> string(1) "1" [0]=> string(1) "1" } array(1) { ["i"]=> string(1) "1" } -- Edit bug report at https://bugs.php.net/bug.php?id=64953&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64953&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64953&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64953&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64953&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64953&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64953&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64953&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64953&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=64953&r=support Expected behavior: https://bugs.php.net/fix.php?id=64953&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64953&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64953&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64953&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64953&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64953&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64953&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=64953&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64953&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64953&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64953&r=mysqlcfg