Edit report at https://bugs.php.net/bug.php?id=70700&edit=1
ID: 70700
Updated by: sixd@php.net
Reported by: ashnazg@php.net
Summary: LOB read loop ends early for multibyte strings
Status: Feedback
Type: Bug
Package: OCI8 related
Operating System: RHEL6, Win7
PHP Version: 5.5.30
Assigned To: sixd
Block user comment: N
Private report: N
New Comment:
What's the client NLS_LANG?
Neither OCI8 or PDO_OCI support NCHAR / NCLOB.
Previous Comments:
------------------------------------------------------------------------
[2015-10-13 15:05:25] ashnazg@php.net
My environments:
RHEL6:
- PHP 5.5.24
- oci8 => 1.4.10
- Oracle Run-time Client Library Version => 11.2.0.3.0
- Oracle Instant Client Version => 12.1
- Temporary Lob support => enabled
Win7:
- PHP 5.5.11
- oci8 => 1.4.10
- Oracle Run-time Client Library Version => 11.2.0.2.0
- Oracle Instant Client Version => 11.2
- Temporary Lob support => enabled
Database:
NLS_LANGUAGE AMERICAN
NLS_CHARACTERSET AL32UTF8
NLS_NCHAR_CHARACTERSET AL16UTF16
NLS_LENGTH_SEMANTICS CHAR
I don't run these multibyte CLOB tests against my older database that uses
WE8MSWIN1252/AL16UTF16, as I've read that PDO OCI doesn't have NCLOB support implemented
(that only affects my OCI8 testing because it's a DBAL/ORM system, and thus I'm trying to
keep the 'available features' matched between OCI8 and PDO OCI).
------------------------------------------------------------------------
[2015-10-13 02:05:43] sixd@php.net
Thanks for the testcase.
Can you give details of your environment - versions, NLS settings etc?
The PDO_OCI and OCI8 code bases are different so the SO issue may have a different cause or
solutions.
------------------------------------------------------------------------
[2015-10-12 20:26:40] ashnazg@php.net
PHPT test for this bug is in PR #1569 (https://github.com/php/php-src/pull/1569)
------------------------------------------------------------------------
[2015-10-12 19:31:20] ashnazg@php.net
Note, it seems at least a little plausible in my mind that #60994 might be related to this bug, as
in the bug condition here might be the root cause of the bug behavior on #60994. See http://stackoverflow.com/questions/33026617/pdo-oci-truncates-large-multibyte-clobs
for my rationale on that thought.
------------------------------------------------------------------------
[2015-10-12 19:29:36] ashnazg@php.net
Description:
------------
When using the "while !$lob->eof() { $lob->read($chunk); fwrite($chunk) }" loop to
read the contents of a long CLOB that contains only single-byte characters, everything works fine
(can get a 10,000,000 char clob no problem).
However, if the CLOB contains mutibyte characters, it seems as though the size of the first
LOB->read() call is as far as the loop will go. Thus, reading the LOB in chunks does not
succeed, though no errors are given.
A workaround is to use LOB->size() to determine the full size of the CLOB, and then do one
LOB->read() on a larger size chunk (thus getting the entire CLOB in one single, huge read). I
have to guess this is hard on memory usage when large CLOBs are in play, and is thus not a desirable
workaround.
Test script:
---------------
(will provide a PHPT in a PR)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70700&edit=1