[PECL-CVS] [pecl-database-pdo_oci] pdo_oci_blob_fetchall_fix: Do not create new lobs, when the lob is temporary + update bug57702.phpt test
[email protected] (Sharad Chandran R) Wed, 7 Jan 2026 06:27:41 +0000
| Newsgroups | php.pecl.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: Sharad Chandran R (sharadraju)
Date: 2026-01-07T11:50:35+05:30
Commit: https://github.com/php/pecl-database-pdo_oci/commit/a4adfd2513b13e7c5237f17ee3317951186f2c4e
Raw diff: https://github.com/php/pecl-database-pdo_oci/commit/a4adfd2513b13e7c5237f17ee3317951186f2c4e.diff
Do not create new lobs, when the lob is temporary + update bug57702.phpt test
Changed paths:
M oci_statement.c
M tests/bug57702.phpt
Diff:
diff --git a/oci_statement.c b/oci_statement.c
index 5f8f062..0522b38 100644
--- a/oci_statement.c
+++ b/oci_statement.c
@@ -797,6 +797,19 @@ static int oci_stmt_get_col(pdo_stmt_t *stmt, int colno, zval *result, enum pdo_
if (C->dtype == SQLT_BLOB || C->dtype == SQLT_CLOB) {
if (C->data) {
+ OCILobLocator *new_lob;
+ boolean isTempLOB;
+ OCILobIsTemporary(S->H->env, S->err, (OCILobLocator*)C->data, &isTempLOB);
+ if (!isTempLOB &&
+ OCIDescriptorAlloc(S->H->env, (dvoid**)&new_lob, OCI_DTYPE_LOB, 0, NULL) == OCI_SUCCESS) {
+ if (OCILobLocatorAssign(S->H->svc, S->err, (OCILobLocator*)C->data, &new_lob) == OCI_SUCCESS) {
+ php_stream *stream = oci_create_lob_stream(stmt, new_lob);
+ OCILobOpen(S->H->svc, S->err, new_lob, OCI_LOB_READONLY);
+ php_stream_to_zval(stream, result);
+ return 1;
+ }
+ OCIDescriptorFree(new_lob, OCI_DTYPE_LOB);
+ }
php_stream *stream = oci_create_lob_stream(stmt, (OCILobLocator*)C->data);
OCILobOpen(S->H->svc, S->err, (OCILobLocator*)C->data, OCI_LOB_READONLY);
php_stream_to_zval(stream, result);
diff --git a/tests/bug57702.phpt b/tests/bug57702.phpt
index b635a2c..3163c72 100644
--- a/tests/bug57702.phpt
+++ b/tests/bug57702.phpt
@@ -148,7 +148,7 @@ print "done\n";
?>
--CLEAN--
<?php
-require(getenv('PDO_TEST_DIR').'/pdo_test.inc');
+require_once(getenv('PDO_TEST_DIR').'/pdo_test.inc');
$db = PDOTest::test_factory(getenv('PDO_OCI_TEST_DIR').'/common.phpt');
$db->exec("begin
execute immediate 'drop table test57702';
@@ -184,8 +184,8 @@ string(11) "row 2 col 1"
string(11) "row 2 col 2"
Fifth Query
-string(11) "row 2 col 1"
-string(11) "row 2 col 2"
+string(11) "row 1 col 1"
+string(11) "row 1 col 2"
string(11) "row 2 col 1"
string(11) "row 2 col 2"