#46249 [Csd]: pdo_pgsql always fill in NULL for empty BLOB

From: Date: Sun, 12 Oct 2008 16:51:06 +0000
Subject: #46249 [Csd]: pdo_pgsql always fill in NULL for empty BLOB
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-129655@lists.php.net to get a copy of this message
ID: 46249 Updated by: felipe@php.net Reported By: hswong3i at gmail dot com Status: Closed Bug Type: PDO related Operating System: Debian PHP Version: 5.2.6 Assigned To: felipe New Comment: Do you have tried after 13:03:31 2008 UTC? I've commited a complete fix to these issue in this time. Thanks. Previous Comments: ------------------------------------------------------------------------ [2008-10-12 16:39:57] hswong3i at gmail dot com I try for both PHP5.2 and 5.3 from http://snaps.php.net/ (they both coming with the fix). They are now able to handle NULL and empty string BLOB INSERT/UPDATE. Thanks for the work. BTW, it is now generate another issue that should belongs to http://bugs.php.net/bug.php?id=46274. Whenever fetching NULL or empty BLOB content from DB apache will crash with Segmentation fault. Maybe we still need some love for that :S ------------------------------------------------------------------------ [2008-10-11 19:05:59] felipe@php.net This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. ------------------------------------------------------------------------ [2008-10-11 11:47:35] felipe@php.net Oh sorry, you're right. I can reproduce it. ------------------------------------------------------------------------ [2008-10-11 06:47:47] hswong3i at gmail dot com According to http://www.php.net/manual/en/pdo.lobs.php, using PDO for BLOB INSERT/UPDATE should come with: 1. bindParam/bindColumn 2. PDO::PARAM_LOB 3. stream API, e.g. fopen(), fwrite(), rewind(), etc. You may try to insert other value though you code snippet. The value should also NOT able to insert into PostgreSQL... The bug reproduction code in http://drupal.org/node/316095#comment-1047830 is using pdo_pgsql directly. The db_insert() used is just a fake clone of Drupal CVS HEAD function with simplified programming logic. ------------------------------------------------------------------------ [2008-10-11 00:26:16] felipe@php.net I can't reproduce using 5.3CVS: $db = new PDO('pgsql:host=localhost dbname=test', 'foo', 'bar', array(PDO::ATTR_STRINGIFY_FETCHES => TRUE)); $stmt = $db->prepare("INSERT INTO test_one_blob (blob1) VALUES (?)"); $stmt->execute(array('')); var_dump($db->errorinfo()); $stmt = $db->prepare("INSERT INTO test_one_blob (blob1) VALUES (:foo)"); $x = ''; $stmt->bindParam(':foo', $x); $stmt->execute(); var_dump($db->errorinfo()); $stmt = $db->query("INSERT INTO test_one_blob (blob1) VALUES ('')"); $stmt->execute(); teste=> select * from test_one_blob where blob1 is null; id | blob1 ----+------- (0 registros) Do you have tested using PDO directly, without Drupal's db_insert()? ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/46249 -- Edit this bug report at http://bugs.php.net/?id=46249&edit=1

« previous php.bugs (#129655) next »