mbeccati Thu, 03 Sep 2009 22:53:25 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=288013
Log: MFH - Fixed bug #48060 (pdo_pgsql - large objects are returned as empty) # Backported from 5.3.0, per gripe from Konstantin Ryabitsev # Permission granted by Ilia Bug: http://bugs.php.net/48060 (Closed) pdo_pgsql - large objects are returned as empty Changed paths: U php/php-src/branches/PHP_5_2/NEWS U php/php-src/branches/PHP_5_2/ext/pdo/pdo_stmt.c U php/php-src/branches/PHP_5_2/ext/pdo_pgsql/pgsql_statement.c U php/php-src/branches/PHP_5_2/ext/pdo_pgsql/tests/bug46274_2.phpt Modified: php/php-src/branches/PHP_5_2/NEWS =================================================================== --- php/php-src/branches/PHP_5_2/NEWS 2009-09-03 22:19:34 UTC (rev 288012) +++ php/php-src/branches/PHP_5_2/NEWS 2009-09-03 22:53:25 UTC (rev 288013) @@ -1,6 +1,7 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 0? Sep 2009, PHP 5.2.11 +- Fixed bug #48060 (pdo_pgsql - large objects are returned as empty). (Matteo) 03 Sep 2009, PHP 5.2.11RC2 Modified: php/php-src/branches/PHP_5_2/ext/pdo/pdo_stmt.c =================================================================== --- php/php-src/branches/PHP_5_2/ext/pdo/pdo_stmt.c 2009-09-03 22:19:34 UTC (rev 288012) +++ php/php-src/branches/PHP_5_2/ext/pdo/pdo_stmt.c 2009-09-03 22:53:25 UTC (rev 288013) @@ -587,9 +587,8 @@ case PDO_PARAM_LOB: if (value == NULL) { ZVAL_NULL(dest); - } else if (value[0] == '\0') { - ZVAL_EMPTY_STRING(dest); } else if (value_len == 0) { + /* Warning, empty strings need to be passed as stream */ if (stmt->dbh->stringify || new_type == PDO_PARAM_STR) { char *buf = NULL; size_t len; Modified: php/php-src/branches/PHP_5_2/ext/pdo_pgsql/pgsql_statement.c =================================================================== --- php/php-src/branches/PHP_5_2/ext/pdo_pgsql/pgsql_statement.c 2009-09-03 22:19:34 UTC (rev 288012) +++ php/php-src/branches/PHP_5_2/ext/pdo_pgsql/pgsql_statement.c 2009-09-03 22:53:25 UTC (rev 288013) @@ -599,8 +599,14 @@ return 0; } else { *ptr = php_pdo_pgsql_unescape_bytea(*ptr, &tmp_len); - *len = tmp_len; - *caller_frees = 1; + if (!tmp_len) { + /* Empty string, return as empty stream */ + *ptr = (char *)php_stream_memory_open(TEMP_STREAM_READONLY, "", 0); + *len = 0; + } else { + *len = tmp_len; + *caller_frees = 1; + } } break; case PDO_PARAM_NULL: Modified: php/php-src/branches/PHP_5_2/ext/pdo_pgsql/tests/bug46274_2.phpt =================================================================== --- php/php-src/branches/PHP_5_2/ext/pdo_pgsql/tests/bug46274_2.phpt 2009-09-03 22:19:34 UTC (rev 288012) +++ php/php-src/branches/PHP_5_2/ext/pdo_pgsql/tests/bug46274_2.phpt 2009-09-03 22:53:25 UTC (rev 288013) @@ -47,11 +47,13 @@ var_dump($x = $res->fetch()); var_dump(fread($x['blob1'], 10)); -// Empty string +// Resource var_dump($res->fetch()); +var_dump(fread($x['blob1'], 10)); -// Empty string +// Resource var_dump($res->fetch()); +var_dump(fread($x['blob1'], 10)); // NULL var_dump($res->fetch()); @@ -69,16 +71,18 @@ string(3) "foo" array(2) { ["blob1"]=> - string(0) "" + resource(%d) of type (stream) [0]=> - string(0) "" + resource(%d) of type (stream) } +string(0) "" array(2) { ["blob1"]=> - string(0) "" + resource(%d) of type (stream) [0]=> - string(0) "" + resource(%d) of type (stream) } +string(0) "" array(2) { ["blob1"]=> NULL
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php