#37706 [Bgs->Opn]: oci8 maps to same descriptor when fetching multiple rows with lobs
| From: | crescentfreshpot at yahoo dot com | Date: | Tue, 06 Jun 2006 12:45:11 +0000 |
| Subject: | #37706 [Bgs->Opn]: oci8 maps to same descriptor when fetching multiple rows with lobs | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969373192@lists.php.net to get a copy of this message | ||
ID: 37706
User updated by: crescentfreshpot at yahoo dot com
-Summary: OCI-Lob read advances wrong internal pointer
Reported By: crescentfreshpot at yahoo dot com
-Status: Bogus
+Status: Open
-Bug Type: OCI8 related
+Bug Type: Documentation problem
Operating System: Win XP
PHP Version: 5CVS-2006-06-05 (snap)
New Comment:
Well it was not obvious that all my fetched rows would all point to the
same (last fetched) lob descriptor in underlying memory, so can we say
this at least needs to be documented?
Previous Comments:
------------------------------------------------------------------------
[2006-06-06 06:36:54] tony2001@php.net
I don't see any way to bind several variables to one placeholder/column
in OCI API, so we reuse the same descriptor on each iteration.
------------------------------------------------------------------------
[2006-06-06 00:29:57] crescentfreshpot at yahoo dot com
Three things:
a) AFAIK php has no problems with having multiple stream handles open,
so does your "it's expected" comment refer to limitations in the oci
library itself?
b) is this why there is no way to stop oci_fetch_all from automatically
fetching my lob data and instead return them to me as separate,
*individual* streams?
b) Is there no workaround for this? Something along the lines of
php_stream_copy_to_stream to save a reference to an oci stream as it's
fetched say in a fetchAll scenario?
------------------------------------------------------------------------
[2006-06-05 22:21:38] tony2001@php.net
$row1[0] and $row2[0] are different variables pointing to the same LOB
descriptor.
This is how it works and it's expected.
------------------------------------------------------------------------
[2006-06-05 22:18:18] crescentfreshpot at yahoo dot com
Description:
------------
I think OCI-Lob::read() is reading from the wrong handle when called
multiple times on different lob descriptors.
Reproduce code:
---------------
sql:
create table lobtest (lobdata clob);
insert into lobtest (lobdata) values('data data data data data data
data data');
insert into lobtest (lobdata) values('data2 data2 data2 data2 data2
data2 data2 data2');
commit;
php:
$conn = oci_connect('xxx','yyy','zzz');
$stmt = oci_parse($conn, "select lobdata from lobtest");
oci_execute($stmt);
$row1 = oci_fetch_array($stmt, OCI_NUM);
$row2 = oci_fetch_array($stmt, OCI_NUM);
var_dump($row1[0]->tell());
var_dump($row1[0]->read(8192));
var_dump($row2[0]->tell());
var_dump($row2[0]->read(8192));
Expected result:
----------------
int(0)
string(39) "data data data data data data data data"
int(0)
string(0) "data2 data2 data2 data2 data2 data2 data2 data2"
Actual result:
--------------
int(0)
string(39) "data data data data data data data data"
int(39)
string(0) ""
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37706&edit=1