tony2001 Thu Jan 11 11:26:36 2007 UTC Added files: /php-src/ext/oci8/tests bug40078.phpt
Modified files: /php-src/ext/oci8 oci8.c oci8_statement.c php_oci8_int.h Log: fix #40078 (ORA-01405 when fetching NULL values using oci_bind_array_by_name()) http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/oci8.c?r1=1.326&r2=1.327&diff_format=u Index: php-src/ext/oci8/oci8.c diff -u php-src/ext/oci8/oci8.c:1.326 php-src/ext/oci8/oci8.c:1.327 --- php-src/ext/oci8/oci8.c:1.326 Mon Jan 1 09:29:26 2007 +++ php-src/ext/oci8/oci8.c Thu Jan 11 11:26:36 2007 @@ -26,7 +26,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: oci8.c,v 1.326 2007/01/01 09:29:26 sebastian Exp $ */ +/* $Id: oci8.c,v 1.327 2007/01/11 11:26:36 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.326 $"); + php_info_print_table_row(2, "Revision", "$Revision: 1.327 $"); 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.39&r2=1.40&diff_format=u Index: php-src/ext/oci8/oci8_statement.c diff -u php-src/ext/oci8/oci8_statement.c:1.39 php-src/ext/oci8/oci8_statement.c:1.40 --- php-src/ext/oci8/oci8_statement.c:1.39 Mon Jan 1 09:29:26 2007 +++ php-src/ext/oci8/oci8_statement.c Thu Jan 11 11:26:36 2007 @@ -25,7 +25,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: oci8_statement.c,v 1.39 2007/01/01 09:29:26 sebastian Exp $ */ +/* $Id: oci8_statement.c,v 1.40 2007/01/11 11:26:36 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H @@ -1336,7 +1336,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, @@ -1391,13 +1391,18 @@ bind->array.max_length = TEXT_BYTES(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); for (i = 0; i < bind->array.current_length; i++) { if (zend_hash_get_current_data(hash, (void **) &entry) != FAILURE) { convert_to_text_ex(entry); bind->array.element_lengths[i] = TEXT_BYTES(Z_UNILEN_PP(entry)); + if (Z_UNILEN_PP(entry) == 0) { + bind->array.indicators[i] = -1; + } zend_hash_move_forward(hash); } else { break; @@ -1447,6 +1452,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++) { @@ -1484,6 +1490,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++) { @@ -1521,6 +1528,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.28&r2=1.29&diff_format=u Index: php-src/ext/oci8/php_oci8_int.h diff -u php-src/ext/oci8/php_oci8_int.h:1.28 php-src/ext/oci8/php_oci8_int.h:1.29 --- php-src/ext/oci8/php_oci8_int.h:1.28 Mon Jan 1 09:29:26 2007 +++ php-src/ext/oci8/php_oci8_int.h Thu Jan 11 11:26:36 2007 @@ -25,7 +25,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_oci8_int.h,v 1.28 2007/01/01 09:29:26 sebastian Exp $ */ +/* $Id: php_oci8_int.h,v 1.29 2007/01/11 11:26:36 tony2001 Exp $ */ #if HAVE_OCI8 # ifndef PHP_OCI8_INT_H @@ -188,7 +188,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