Skip to content

Commit cfe2b36

Browse files
committed
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.
1 parent f66f2b2 commit cfe2b36

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

ext/pdo/pdo_stmt.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,12 @@ static inline void fetch_value(pdo_stmt_t *stmt, zval *dest, int colno, int *typ
520520
case PDO_PARAM_ZVAL:
521521
if (value && value_len == sizeof(zval)) {
522522
ZVAL_COPY_VALUE(dest, (zval *)value);
523+
524+
if (Z_TYPE_P(dest) == IS_STRING && Z_STRLEN_P(dest) == 0
525+
&& stmt->dbh->oracle_nulls == PDO_NULL_EMPTY_STRING) {
526+
zval_ptr_dtor_str(dest);
527+
ZVAL_NULL(dest);
528+
}
523529
} else {
524530
ZVAL_NULL(dest);
525531
}

ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ array(1) {
112112
["z"]=>
113113
NULL
114114
["a"]=>
115-
string(0) ""
115+
NULL
116116
["b"]=>
117117
string(1) " "
118118
["c"]=>
119-
string(0) ""
119+
NULL
120120
["d"]=>
121121
string(2) " d"
122122
["e"]=>
@@ -131,11 +131,11 @@ array(1) {
131131
["z"]=>
132132
NULL
133133
["a"]=>
134-
string(0) ""
134+
NULL
135135
["b"]=>
136136
string(1) " "
137137
["c"]=>
138-
string(0) ""
138+
NULL
139139
["d"]=>
140140
string(2) " d"
141141
["e"]=>

0 commit comments

Comments
 (0)