diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-12-15 17:11:51 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-12-15 17:12:46 +0100 |
commit | cfe2b36a6db6ed2b1af7a574ed36abadfa18285f (patch) | |
tree | 7e1f7797681e3507d1d615f2f30e34dfe9e32749 | |
parent | f66f2b2b4f1b2ac2f21f80ef83687105f87c7f21 (diff) | |
download | php-git-cfe2b36a6db6ed2b1af7a574ed36abadfa18285f.tar.gz |
Fix ATTR_ORACLE_NULLS with PARAM_ZVAL
PARAM_ZVAL with a STR result should be treated the same way as
PARAM_STR in this regard.
-rw-r--r-- | ext/pdo/pdo_stmt.c | 6 | ||||
-rw-r--r-- | ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt | 8 |
2 files changed, 10 insertions, 4 deletions
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 5163e65a98..b1b6fb9907 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -520,6 +520,12 @@ static inline void fetch_value(pdo_stmt_t *stmt, zval *dest, int colno, int *typ case PDO_PARAM_ZVAL: if (value && value_len == sizeof(zval)) { ZVAL_COPY_VALUE(dest, (zval *)value); + + if (Z_TYPE_P(dest) == IS_STRING && Z_STRLEN_P(dest) == 0 + && stmt->dbh->oracle_nulls == PDO_NULL_EMPTY_STRING) { + zval_ptr_dtor_str(dest); + ZVAL_NULL(dest); + } } else { ZVAL_NULL(dest); } diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt index 1b6941c583..d7f54bfdee 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt @@ -112,11 +112,11 @@ array(1) { ["z"]=> NULL ["a"]=> - string(0) "" + NULL ["b"]=> string(1) " " ["c"]=> - string(0) "" + NULL ["d"]=> string(2) " d" ["e"]=> @@ -131,11 +131,11 @@ array(1) { ["z"]=> NULL ["a"]=> - string(0) "" + NULL ["b"]=> string(1) " " ["c"]=> - string(0) "" + NULL ["d"]=> string(2) " d" ["e"]=> |