php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38061 php_oci_lob_read counts bytes read incorrectly for CLOBs
Submitted: 2006-07-10 21:45 UTC Modified: 2006-07-10 22:42 UTC
From: dcowgill at communityconnect dot com Assigned:
Status: Closed Package: OCI8 related
PHP Version: 5.1.4 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dcowgill at communityconnect dot com
New email:
PHP Version: OS:

 

 [2006-07-10 21:45 UTC] dcowgill at communityconnect dot com
Description:
------------
OCI-Lob->read returns empty string, even when OCI-Lob->size is non-zero and lob offset is 0; tested with oracle 10.1.0.3 and 10.2.0.1

Reproduce code:
---------------
The example labeled "Example 3. Inserting data into a CLOB column" in the OCI8 section of the PHP manual (http://us2.php.net/manual/en/ref.oci8.php) demonstrates the problem perfectly.

Expected result:
----------------
As described in the example in the php manual.

Actual result:
--------------
No clob data is returned; same outcome when fetching with the OCI_RETURN_LOBS bit set, or when using a bind variable.

The bug appears to be in php_oci_lob_read (ext/oci8/oci8_lob.c) -- specifically, in the #ifdef HAVE_OCI_LOB_READ2 branch. OCILobRead2 always sets byte_amtp to 0 when char_amtp is provided and the data type is clob; but on line 251, data_len is incremented by byte_amtp.

The OCI docs are, not surprisingly, characteristically vague about these parameters, and the description at http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14250/oci16msc002.htm#sthref3022 is not much help:

"byte_amtp (IN/OUT) IN - The number of bytes to read from the database. Used for BLOB and BFILE always. For CLOB and NCLOB, it is used only when char_amtp is zero. OUT - The number of bytes read into the user buffer."

That sounds like byte_amtp should always have a value on output, even if char_amtp was non-zero and the data type is CLOB or NCLOB, but my oracle client certainly doesn't do that. It always sets *byte_amtp to zero unless char_amtp is null.

Tested with out-of-the-box installs of oracle 10.1.0.3 and 10.2.0.1

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-07-10 21:52 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2006-07-10 22:24 UTC] dcowgill at communityconnect dot com
appears to be fixed in CVS. Thanks!
 [2006-07-10 22:42 UTC] tony2001@php.net
Great.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 12:01:27 2024 UTC