diff options
author | Matteo Beccati <mbeccati@php.net> | 2009-09-03 22:53:25 +0000 |
---|---|---|
committer | Matteo Beccati <mbeccati@php.net> | 2009-09-03 22:53:25 +0000 |
commit | 2acedb40e6cb2b3703913b89813824fd6657547d (patch) | |
tree | 6f4951394a93600100880a83600d4bfaa9e5140d | |
parent | d9eeb2e6e659486ab9d2d15b720714b1ef5503dd (diff) | |
download | php-git-2acedb40e6cb2b3703913b89813824fd6657547d.tar.gz |
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
-rw-r--r-- | NEWS | 1 | ||||
-rwxr-xr-x | ext/pdo/pdo_stmt.c | 3 | ||||
-rw-r--r-- | ext/pdo_pgsql/pgsql_statement.c | 10 | ||||
-rw-r--r-- | ext/pdo_pgsql/tests/bug46274_2.phpt | 16 |
4 files changed, 20 insertions, 10 deletions
@@ -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 diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index d5c618ea0b..136f82d47b 100755 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -587,9 +587,8 @@ static inline void fetch_value(pdo_stmt_t *stmt, zval *dest, int colno, int *typ 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; diff --git a/ext/pdo_pgsql/pgsql_statement.c b/ext/pdo_pgsql/pgsql_statement.c index a891069881..ce53d84922 100644 --- a/ext/pdo_pgsql/pgsql_statement.c +++ b/ext/pdo_pgsql/pgsql_statement.c @@ -599,8 +599,14 @@ static int pgsql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned 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: diff --git a/ext/pdo_pgsql/tests/bug46274_2.phpt b/ext/pdo_pgsql/tests/bug46274_2.phpt index 5e35556880..eb675afe9e 100644 --- a/ext/pdo_pgsql/tests/bug46274_2.phpt +++ b/ext/pdo_pgsql/tests/bug46274_2.phpt @@ -47,11 +47,13 @@ $res = $db->query("SELECT blob1 from test_one_blob"); 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 @@ array(2) { 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 |