Skip to content

Commit 526b589

Browse files
committed
Do not create new lobs, when the lob is temporary + update bug57702.phpt test
1 parent 3399a93 commit 526b589

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

oci_statement.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,19 @@ static int oci_stmt_get_col(pdo_stmt_t *stmt, int colno, zval *result, enum pdo_
797797

798798
if (C->dtype == SQLT_BLOB || C->dtype == SQLT_CLOB) {
799799
if (C->data) {
800+
OCILobLocator *new_lob;
801+
boolean isTempLOB;
802+
OCILobIsTemporary(S->H->env, S->err, (OCILobLocator*)C->data, &isTempLOB);
803+
if (!isTempLOB &&
804+
OCIDescriptorAlloc(S->H->env, (dvoid**)&new_lob, OCI_DTYPE_LOB, 0, NULL) == OCI_SUCCESS) {
805+
if (OCILobLocatorAssign(S->H->svc, S->err, (OCILobLocator*)C->data, &new_lob) == OCI_SUCCESS) {
806+
php_stream *stream = oci_create_lob_stream(stmt, new_lob);
807+
OCILobOpen(S->H->svc, S->err, new_lob, OCI_LOB_READONLY);
808+
php_stream_to_zval(stream, result);
809+
return 1;
810+
}
811+
OCIDescriptorFree(new_lob, OCI_DTYPE_LOB);
812+
}
800813
php_stream *stream = oci_create_lob_stream(stmt, (OCILobLocator*)C->data);
801814
OCILobOpen(S->H->svc, S->err, (OCILobLocator*)C->data, OCI_LOB_READONLY);
802815
php_stream_to_zval(stream, result);

tests/bug57702.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ string(11) "row 2 col 1"
184184
string(11) "row 2 col 2"
185185

186186
Fifth Query
187-
string(11) "row 2 col 1"
188-
string(11) "row 2 col 2"
187+
string(11) "row 1 col 1"
188+
string(11) "row 1 col 2"
189189
string(11) "row 2 col 1"
190190
string(11) "row 2 col 2"
191191

0 commit comments

Comments
 (0)