]> granicus.if.org Git - php/commitdiff
Fix ATTR_ORACLE_NULLS with PARAM_ZVAL
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 15 Dec 2020 16:11:51 +0000 (17:11 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 15 Dec 2020 16:12:46 +0000 (17:12 +0100)
PARAM_ZVAL with a STR result should be treated the same way as
PARAM_STR in this regard.

ext/pdo/pdo_stmt.c
ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt

index 5163e65a98ecb107220a4f809bef72d3022ce6c7..b1b6fb9907462928619e260d2fc70f9e78886555 100644 (file)
@@ -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);
                        }
index 1b6941c583d908ed13e84606d18a42e0f32bb365..d7f54bfdee940a110553b7b7a6ad027147dbe427 100644 (file)
@@ -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"]=>