Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions oci_statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
} \
} while(0)

static php_stream *oci_create_lob_stream(zval *dbh, pdo_stmt_t *stmt, OCILobLocator *lob);
static php_stream *oci_create_lob_stream(pdo_stmt_t *stmt, OCILobLocator *lob);

#define OCI_TEMPLOB_CLOSE(envhp, svchp, errhp, lob) \
do \
Expand Down Expand Up @@ -98,10 +98,13 @@ static int oci_stmt_dtor(pdo_stmt_t *stmt) /* {{{ */
S->einfo.errmsg = NULL;
}

/* TODO: There's php_pdo_stmt_valid_db_obj_handle in PHP-8.5-dev that does these checks. */
#if PHP_API_VERSION < 20240925
bool server_obj_usable = !Z_ISUNDEF(stmt->database_object_handle)
&& IS_OBJ_VALID(EG(objects_store).object_buckets[Z_OBJ_HANDLE(stmt->database_object_handle)])
&& !(OBJ_FLAGS(Z_OBJ(stmt->database_object_handle)) & IS_OBJ_FREE_CALLED);
#else
bool server_obj_usable = php_pdo_stmt_valid_db_obj_handle(stmt);
#endif

if (S->cols) {
for (i = 0; i < stmt->column_count; i++) {
Expand Down Expand Up @@ -393,7 +396,7 @@ static int oci_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *pa
* wanted to bind a lob locator into it from the query
* */

stm = oci_create_lob_stream(&stmt->database_object_handle, stmt, (OCILobLocator*)P->thing);
stm = oci_create_lob_stream(stmt, (OCILobLocator*)P->thing);
if (stm) {
OCILobOpen(S->H->svc, S->err, (OCILobLocator*)P->thing, OCI_LOB_READWRITE);
php_stream_to_zval(stm, parameter);
Expand Down Expand Up @@ -711,12 +714,16 @@ static const php_stream_ops oci_blob_stream_ops = {
NULL
};

static php_stream *oci_create_lob_stream(zval *dbh, pdo_stmt_t *stmt, OCILobLocator *lob)
static php_stream *oci_create_lob_stream(pdo_stmt_t *stmt, OCILobLocator *lob)
{
php_stream *stm;
struct oci_lob_self *self = ecalloc(1, sizeof(*self));

ZVAL_COPY_VALUE(&self->dbh, dbh);
#if PHP_API_VERSION < 20240925
ZVAL_COPY_VALUE(&self->dbh, &stmt->database_object_handle);
#else
ZVAL_OBJ(&self->dbh, stmt->database_object_handle);
#endif
self->lob = lob;
self->offset = 1; /* 1-based */
self->stmt = stmt;
Expand Down Expand Up @@ -756,7 +763,7 @@ 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) {
php_stream *stream = oci_create_lob_stream(&stmt->database_object_handle, stmt, (OCILobLocator*)C->data);
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);
return 1;
Expand Down