From: christopher dot jones at oracle dot com Operating system: n/a PHP version: 5.2.0 PHP Bug Type: OCI8 related Bug description: oci_define_by_name column type is ignored
Description: ------------ The datatype passed to oci_define_by_name() is ignored. Patch is something like: Index: oci8_interface.c =================================================================== RCS file: /repository/php-src/ext/oci8/oci8_interface.c,v retrieving revision 1.8.2.7.2.6 diff -u -r1.8.2.7.2.6 oci8_interface.c --- oci8_interface.c 21 Dec 2006 22:08:26 -0000 1.8.2.7.2.6 +++ oci8_interface.c 29 Dec 2006 22:10:30 -0000 @@ -52,7 +52,7 @@ zval *stmt, *var; char *name; int name_len; - long type = SQLT_CHR; + long type = 0; php_oci_statement *statement; php_oci_define *define, *tmp_define; Index: oci8_statement.c =================================================================== RCS file: /repository/php-src/ext/oci8/oci8_statement.c,v retrieving revision 1.7.2.14.2.17 diff -u -r1.7.2.14.2.17 oci8_statement.c --- oci8_statement.c 25 Dec 2006 21:47:02 -0000 1.7.2.14.2.17 +++ oci8_statement.c 29 Dec 2006 22:10:30 -0000 @@ -506,7 +506,11 @@ /* find a user-setted define */ if (statement->defines) { - zend_hash_find(statement->defines,outcol->name,outcol->name_len,(void **) &outcol->define); + if (zend_hash_find(statement->defines,outcol->name,outcol->name_len,(void **) &outcol->define) == SUCCESS) { + if (outcol->define->type) { + outcol->data_type = outcol->define->type; + } + } } buf = 0; Reproduce code: --------------- These two queries incorrectly produce the same results: $stmt = oci_parse($c, "SELECT fileimage FROM phptestrawtable"); var_dump(oci_define_by_name($stmt, 'FILEIMAGE', $fi, SQLT_STR)); oci_execute($stmt); while (oci_fetch($stmt)) { echo "file md5:" . md5($fi) . "\n"; } $stmt = oci_parse($c, "SELECT fileimage FROM phptestrawtable"); var_dump(oci_define_by_name($stmt, 'FILEIMAGE', $fi)); oci_execute($stmt); while (oci_fetch($stmt)) { echo "file md5:" . md5($fi) . "\n"; } I'll mail a full .phpt testcase to Tony. -- Edit bug report at http://bugs.php.net/?id=39988&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39988&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39988&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39988&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=39988&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=39988&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=39988&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=39988&r=needscript Try newer version: http://bugs.php.net/fix.php?id=39988&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=39988&r=support Expected behavior: http://bugs.php.net/fix.php?id=39988&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=39988&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=39988&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=39988&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39988&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=39988&r=dst IIS Stability: http://bugs.php.net/fix.php?id=39988&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=39988&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=39988&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=39988&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=39988&r=mysqlcfg