|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19364 OCIFetch() is returning garbage on empty resultsets
Submitted: 2002-09-11 20:00 UTC Modified: 2002-09-12 08:35 UTC
From: walovaton at yahoo dot com dot mx Assigned:
Status: Closed Package: OCI8 related
PHP Version: 4.2.3 OS: Linux Mandrake 8.2
Private report: No CVE-ID: None
 [2002-09-11 20:00 UTC] walovaton at yahoo dot com dot mx

This bug seems to be happening in any 4.2.x series, in my case 4.2.3... but not in 4.1.x series

When I executed a query that returns an empty recordset (0 records), the value returned by OCIFetch() (or may be OCIResult()) is random garbage.  Some times strange characters, sometimes filed names of the SELECT statement.  :-S

The sql query is all right, if I print the $sql and copy/paste it in sqlplus... it returns the well known message "no rows selected".

Let's see a little example:

$conn = OCILogon("user", "pass", "dbstring");
// the id '200' doesn't exists
$sql  = "select name from customers where id = '200'";
$stmt = OCIParse($conn, $sql);
// $name should be empty, but it contains garbage
$name = OCIResult($stmt, "name");

So, like in PHP 4.1.x, I was expecting a null value or something that represents an empty value... not garbage or even important information like a fragment of the SELECT statement.

I tried this in both ways: (a) compiling OCI8 as a shared module and (b) compiling OCI8 as part of the php shared object,  I got the same result.

This is my configure string for php 4.2.3: the (b) way
./configure --with-apxs --disable-static --disable-debug --enable-inline-optimization --prefix=/usr/local/php-4.2.3 --with-config-file-path=/usr/local/php-4.2.3/etc --enable-magic-quotes --with-pear --enable-safe-mode --with-zlib=shared --with-mysql=shared,/usr --with-oci8=/opt/OraHome81 --with-pgsql=shared,/usr --with-gettext=shared --with-regex=system --enable-sysvsem --enable-sysvshm --with-mod_charset --enable-trans-sid --enable-ftp=shared

and this is my configure string for php 4.1.2: (works fine)
./configure --with-apxs --disable-static --disable-debug --enable-pic --enable-inline-optimization --prefix=/usr/local --with-zlib --with-config-file-path=/usr/local/etc --enable-magic-quotes --enable-track-vars --enable-safe-mode --with-exec-dir=/usr/bin --with-regex=system --enable-sysvsem --enable-sysvshm --with-mod_charset --enable-force-cgi-redirect --enable-trans-sid --enable-ftp --with-gettext --with-freetype-dir --with-oci8=/opt/OraHome81 --with-mysql=/usr --with-pgsql=/usr

I'm using gcc 3.2 (should I use gcc 2.95.X???)

I was expecting to make the upgrade to php 4.2.x soon but this strange bug makes me think it twice.

I hope this bug report helps you to fix the problem. If you need more information, just ask for it and I'll give you what you need.



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-09-12 04:51 UTC]
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at
In case this was a documentation problem, the fix will show up soon at

In case this was a website problem, the change will show
up on the site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.

simply place the oci8.c and php_oci8.h from CVS-HEAD into 
your 4.2.x and recompile. 
thx for reporting. 
 [2002-09-12 08:35 UTC] walovaton at yahoo dot com dot mx
Was this an old bug?

I searched on previous bug reports but I didn't find anything.

I'll test the CVS-HEAD version. Thanx for your help.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 17 11:01:31 2024 UTC