Bug #70700 [Com]: LOB read loop ends early for multibyte strings

From: Date: Mon, 12 Oct 2015 20:26:40 +0000
Subject: Bug #70700 [Com]: LOB read loop ends early for multibyte strings
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196567@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70700&edit=1

 ID:                 70700
 Comment by:         ashnazg@php.net
 Reported by:        ashnazg@php.net
 Summary:            LOB read loop ends early for multibyte strings
 Status:             Open
 Type:               Bug
 Package:            OCI8 related
 Operating System:   RHEL6, Win7
 PHP Version:        5.5.30
 Block user comment: N
 Private report:     N

 New Comment:

PHPT test for this bug is in PR #1569 (https://github.com/php/php-src/pull/1569)


Previous Comments:
------------------------------------------------------------------------
[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


Thread (11 messages)

« previous php.bugs (#196567) next »