com php-src: Fix ATTR_ORACLE_NULLS with PARAM_ZVAL: ext/pdo/pdo_stmt.c ext/pdo_mysql/tests/pdo_mysql _attr_oracle_nulls.phpt
| From: | Nikita Popov | Date: | Tue, 15 Dec 2020 16:12:46 +0000 |
| Subject: | com php-src: Fix ATTR_ORACLE_NULLS with PARAM_ZVAL: ext/pdo/pdo_stmt.c ext/pdo_mysql/tests/pdo_mysql _attr_oracle_nulls.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-114472@lists.php.net to get a copy of this message | ||
Commit: cfe2b36a6db6ed2b1af7a574ed36abadfa18285f
Author: Nikita Popov <nikita.ppv@gmail.com> Tue, 15 Dec 2020 17:11:51 +0100
Parents: f66f2b2b4f1b2ac2f21f80ef83687105f87c7f21
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=cfe2b36a6db6ed2b1af7a574ed36abadfa18285f
Log:
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.
Changed paths:
M ext/pdo/pdo_stmt.c
M ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt
Diff:
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index 5163e65a98e..b1b6fb99074 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 1b6941c583d..d7f54bfdee9 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"]=>