From 3c0432be7fb0aaa865c0b9eeed2bfcf5d0b915e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20K=C3=B6ditz?= Date: Wed, 15 Apr 2026 16:58:45 +0200 Subject: [PATCH] Fix #106: preserve nullable bit when setting SQL_TEXT in _php_ibase_bind() The fallthrough path in _php_ibase_bind() unconditionally set sqltype to SQL_TEXT, discarding the nullable bit (bit 0). This caused subsequent ibase_execute() calls with NULL to be ignored for nullable columns that went through this path. Fix: use SQL_TEXT | (var->sqltype & 1) to preserve the nullable flag. Adds test: tests/issue106_001.phpt --- ibase_query.c | 2 +- tests/issue106_001.phpt | 50 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 tests/issue106_001.phpt diff --git a/ibase_query.c b/ibase_query.c index 052d97c5..57fe3c0b 100644 --- a/ibase_query.c +++ b/ibase_query.c @@ -796,7 +796,7 @@ static int _php_ibase_bind(ibase_query *ib_query, zval *b_vars) /* {{{ */ convert_to_string(b_var); var->sqldata = Z_STRVAL_P(b_var); var->sqllen = (ISC_SHORT)Z_STRLEN_P(b_var); - var->sqltype = SQL_TEXT; // Here: sqltype is modfied, can't rely on it for next calls + var->sqltype = SQL_TEXT | (var->sqltype & 1); // preserve nullable bit (issue #106) // Another way to send string w/o converting base zval // zend_string *str = zval_get_string(b_var); diff --git a/tests/issue106_001.phpt b/tests/issue106_001.phpt new file mode 100644 index 00000000..5cbe1d14 --- /dev/null +++ b/tests/issue106_001.phpt @@ -0,0 +1,50 @@ +--TEST-- +Issue #106: _php_ibase_bind() loses NULL flag when handling SQL_TEXT fallthrough +--SKIPIF-- + +--FILE-- + +--EXPECT-- +ID=1 VAL='hello' +ID=2 VAL=NULL +ID=3 VAL='world'