com php-src: PHP 7 OCI8: fix bug57702.phpt regression: ext/pdo_oci/oci_statement.c
| From: | Christopher Jones | Date: | Mon, 13 Jul 2015 22:39:59 +0000 |
| Subject: | com php-src: PHP 7 OCI8: fix bug57702.phpt regression: ext/pdo_oci/oci_statement.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-87973@lists.php.net to get a copy of this message | ||
Commit: c20f00f76595ecf70d030ce13d54d3d1f6f9bd2b
Author: Christopher Jones <christopher.jones@oracle.com> Tue, 14 Jul 2015 08:39:59
+1000
Parents: 9db46a392ba555b362378b21595cce5bf3e98fc0
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c20f00f76595ecf70d030ce13d54d3d1f6f9bd2b
Log:
PHP 7 OCI8: fix bug57702.phpt regression
Bugs:
https://bugs.php.net/57702
Changed paths:
M ext/pdo_oci/oci_statement.c
Diff:
diff --git a/ext/pdo_oci/oci_statement.c b/ext/pdo_oci/oci_statement.c
index 868e69f..9c2e149 100644
--- a/ext/pdo_oci/oci_statement.c
+++ b/ext/pdo_oci/oci_statement.c
@@ -51,7 +51,7 @@
} \
} while(0)
-static php_stream *oci_create_lob_stream(pdo_stmt_t *stmt, OCILobLocator *lob);
+static php_stream *oci_create_lob_stream(zval *dbh, pdo_stmt_t *stmt, OCILobLocator *lob);
static int oci_stmt_dtor(pdo_stmt_t *stmt) /* {{{ */
{
@@ -377,7 +377,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, (OCILobLocator*)P->thing);
+ stm = oci_create_lob_stream(&stmt->database_object_handle, stmt,
(OCILobLocator*)P->thing);
if (stm) {
OCILobOpen(S->H->svc, S->err, (OCILobLocator*)P->thing, OCI_LOB_READWRITE);
php_stream_to_zval(stm, parameter);
@@ -614,6 +614,7 @@ struct _oci_lob_env {
typedef struct _oci_lob_env oci_lob_env;
struct oci_lob_self {
+ zval dbh;
pdo_stmt_t *stmt;
pdo_oci_stmt *S;
OCILobLocator *lob;
@@ -666,10 +667,14 @@ static size_t oci_blob_read(php_stream *stream, char *buf, size_t count)
static int oci_blob_close(php_stream *stream, int close_handle)
{
struct oci_lob_self *self = (struct oci_lob_self *)stream->abstract;
- /* pdo_stmt_t *stmt = self->stmt; */
+ pdo_stmt_t *stmt = self->stmt;
if (close_handle) {
+ zend_object *obj = &stmt->std;
+
OCILobClose(self->E->svc, self->E->err, self->lob);
+ zval_ptr_dtor(&self->dbh);
+ GC_REFCOUNT(obj)--;
efree(self->E);
efree(self);
}
@@ -709,10 +714,12 @@ static php_stream_ops oci_blob_stream_ops = {
NULL
};
-static php_stream *oci_create_lob_stream(pdo_stmt_t *stmt, OCILobLocator *lob)
+static php_stream *oci_create_lob_stream(zval *dbh, pdo_stmt_t *stmt, OCILobLocator *lob)
{
php_stream *stm;
struct oci_lob_self *self = ecalloc(1, sizeof(*self));
+
+ ZVAL_COPY_VALUE(&self->dbh, dbh);
self->lob = lob;
self->offset = 1; /* 1-based */
self->stmt = stmt;
@@ -724,6 +731,10 @@ static php_stream *oci_create_lob_stream(pdo_stmt_t *stmt, OCILobLocator *lob)
stm = php_stream_alloc(&oci_blob_stream_ops, self, 0, "r+b");
if (stm) {
+ zend_object *obj;
+ obj = &stmt->std;
+ Z_ADDREF(self->dbh);
+ GC_REFCOUNT(obj)++;
return stm;
}
@@ -747,7 +758,7 @@ static int oci_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, size_t *len
if (C->dtype == SQLT_BLOB || C->dtype == SQLT_CLOB) {
if (C->data) {
- *ptr = (char*)oci_create_lob_stream(stmt, (OCILobLocator*)C->data);
+ *ptr = (char*)oci_create_lob_stream(&stmt->database_object_handle, stmt,
(OCILobLocator*)C->data);
OCILobOpen(S->H->svc, S->err, (OCILobLocator*)C->data, OCI_LOB_READONLY);
}
*len = (size_t) 0;