Reputation: 6688
When PDO OCI returns my row via PDO::fetch(), my CLOB column is already a PHP stream. In cases of long CLOBs with multibyte UTF-8 characters in them, when I read this stream, it is truncated.
Examples
Another:
I can see similar results using a three-byte character ("の"), where the maximum length that works correctly is 2730 chars (8192 bytes).
I had this same issue using raw OCI, where I was using a read loop on the LOB object itself:
while !lob->eof() then lob->read(8192)
I was able to work around the issue by getting the full size of the entire CLOB (lob->size()
) and using that as my LOB read size, thus pulling it all in one big read.
I see no way to do this in PDO OCI.
My hunch is that internal code in PDO OCI is probably doing the same kind of read loop to turn the LOB into a PHP stream.
It seems that doing chunked reads of a LOB >8192bytes might be broken in raw OCI, and maybe PDO OCI has the same bug. In some of my testing, my intuition thinks that perhaps the read is ending in the middle of a multibyte character, and silently fails if it tries to next resume on what it sees as an invalid UTF-8 byte.
Has anyone encountered such behavior? Any workaround for PDO OCI?
My environments:
- PHP 5.5.24 on RHEL6, oci8 v1.4.10
- PHP 5.5.11 on Win7, oci8 v1.4.10
Upvotes: 3
Views: 820
Reputation: 6688
Turns out this may indeed be a PDO_OCI bug: "the base bug needs to be fixed (no ETA on this yet)" (https://github.com/php/php-src/pull/1566, referring to (https://bugs.php.net/bug.php?id=60994).
Upvotes: 2