OCI_G(in_call)) {
/* Remove the hash entry if present */
- zvp = zend_hash_find(&EG(persistent_list), connection->hash_key);
- le = Z_RES_P(zvp); /* PHPNG TODO check for null zvp */
- if (le != NULL && le->type == le_pconnection && le->ptr == connection) {
- zend_hash_del(&EG(persistent_list), connection->hash_key);
- }
- else {
- php_oci_connection_close(connection);
- OCI_G(num_persistent)--;
+ if (connection->hash_key) {
+ zvp = zend_hash_find(&EG(persistent_list), connection->hash_key);
+ le = zvp ? Z_RES_P(zvp) : NULL; /* PHPNG TODO check for null zvp */
+ if (le != NULL && le->type == le_pconnection && le->ptr == connection) {
+ zend_hash_del(&EG(persistent_list), connection->hash_key);
+ }
+ else {
+ php_oci_connection_close(connection);
+ OCI_G(num_persistent)--;
+ }
}
#ifdef HAVE_OCI8_DTRACE
efree(define->name);
define->name = NULL;
}
+
+ efree(define);
}
/* }}} */
if (bind->array.indicators) {
efree(bind->array.indicators);
}
+
efree(bind);
/*zval_ptr_dtor(&bind->zval); */
}
zend_list_close(column->stmtid);
}
- if (column->is_descr) {
+ if (column->descid) {
zend_list_close(column->descid);
}
le = Z_RES_P(zvp);
found = 1;
if (le->type == le_index_ptr) {
- int type, link;
void *ptr;
ptr = le->ptr; /* PHPNG TODO */
if (connection->is_open) {
/* found an open connection. now ping it */
if (connection->is_persistent) {
- int rsrc_type;
/* Check connection liveness in the following order:
* 1) always check OCI_ATTR_SERVER_STATUS
connection->used_this_request = 1;
tmp = (php_oci_connection *)connection->id->ptr;
- if (tmp != NULL && rsrc_type == le_pconnection && tmp->hash_key->len == hashed_details.s->len &&
+ if (tmp != NULL && tmp->hash_key->len == hashed_details.s->len &&
memcmp(tmp->hash_key->val, hashed_details.s->val, tmp->hash_key->len) == 0 && ++GC_REFCOUNT(connection->id) == SUCCESS) {
/* do nothing */
} else {
* if ping fails
*/
if (persistent){
- int rsrc_type;
connection->is_open = 0;
connection->used_this_request = 1;
/* We have to do a hash_del but need to preserve the resource if there is a positive
* refcount. Set the data pointer in the list entry to NULL
*/
- if (connection == connection->id->ptr && rsrc_type == le_pconnection) {
+ if (connection == connection->id->ptr) {
le->ptr = NULL;
}
* (like env) on the session pool
*/
php_oci_spool_close(connection->private_spool);
+ connection->private_spool = NULL;
}
if (connection->hash_key) {
pefree(connection->hash_key, connection->is_persistent);
+ connection->hash_key = NULL;
}
#ifdef HAVE_OCI8_DTRACE
if (connection->client_id) {
pefree(connection->client_id, connection->is_persistent);
+ connection->client_id = NULL;
}
#endif /* HAVE_OCI8_DTRACE */
pefree(connection, connection->is_persistent);
} else if (column->is_descr) {
if (column->data_type != SQLT_RDD) {
- int rsrc_type;
/* reset descriptor's length */
descriptor = (php_oci_descriptor *) column->descid->ptr;
- if (!descriptor || rsrc_type != le_descriptor) {
+ if (!descriptor) {
php_error_docref(NULL, E_WARNING, "Unable to find LOB descriptor #%d", column->descid);
return 1;
}
{
smart_str spool_hashed_details = {0};
php_oci_spool *session_pool = NULL;
- zend_resource spool_le = {0};
+ zend_resource spool_le = {{0}};
zend_resource *spool_out_le = NULL;
zend_bool iserror = 0;
zval *spool_out_zv = NULL;
size_t name_len;
zend_long type = 0;
php_oci_statement *statement;
- php_oci_define *define, *tmp_define;
+ php_oci_define *define;
zend_string *zvtmp;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rsz/|l", &stmt, &name, &name_len, &var, &type) == FAILURE) {
/* if (zend_hash_add(statement->defines, name, name_len, define, sizeof(php_oci_define), (void **)&tmp_define) == SUCCESS) { */
zvtmp = zend_string_init(name, name_len, 0);
- if ((tmp_define = zend_hash_add_new_ptr(statement->defines, zvtmp, define)) != NULL) {
- efree(define);
+ if ((define = zend_hash_add_new_ptr(statement->defines, zvtmp, define)) != NULL) {
zend_string_release(zvtmp);
- define = tmp_define;
} else {
efree(define);
zend_string_release(zvtmp);
define->name = (text*) estrndup(name, name_len);
define->name_len = name_len;
define->type = type;
- memmove(&define->zval, var, sizeof(zval));
- Z_ADDREF_P(var);
+ /* convert_to_string(var); */
+ ZVAL_COPY(&define->zval, var);
RETURN_TRUE;
}
Parse a SQL or PL/SQL statement and return a statement resource */
PHP_FUNCTION(oci_parse)
{
+ zval *z_statement;
zval *z_connection;
php_oci_connection *connection;
php_oci_statement *statement;
statement = php_oci_statement_create(connection, query, query_len);
if (statement) {
+ GC_REFCOUNT(statement->id)++;
RETURN_RES(statement->id);
}
RETURN_FALSE;
statement2->has_descr = 0;
statement2->stmttype = 0;
- Z_ADDREF_P(statement->id);
- Z_ADDREF_P(statement2->connection->id);
+ GC_REFCOUNT(statement->id)++;
+ GC_REFCOUNT(statement2->connection->id)++;
php_oci_statement_set_prefetch(statement2, statement->prefetch_count);
/* dvoid *php_oci_collection = NULL; */
OCIStmt *oci_stmt = NULL;
dvoid *bind_data = NULL;
- php_oci_bind bind, *old_bind, *bindp;
+ php_oci_bind *old_bind, *bindp;
int mode = OCI_DATA_AT_EXEC;
sb4 value_sz = -1;
sword errstatus;
bindp->parent_statement = statement;
ZVAL_COPY(&bindp->zval, var);
bindp->type = type;
- Z_TRY_ADDREF_P(var);
PHP_OCI_CALL_RETURN(errstatus,
OCIBindByName,
convert_to_string(val);
zval_dtor(val);
-#if 0
+ {
+ char *p = ecalloc(1, PHP_OCI_PIECE_SIZE);
+ ZVAL_STRINGL(val, p, PHP_OCI_PIECE_SIZE);
+ efree(p);
+ }
+#if 0
Z_STRLEN_P(val) = PHP_OCI_PIECE_SIZE; /* 64K-1 is max XXX */
- Z_STRVAL_P(val) = ecalloc(1, Z_STRLEN_P(phpbind->zval) + 1);
+ Z_STRVAL_P(val) = ecalloc(1, Z_STRLEN_P(val) + 1);
/* XXX is this right? */
-#endif
ZVAL_STRINGL(val, NULL, Z_STRLEN(phpbind->zval) + 1);
+#endif
/* XXX we assume that zend-zval len has 4 bytes */
*alenpp = (ub4*) &Z_STRLEN(phpbind->zval);
bindp->array.type = type;
bindp->indicator = 0; /* not used for array binds */
bindp->type = 0; /* not used for array binds */
-
Z_ADDREF_P(var);
PHP_OCI_CALL_RETURN(errstatus,