abies Wed May 5 18:18:35 2004 EDT
Modified files:
/php-src/ext/interbase ibase_query.c
Log:
Fixed unregistered bug: array count is incorrect when binding array ids
Fixed unregistered bug: empty numeric/datetime param argument is coerced to
a string that cannot be handled by the IB API layer
http://cvs.php.net/diff.php/php-src/ext/interbase/ibase_query.c?r1=1.2&r2=1.3&ty=u
Index: php-src/ext/interbase/ibase_query.c
diff -u php-src/ext/interbase/ibase_query.c:1.2 php-src/ext/interbase/ibase_query.c:1.3
--- php-src/ext/interbase/ibase_query.c:1.2 Tue May 4 08:42:54 2004
+++ php-src/ext/interbase/ibase_query.c Wed May 5 18:18:35 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ibase_query.c,v 1.2 2004/05/04 12:42:54 abies Exp $ */
+/* $Id: ibase_query.c,v 1.3 2004/05/05 22:18:35 abies Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -615,14 +615,7 @@
var->sqlind = &buf[i].sqlind;
- if (Z_TYPE_P(b_var) == IS_NULL) {
- if ((var->sqltype & 1) != 1) {
- _php_ibase_module_error("Parameter %d must have a
value" TSRMLS_CC, i+1);
- rv = FAILURE;
- }
- buf[i].sqlind = -1;
- if ((var->sqltype & ~1) == SQL_ARRAY) ++array_cnt;
- } else {
+ if (Z_TYPE_P(b_var) != IS_NULL) {
buf[i].sqlind = 0;
if (var->sqlscale < 0) {
@@ -630,7 +623,7 @@
DECIMAL or NUMERIC field are stored internally as
scaled integers.
Coerce it to string and let InterBase's internal
routines handle it.
*/
- var->sqltype = SQL_TEXT;
+ goto php_ibase_bind_default;
}
var->sqldata = (void*)&buf[i];
@@ -775,7 +768,7 @@
}
} else {
/* convert the array data into
something IB can understand */
- ibase_array *ar =
&ib_query->in_array[array_cnt++];
+ ibase_array *ar =
&ib_query->in_array[array_cnt];
void *array_data =
emalloc(ar->ar_size);
ISC_QUAD array_id = { 0, 0 };
@@ -797,15 +790,32 @@
buf[i].val.qval = array_id;
efree(array_data);
}
+ ++array_cnt;
break;
- default:
php_ibase_bind_default:
+ /* empty strings should be coerced to NULL for
non-text types */
+ if (Z_TYPE_P(b_var) == IS_STRING &&
Z_STRLEN_P(b_var) == 0) {
+ ZVAL_NULL(b_var);
+ break;
+ }
+
+ default:
convert_to_string(b_var);
var->sqldata = Z_STRVAL_P(b_var);
var->sqllen = Z_STRLEN_P(b_var);
var->sqltype = SQL_TEXT;
} /* switch */
} /* if */
+
+ if (Z_TYPE_P(b_var) == IS_NULL) {
+ if (! (var->sqltype & 1)) {
+ _php_ibase_module_error("Parameter %d must have a
value" TSRMLS_CC, i+1);
+ rv = FAILURE;
+ }
+ buf[i].sqlind = -1;
+
+ if (var->sqltype & SQL_ARRAY) ++array_cnt;
+ }
} /* for */
return rv;
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php