From: mark dot kirkwood at catalyst dot net dot nz Operating system: Ubuntu x86 (32 bit) PHP version: 5.2CVS-2009-07-14 (CVS) PHP Bug Type: PDO related Bug description: int value > PHP_INT_MAX causes "Invalid text representation" in pdo_pgsql
Description: ------------ PDO performs conversions to string of various parameters. However for an integer > PHP_INT_MAX PHP has already converted it to a float before PDO sees it. This catches out Postgres [1] when inserting such a value because the conversion leaves trailing .0000... on the value. Now this issue seems to have been fixed in PHP 6.0. The actual fix looks to be very simple (I'll attach a patch in a separate comment). The affected file is: ext/pdo/pdo_stmt.c function: really_register_bound_param I think we can just call convert_to_string without any special casing for IS_DOUBLE, as convert_to_string handles them ok itself. [1] but will catch Mysql too if have STRICT_ALL_TABLES or similar enabled. Reproduce code: --------------- /* table a has desc (id bigint) */ $sql = "INSERT INTO a VALUES (?)"; $stmt = $dbh->prepare($sql,array(PDO::ATTR_EMULATE_PREPARES => true)); $id = PHP_INT_MAX + 1; var_dump($id); $stmt->execute(array($id)); Expected result: ---------------- integer 2147483648 inserted into the table 'a'. Actual result: -------------- PDOException: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "2147483648.000000" -- Edit bug report at http://bugs.php.net/?id=48924&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48924&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48924&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48924&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=48924&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48924&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=48924&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=48924&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=48924&r=needscript Try newer version: http://bugs.php.net/fix.php?id=48924&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=48924&r=support Expected behavior: http://bugs.php.net/fix.php?id=48924&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=48924&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=48924&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=48924&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48924&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=48924&r=dst IIS Stability: http://bugs.php.net/fix.php?id=48924&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=48924&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=48924&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=48924&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=48924&r=mysqlcfg