ID:               46249
 User updated by:  hswong3i at gmail dot com
 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:

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


Previous Comments:
------------------------------------------------------------------------

[2008-10-11 19:05:59] [EMAIL PROTECTED]

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] [EMAIL PROTECTED]

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] [EMAIL PROTECTED]

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()?

------------------------------------------------------------------------

[2008-10-07 18:00:22] hswong3i at gmail dot com

Description:
------------
When pdo_pgsql working with:
  1. BLOB field,
  2. running INSERT/UPDATE queries, and
  3. BLOB value with empty string ''

It will always fill NULL into database and so result as buggy.
INSERT/UPDATE BLOB value with NULL will function correctly.

P.S. pdo_mysql is NOT buggy when running with similar programming
logic, empty string pass into database correctly. Tested with PHP5.2.6
and PHP5.3-dev, both are buggy.

Reproduce code:
---------------
Please refer to http://drupal.org/node/316095#comment-1047830 for more
information.

Expected result:
----------------
Empty string should fill into database correctly.

Actual result:
--------------
Empty string is now stored as NULL.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=46249&edit=1

Reply via email to