tony2001 Thu Jan 11 11:27:52 2007 UTC Added files: (Branch: PHP_5_2) /php-src/ext/oci8/tests bug40078.phpt
Modified files: /php-src NEWS /php-src/ext/oci8 oci8.c oci8_statement.c php_oci8_int.h Log: MFH: fix #40078 (ORA-01405 when fetching NULL values using oci_bind_array_by_name()) http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.489&r2=1.2027.2.547.2.490&diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.547.2.489 php-src/NEWS:1.2027.2.547.2.490 --- php-src/NEWS:1.2027.2.547.2.489 Wed Jan 10 18:14:37 2007 +++ php-src/NEWS Thu Jan 11 11:27:52 2007 @@ -9,6 +9,8 @@ - Fixed bug #40083 (milter SAPI functions always return false/null). (Tony) - Fixed bug #40079 (php_get_current_user() not thread safe). (Ilia, wharmby at uk dot ibm dot com) +- Fixed bug #40078 (ORA-01405 when fetching NULL values using + oci_bind_array_by_name()). (Tony) - Fixed bug #40076 (zend_alloc.c: Value of enumeration constant must be in range of signed integer). (Dmitry) - Fixed bug #40073 (exif_read_data dies on certain images). (Tony, Marcus) http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/oci8.c?r1=1.269.2.16.2.27&r2=1.269.2.16.2.28&diff_format=u Index: php-src/ext/oci8/oci8.c diff -u php-src/ext/oci8/oci8.c:1.269.2.16.2.27 php-src/ext/oci8/oci8.c:1.269.2.16.2.28 --- php-src/ext/oci8/oci8.c:1.269.2.16.2.27 Mon Jan 1 09:36:03 2007 +++ php-src/ext/oci8/oci8.c Thu Jan 11 11:27:52 2007 @@ -26,7 +26,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: oci8.c,v 1.269.2.16.2.27 2007/01/01 09:36:03 sebastian Exp $ */ +/* $Id: oci8.c,v 1.269.2.16.2.28 2007/01/11 11:27:52 tony2001 Exp $ */ /* TODO * * file://localhost/www/docs/oci10/ociaahan.htm#423823 - implement lob_empty() with OCI_ATTR_LOBEMPTY @@ -670,7 +670,7 @@ php_info_print_table_start(); php_info_print_table_row(2, "OCI8 Support", "enabled"); php_info_print_table_row(2, "Version", "1.2.2"); - php_info_print_table_row(2, "Revision", "$Revision: 1.269.2.16.2.27 $"); + php_info_print_table_row(2, "Revision", "$Revision: 1.269.2.16.2.28 $"); sprintf(buf, "%ld", OCI_G(num_persistent)); php_info_print_table_row(2, "Active Persistent Connections", buf); @@ -778,13 +778,16 @@ if (bind->array.elements) { efree(bind->array.elements); } + if (bind->array.element_lengths) { efree(bind->array.element_lengths); } -/* + if (bind->array.indicators) { efree(bind->array.indicators); - } + } + +/* if (bind->array.retcodes) { efree(bind->array.retcodes); } http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/oci8_statement.c?r1=1.7.2.14.2.18&r2=1.7.2.14.2.19&diff_format=u Index: php-src/ext/oci8/oci8_statement.c diff -u php-src/ext/oci8/oci8_statement.c:1.7.2.14.2.18 php-src/ext/oci8/oci8_statement.c:1.7.2.14.2.19 --- php-src/ext/oci8/oci8_statement.c:1.7.2.14.2.18 Mon Jan 1 09:36:03 2007 +++ php-src/ext/oci8/oci8_statement.c Thu Jan 11 11:27:52 2007 @@ -25,7 +25,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: oci8_statement.c,v 1.7.2.14.2.18 2007/01/01 09:36:03 sebastian Exp $ */ +/* $Id: oci8_statement.c,v 1.7.2.14.2.19 2007/01/11 11:27:52 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H @@ -1270,7 +1270,7 @@ (dvoid *) bindp->array.elements, (sb4) bind->array.max_length, type, - (dvoid *)0, /* bindp->array.indicators, */ + (dvoid *)bindp->array.indicators, (ub2 *)bind->array.element_lengths, (ub2 *)0, /* bindp->array.retcodes, */ (ub4) max_table_length, @@ -1320,6 +1320,8 @@ bind->array.max_length = maxlength; bind->array.element_lengths = safe_emalloc(max_table_length, sizeof(ub2), 0); memset(bind->array.element_lengths, 0, max_table_length*sizeof(ub2)); + bind->array.indicators = safe_emalloc(max_table_length, sizeof(sb2), 0); + memset(bind->array.indicators, 0, max_table_length*sizeof(sb2)); zend_hash_internal_pointer_reset(hash); @@ -1327,6 +1329,9 @@ if (zend_hash_get_current_data(hash, (void **) &entry) != FAILURE) { convert_to_string_ex(entry); bind->array.element_lengths[i] = Z_STRLEN_PP(entry); + if (Z_STRLEN_PP(entry) == 0) { + bind->array.indicators[i] = -1; + } zend_hash_move_forward(hash); } else { break; @@ -1372,6 +1377,7 @@ bind->array.max_length = sizeof(ub4); bind->array.element_lengths = safe_emalloc(max_table_length, sizeof(ub2), 0); memset(bind->array.element_lengths, 0, max_table_length * sizeof(ub2)); + bind->array.indicators = NULL; zend_hash_internal_pointer_reset(hash); for (i = 0; i < max_table_length; i++) { @@ -1409,6 +1415,7 @@ bind->array.max_length = sizeof(double); bind->array.element_lengths = safe_emalloc(max_table_length, sizeof(ub2), 0); memset(bind->array.element_lengths, 0, max_table_length * sizeof(ub2)); + bind->array.indicators = NULL; zend_hash_internal_pointer_reset(hash); for (i = 0; i < max_table_length; i++) { @@ -1446,6 +1453,7 @@ bind->array.max_length = sizeof(OCIDate); bind->array.element_lengths = safe_emalloc(max_table_length, sizeof(ub2), 0); memset(bind->array.element_lengths, 0, max_table_length * sizeof(ub2)); + bind->array.indicators = NULL; zend_hash_internal_pointer_reset(hash); for (i = 0; i < max_table_length; i++) { http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/php_oci8_int.h?r1=1.11.2.6.2.12&r2=1.11.2.6.2.13&diff_format=u Index: php-src/ext/oci8/php_oci8_int.h diff -u php-src/ext/oci8/php_oci8_int.h:1.11.2.6.2.12 php-src/ext/oci8/php_oci8_int.h:1.11.2.6.2.13 --- php-src/ext/oci8/php_oci8_int.h:1.11.2.6.2.12 Mon Jan 1 09:36:03 2007 +++ php-src/ext/oci8/php_oci8_int.h Thu Jan 11 11:27:52 2007 @@ -25,7 +25,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_oci8_int.h,v 1.11.2.6.2.12 2007/01/01 09:36:03 sebastian Exp $ */ +/* $Id: php_oci8_int.h,v 1.11.2.6.2.13 2007/01/11 11:27:52 tony2001 Exp $ */ #if HAVE_OCI8 # ifndef PHP_OCI8_INT_H @@ -180,7 +180,7 @@ php_oci_statement *parent_statement; /* pointer to the parent statement */ struct { void *elements; -/* ub2 *indicators; */ + sb2 *indicators; ub2 *element_lengths; /* ub2 *retcodes; */ ub4 current_length; http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/tests/bug40078.phpt?view=markup&rev=1.1 Index: php-src/ext/oci8/tests/bug40078.phpt +++ php-src/ext/oci8/tests/bug40078.phpt --TEST-- Bug #40078 (ORA-01405 when fetching NULL values using oci_bind_array_by_name()) --SKIPIF-- <?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> --FILE-- <?php require dirname(__FILE__).'/connect.inc'; $create_pkg = " CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS TYPE ARRTYPE IS TABLE OF VARCHAR(20) INDEX BY BINARY_INTEGER; PROCEDURE nullbind(c1 OUT ARRTYPE); END ARRAYBINDPKG1;"; $statement = oci_parse($c, $create_pkg); oci_execute($statement); $create_pkg_body = " CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS PROCEDURE nullbind(c1 OUT ARRTYPE) IS BEGIN c1(1) := 'one'; c1(2) := 'two'; c1(3) := ''; c1(4) := 'four'; c1(5) := 'five'; END nullbind; END ARRAYBINDPKG1;"; $statement = oci_parse($c, $create_pkg_body); oci_execute($statement); $statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.nullbind(:c1); END;"); oci_bind_array_by_name($statement, ":c1", $array, 5, 20, SQLT_CHR); oci_execute($statement); var_dump($array); echo "Done\n"; ?> --EXPECTF-- array(5) { [0]=> string(3) "one" [1]=> string(3) "two" [2]=> string(0) "" [3]=> string(4) "four" [4]=> string(4) "five" } Done --UEXPECTF-- array(5) { [0]=> unicode(3) "one" [1]=> unicode(3) "two" [2]=> unicode(0) "" [3]=> unicode(4) "four" [4]=> unicode(4) "five" } Done -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php