From: e dot mauviere at geoclip dot fr Operating system: WIN XP PRO PHP version: 5.1.2 PHP Bug Type: PostgreSQL related Bug description: data is returned truncated with BINARY CURSOR
Description: ------------ Impossible to retrieve properly binary data from a binary field in Postgresql. It should work with the SQL BINARY CURSOR OPTION in Postgres, but data returned is truncated. Reproduce code: --------------- CREATE TABLE test(binfield byteA) ; INSERT INTO test VALUES (decode('0103AA000812','hex')); //First try $data =pg_query("SELECT binfield FROM test"); $res=pg_fetch_result($data,0); echo $res; // =>"\001\003\252\000\010\022" echo bin2hex(pg_unescape_bytea($res)); //=> "0103aa000812" //By default, Potsgresql returns binary field values as strings, so we need to unescape them to restore original binary data. Tedious. Performance issue here. //second try $sql="BEGIN;DECLARE mycursor BINARY CURSOR FOR SELECT binfield FROM test;fetch all in mycursor;"; //the BINARY CURSOR option forces PostgreSQ to return binary data $data =pg_query($sql); $res=pg_fetch_result($data,0); echo strlen($res); //=> 3 echo bin2hex($res); //=> 0103aa //BUG : data returned is truncated, as soon as a "00" byte is encountered, Expected result: ---------------- i am expecting to retrieve full binary content -- Edit bug report at http://bugs.php.net/?id=37100&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37100&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=37100&r=trysnapshot51 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37100&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=37100&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=37100&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=37100&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=37100&r=needscript Try newer version: http://bugs.php.net/fix.php?id=37100&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=37100&r=support Expected behavior: http://bugs.php.net/fix.php?id=37100&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=37100&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=37100&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=37100&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37100&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=37100&r=dst IIS Stability: http://bugs.php.net/fix.php?id=37100&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=37100&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=37100&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=37100&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=37100&r=mysqlcfg