tony2001 Wed Aug 9 12:15:43 2006 UTC Added files: (Branch: PHP_5_2) /php-src/ext/oci8/tests bug38161.phpt
Modified files: /php-src NEWS /php-src/ext/oci8 oci8_statement.c php_oci8_int.h Log: MFH: fix #38161 (oci_bind_by_name() returns garbage when Oracle didn't set the variable) http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.191&r2=1.2027.2.547.2.192&diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.547.2.191 php-src/NEWS:1.2027.2.547.2.192 --- php-src/NEWS:1.2027.2.547.2.191 Tue Aug 8 15:55:26 2006 +++ php-src/NEWS Wed Aug 9 12:15:42 2006 @@ -75,6 +75,8 @@ itself). (Ilia) - Fixed bug #38173 (Freeing nested cursors causes OCI8 to segfault). (Tony) - Fixed bug #38168 (Crash in pdo_pgsql on missing bound parameters). (Ilia) +- Fixed bug #38161 (oci_bind_by_name() returns garbage when Oracle didn't set + the variable). (Tony) - Fixed bug #38132 (ReflectionClass::getStaticProperties() retains \0 in key names). (Ilia) - Fixed bug #38064 (ignored constructor visibility). (Marcus) http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/oci8_statement.c?r1=1.7.2.14.2.3&r2=1.7.2.14.2.4&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.3 php-src/ext/oci8/oci8_statement.c:1.7.2.14.2.4 --- php-src/ext/oci8/oci8_statement.c:1.7.2.14.2.3 Wed Aug 9 11:49:06 2006 +++ php-src/ext/oci8/oci8_statement.c Wed Aug 9 12:15:42 2006 @@ -25,7 +25,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: oci8_statement.c,v 1.7.2.14.2.3 2006/08/09 11:49:06 tony2001 Exp $ */ +/* $Id: oci8_statement.c,v 1.7.2.14.2.4 2006/08/09 12:15:42 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H @@ -826,9 +826,11 @@ case SQLT_LNG: case SQLT_CHR: /* this is the default case when type was not specified */ - convert_to_string(var); + if (Z_TYPE_P(var) != IS_NULL) { + convert_to_string(var); + } if (maxlength == -1) { - value_sz = Z_STRLEN_P(var); + value_sz = (Z_TYPE_P(var) == IS_STRING) ? Z_STRLEN_P(var) : 0; } else { value_sz = maxlength; @@ -1003,7 +1005,7 @@ zval_dtor(val); Z_STRLEN_P(val) = PHP_OCI_PIECE_SIZE; /* 64K-1 is max XXX */ - Z_STRVAL_P(val) = emalloc(Z_STRLEN_P(phpbind->zval)); + Z_STRVAL_P(val) = ecalloc(1, Z_STRLEN_P(phpbind->zval) + 1); /* XXX we assume that zend-zval len has 4 bytes */ *alenpp = (ub4*) &Z_STRLEN_P(phpbind->zval); http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/php_oci8_int.h?r1=1.11.2.6.2.3&r2=1.11.2.6.2.4&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.3 php-src/ext/oci8/php_oci8_int.h:1.11.2.6.2.4 --- php-src/ext/oci8/php_oci8_int.h:1.11.2.6.2.3 Mon Jul 31 10:30:22 2006 +++ php-src/ext/oci8/php_oci8_int.h Wed Aug 9 12:15:42 2006 @@ -25,7 +25,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_oci8_int.h,v 1.11.2.6.2.3 2006/07/31 10:30:22 tony2001 Exp $ */ +/* $Id: php_oci8_int.h,v 1.11.2.6.2.4 2006/08/09 12:15:42 tony2001 Exp $ */ #if HAVE_OCI8 # ifndef PHP_OCI8_INT_H @@ -186,7 +186,7 @@ long max_length; long type; } array; - sb2 indicator; /* */ + sb2 indicator; /* -1 means NULL */ ub2 retcode; /* */ } php_oci_bind; /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/tests/bug38161.phpt?view=markup&rev=1.1 Index: php-src/ext/oci8/tests/bug38161.phpt +++ php-src/ext/oci8/tests/bug38161.phpt --TEST-- bug #38161 (oci_bind_by_name() returns garbage when Oracle didn't set the variable) --SKIPIF-- <?php if (!extension_loaded("oci8")) print "skip"; ?> --FILE-- <?php require dirname(__FILE__).'/connect.inc'; $query = "begin if false then :bv := 1; end if; end;"; $stid = oci_parse($c, $query); oci_bind_by_name($stid, ":bv", $bv, 22); oci_execute($stid, OCI_DEFAULT); var_dump($bv); unset($bv); $query = "begin if false then :bv := 1; end if; end;"; $stid = oci_parse($c, $query); oci_bind_by_name($stid, ":bv", $bv, 22, SQLT_INT); oci_execute($stid, OCI_DEFAULT); var_dump($bv); echo "Done\n"; ?> --EXPECTF-- NULL int(0) Done -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php