php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39988 oci_define_by_name column type is ignored
Submitted: 2006-12-29 22:21 UTC Modified: 2007-01-11 12:01 UTC
From: christopher dot jones at oracle dot com Assigned: tony2001 (profile)
Status: Closed Package: OCI8 related
PHP Version: 5.2.0 OS: n/a
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: christopher dot jones at oracle dot com
New email:
PHP Version: OS:

 

 [2006-12-29 22:21 UTC] christopher dot jones at oracle dot com
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.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-01-11 12:01 UTC] tony2001@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jan 02 12:01:29 2025 UTC