|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57048 CLOB value is truncated
Submitted: 2006-05-29 09:36 UTC Modified: 2016-10-13 16:25 UTC
From: vs at ez dot no Assigned: nikic (profile)
Status: Closed Package: OCI8 related
PHP Version: 4.4.1 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.
Block user comment
Status: Assign to:
Bug Type:
From: vs at ez dot no
New email:
PHP Version: OS:


 [2006-05-29 09:36 UTC] vs at ez dot no
If I set the fourth parameter (charset) of function oci_connect() to 'UTF8' (=set client charset to Unicode) and then select a CLOB value from my table, the value gets truncated.

Tried on two databases:
1. Oracle 9i (server charset is WE8ISO8859P1)
2. Oracle 10g XE (server charset is AL32UTF8)

PHP 4.4.2 is linked against OIC- libraries.

The bug is not reproducible with the standard PHP oci8 extension, but is with PECL/oci8.

Reproduce code:
// CREATE TABLE clob_test (lob CLOB);
$origLobVal = str_repeat( 'x', 500 ); // randomly chosen character
$conn = oci_connect( 'scott', 'tiger', 'orcl', 'UTF8' );
$stmt = oci_parse( $conn, 'DELETE FROM clob_test' );
oci_execute( $stmt, OCI_COMMIT_ON_SUCCESS );
$stmt = oci_parse( $conn, "INSERT INTO clob_test VALUES (EMPTY_CLOB()) RETURNING lob INTO :lob" );
$lob = oci_new_descriptor( $conn, OCI_D_LOB );
oci_bind_by_name( $stmt, ":lob", $lob, -1, OCI_B_CLOB );
oci_execute( $stmt, OCI_DEFAULT );
$lob->save( $origLobVal );
oci_commit( $conn );
$stmt = oci_parse ( $conn, 'SELECT lob FROM clob_test' );
oci_execute( $stmt, OCI_DEFAULT );
$row = oci_fetch_array( $stmt, OCI_NUM );
$realLobVal = $row[0]->load();
printf( "original len: %d\nreal len:     %d\n", strlen( $origLobVal ), strlen( $realLobVal ) );
oci_free_statement( $stmt );

Expected result:
original len: 500
real len:     500

Actual result:
original len: 500
real len:     166


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-29 09:51 UTC] vs at ez dot no
In the reproduce code above, the value is inserted correctly, since "SELECT DBMS_LOB.GETLENGTH(lob) FROM clob_test" returns "500".
So, the value gets truncated at time of fetching.
 [2006-06-01 16:55 UTC] tony2001 at phpclub dot net
Vadim, please try this patch:
(optionally you can get patched oci8 here:
Hopefully this should fix all unicode lob problems.
 [2006-06-13 07:00 UTC] vs at ez dot no
Thank you. Looks like the patched version does not contain this bug.
 [2006-06-13 13:02 UTC] tony2001 at phpclub dot net
The patch is already in CVS.
 [2016-10-13 16:11 UTC]
-Package: oci8 +Package: *General Issues -Assigned To: +Assigned To: ashnazg
 [2016-10-13 16:13 UTC]
(thought I was logging in, not assigning myself to this old bug... now it won't let me unassign it)
 [2016-10-13 16:20 UTC]
-Package: *General Issues +Package: OCI8 related
 [2016-10-13 16:20 UTC]
(trying to set this back to OCI8, as well as unassign myself... but even though my password logs me in ok, it keeps saying "wrong password" when I try to edit this ticket)
 [2016-10-13 16:25 UTC]
-Assigned To: ashnazg +Assigned To: nikic
 [2016-10-13 16:25 UTC]
Looks like it's not possible to unassign in this state :)
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 24 12:01:28 2024 UTC