#41135 [NEW]: PDO SQLite BLOB field data truncated after 21 bytes

From: Date: Wed, 18 Apr 2007 16:46:47 +0000
Subject: #41135 [NEW]: PDO SQLite BLOB field data truncated after 21 bytes
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-111662@lists.php.net to get a copy of this message
From: rich at corephp dot co dot uk Operating system: Windows XP SP2 PHP version: 5.2.1 PHP Bug Type: PDO related Bug description: PDO SQLite BLOB field data truncated after 21 bytes Description: ------------ There appears to be an issue inserting binary data from a file into a SQLite BLOB field via PDO SQLite in that the data is never fully transferred. The SQLite database consisted of 1 table with 3 columns: id - integer - primary filename - varchar(50) data - blob The PHP code tried to insert an image file into the BLOB field. The code does not error in any way, nothing appears in the PHP error log, no warnings are produced, but the data is never fully transmitted to the SQLite database. The ID is created properly, the filename is correct, but the data field contains only the first 21 bytes worth of the image and nothing more. Various different image files have been tested. The SQLite database itself is valid, and works perfectly with BLOB fields when inserted from the command-line. The web server is Apache 2.2.4 The SQLite database, from phpinfo: PDO Driver for SQLite 3.x enabled PECL Module version 1.0.1 $Id: pdo_sqlite.c,v 1.10.2.6.2.1 2007/01/01 09:36:05 sebastian Exp $ SQLite Library 3.3.7undefined Reproduce code: --------------- $filename = 'D:/sandbox.dev/public_html/test.gif'; try { $db = new PDO('sqlite:D:/sandbox.dev/public_html/test.db'); } catch (PDOException $error) { echo "Error! :" . $error->getMessage(); } $name = 'test.gif'; $stmt = $db->prepare('INSERT INTO DataTest (filename, data) VALUES (?,?)'); $stmt->execute(array($name, file_get_contents($filename))); Expected result: ---------------- The SQLite database 'test.db' should be updated to contain the full contents of test.gif in the BLOB field. Actual result: -------------- The image data is truncated after the first 21 bytes. When viewed in Hexadecimal mode you can see that the GIF89a header was passed across, along with the first 5 bytes of actual picture data, but after that it is cut off. Insert a PNG file instead of a GIF and you get the PNG data header, plus a few bytes worth of image, and again it cuts off. No matter what type of file you insert into the BLOB, only the first 21 bytes make it. -- Edit bug report at http://bugs.php.net/?id=41135&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41135&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41135&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41135&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=41135&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=41135&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=41135&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=41135&r=needscript Try newer version: http://bugs.php.net/fix.php?id=41135&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=41135&r=support Expected behavior: http://bugs.php.net/fix.php?id=41135&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=41135&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=41135&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=41135&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41135&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=41135&r=dst IIS Stability: http://bugs.php.net/fix.php?id=41135&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=41135&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=41135&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=41135&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=41135&r=mysqlcfg

« previous php.bugs (#111662) next »