summaryrefslogtreecommitdiff
path: root/ext/oci8
diff options
context:
space:
mode:
authorChristopher Jones <christopher.jones@oracle.com>2015-07-16 13:06:35 +1000
committerChristopher Jones <christopher.jones@oracle.com>2015-07-16 13:06:35 +1000
commite6d9061e8558f4a370862b32cace46b8e8ce4f02 (patch)
tree30354cc2eb0471b88c6db99fcc3ca6ccfaa14ecf /ext/oci8
parent0af07333520f65def3a72f31effa38c907e962f9 (diff)
downloadphp-git-e6d9061e8558f4a370862b32cace46b8e8ce4f02.tar.gz
More OCI8 diff fixes (Rajendra)
Diffstat (limited to 'ext/oci8')
-rw-r--r--ext/oci8/oci8.c7
-rw-r--r--ext/oci8/oci8_interface.c86
-rw-r--r--ext/oci8/oci8_statement.c80
-rw-r--r--ext/oci8/php_oci8_int.h4
4 files changed, 95 insertions, 82 deletions
diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c
index e3ec34f578..2c65ea94f9 100644
--- a/ext/oci8/oci8.c
+++ b/ext/oci8/oci8.c
@@ -1536,7 +1536,7 @@ void php_oci_define_hash_dtor(zval *data)
{
php_oci_define *define = (php_oci_define *) Z_PTR_P(data);
- zval_ptr_dtor(&define->zval);
+ zval_ptr_dtor(define->zval);
if (define->name) {
efree(define->name);
@@ -1568,7 +1568,7 @@ void php_oci_bind_hash_dtor(zval *data)
}
efree(bind);
- /*zval_ptr_dtor(&bind->zval); */
+ zval_ptr_dtor(bind->zval);
}
/* }}} */
@@ -1708,6 +1708,7 @@ sb4 php_oci_fetch_errmsg(OCIError *error_handle, text **error_buf)
text err_buf[PHP_OCI_ERRBUF_LEN];
memset(err_buf, 0, sizeof(err_buf));
+ *error_buf = (text *)0;
PHP_OCI_CALL(OCIErrorGet, (error_handle, (ub4)1, NULL, &error_code, err_buf, (ub4)PHP_OCI_ERRBUF_LEN, (ub4)OCI_HTYPE_ERROR));
if (error_code) {
@@ -2774,7 +2775,7 @@ void php_oci_fetch_row (INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_arg
}
if (fetch_mode & PHP_OCI_ASSOC) {
if (fetch_mode & PHP_OCI_NUM) {
- Z_ADDREF(element);
+ Z_TRY_ADDREF_P(&element);
}
add_assoc_zval(return_value, column->name, &element);
}
diff --git a/ext/oci8/oci8_interface.c b/ext/oci8/oci8_interface.c
index ce6ee0a3aa..441dd448a5 100644
--- a/ext/oci8/oci8_interface.c
+++ b/ext/oci8/oci8_interface.c
@@ -72,6 +72,9 @@ PHP_FUNCTION(oci_define_by_name)
ALLOC_HASHTABLE(statement->defines);
zend_hash_init(statement->defines, 13, NULL, php_oci_define_hash_dtor, 0);
}
+ else if (zend_hash_str_exists(statement->defines, (const char *)name, name_len)) {
+ RETURN_FALSE;
+ }
define = ecalloc(1,sizeof(php_oci_define));
@@ -88,8 +91,8 @@ PHP_FUNCTION(oci_define_by_name)
define->name = (text*) estrndup(name, name_len);
define->name_len = name_len;
define->type = type;
- /* convert_to_string(var); */
- ZVAL_COPY(&define->zval, var);
+ define->zval = var;
+ Z_TRY_ADDREF_P(define->zval);
RETURN_TRUE;
}
@@ -173,7 +176,7 @@ PHP_FUNCTION(oci_free_descriptor)
}
}
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property");
RETURN_FALSE;
}
@@ -207,7 +210,7 @@ PHP_FUNCTION(oci_lob_save)
}
}
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property");
RETURN_FALSE;
}
@@ -262,7 +265,7 @@ PHP_FUNCTION(oci_lob_import)
}
#endif
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property");
RETURN_FALSE;
}
@@ -291,7 +294,7 @@ PHP_FUNCTION(oci_lob_load)
}
}
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property");
RETURN_FALSE;
}
@@ -331,7 +334,7 @@ PHP_FUNCTION(oci_lob_read)
}
}
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property");
RETURN_FALSE;
}
@@ -369,7 +372,7 @@ PHP_FUNCTION(oci_lob_eof)
}
}
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property");
RETURN_FALSE;
}
@@ -398,7 +401,7 @@ PHP_FUNCTION(oci_lob_tell)
}
}
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property");
RETURN_FALSE;
}
@@ -422,7 +425,7 @@ PHP_FUNCTION(oci_lob_rewind)
}
}
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property");
RETURN_FALSE;
}
@@ -455,7 +458,7 @@ PHP_FUNCTION(oci_lob_seek)
}
}
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property");
RETURN_FALSE;
}
@@ -501,7 +504,7 @@ PHP_FUNCTION(oci_lob_size)
}
}
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property");
RETURN_FALSE;
}
@@ -545,7 +548,7 @@ PHP_FUNCTION(oci_lob_write)
}
}
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property");
RETURN_FALSE;
}
@@ -581,12 +584,12 @@ PHP_FUNCTION(oci_lob_append)
}
}
- if ((tmp_dest = zend_hash_str_find(Z_OBJPROP_P(z_descriptor_dest), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp_dest = zend_hash_str_find(Z_OBJPROP_P(z_descriptor_dest), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property. The first argument should be valid descriptor object");
RETURN_FALSE;
}
- if ((tmp_from = zend_hash_str_find(Z_OBJPROP_P(z_descriptor_from), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp_from = zend_hash_str_find(Z_OBJPROP_P(z_descriptor_from), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property. The second argument should be valid descriptor object");
RETURN_FALSE;
}
@@ -622,7 +625,7 @@ PHP_FUNCTION(oci_lob_truncate)
}
}
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property");
RETURN_FALSE;
}
@@ -682,7 +685,7 @@ PHP_FUNCTION(oci_lob_erase)
}
}
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property");
RETURN_FALSE;
}
@@ -715,7 +718,7 @@ PHP_FUNCTION(oci_lob_flush)
}
}
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property");
RETURN_FALSE;
}
@@ -753,7 +756,7 @@ PHP_FUNCTION(ocisetbufferinglob)
}
}
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property");
RETURN_FALSE;
}
@@ -780,7 +783,7 @@ PHP_FUNCTION(ocigetbufferinglob)
}
}
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property");
RETURN_FALSE;
}
@@ -806,12 +809,12 @@ PHP_FUNCTION(oci_lob_copy)
return;
}
- if ((tmp_dest = zend_hash_str_find(Z_OBJPROP_P(z_descriptor_dest), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp_dest = zend_hash_str_find(Z_OBJPROP_P(z_descriptor_dest), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property. The first argument should be valid descriptor object");
RETURN_FALSE;
}
- if ((tmp_from = zend_hash_str_find(Z_OBJPROP_P(z_descriptor_from), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp_from = zend_hash_str_find(Z_OBJPROP_P(z_descriptor_from), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property. The second argument should be valid descriptor object");
RETURN_FALSE;
}
@@ -848,12 +851,12 @@ PHP_FUNCTION(oci_lob_is_equal)
return;
}
- if ((tmp_first = zend_hash_str_find(Z_OBJPROP_P(z_descriptor_first), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp_first = zend_hash_str_find(Z_OBJPROP_P(z_descriptor_first), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property. The first argument should be valid descriptor object");
RETURN_FALSE;
}
- if ((tmp_second = zend_hash_str_find(Z_OBJPROP_P(z_descriptor_second), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp_second = zend_hash_str_find(Z_OBJPROP_P(z_descriptor_second), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property. The second argument should be valid descriptor object");
RETURN_FALSE;
}
@@ -930,7 +933,7 @@ PHP_FUNCTION(oci_lob_export)
}
#endif
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property");
RETURN_FALSE;
}
@@ -1026,7 +1029,7 @@ PHP_FUNCTION(oci_lob_write_temporary)
}
}
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property");
RETURN_FALSE;
}
@@ -1053,7 +1056,7 @@ PHP_FUNCTION(oci_lob_close)
}
}
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property");
RETURN_FALSE;
}
@@ -1434,7 +1437,7 @@ PHP_FUNCTION(oci_fetch_all)
zend_string *zvtmp;
zvtmp = zend_string_init(columns[ i ]->name, columns[ i ]->name_len, 0);
zend_symtable_update(Z_ARRVAL(row), zvtmp, &element);
- zend_string_release(zvtmp);
+ zend_string_release(zvtmp);
}
}
@@ -1465,9 +1468,9 @@ PHP_FUNCTION(oci_fetch_all)
columns[ i ] = php_oci_statement_get_column(statement, i + 1, NULL, 0);
array_init(&tmp);
- zvtmp = zend_string_init(columns[ i ]->name, columns[ i ]->name_len, 0);
+ zvtmp = zend_string_init(columns[ i ]->name, columns[ i ]->name_len, 0);
outarrs[ i ] = zend_symtable_update(Z_ARRVAL_P(array), zvtmp, &tmp);
- zend_string_release(zvtmp);
+ zend_string_release(zvtmp);
}
}
@@ -1667,7 +1670,8 @@ go_out:
add_assoc_long(return_value, "code", errcode);
/* TODO: avoid reallocation ??? */
add_assoc_string(return_value, "message", (char*) errbuf);
- efree(errbuf);
+ if (errbuf)
+ efree(errbuf);
add_assoc_long(return_value, "offset", error_offset);
add_assoc_string(return_value, "sqltext", sqltext ? (char *) sqltext : "");
} else {
@@ -1697,7 +1701,6 @@ PHP_FUNCTION(oci_num_fields)
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;
@@ -1713,7 +1716,6 @@ PHP_FUNCTION(oci_parse)
statement = php_oci_statement_create(connection, query, query_len);
if (statement) {
- GC_REFCOUNT(statement->id)++;
RETURN_RES(statement->id);
}
RETURN_FALSE;
@@ -2180,7 +2182,7 @@ PHP_FUNCTION(oci_free_collection)
}
}
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_collection), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_collection), "collection", sizeof("collection")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find collection property");
RETURN_FALSE;
}
@@ -2212,7 +2214,7 @@ PHP_FUNCTION(oci_collection_append)
}
}
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_collection), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_collection), "collection", sizeof("collection")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find collection property");
RETURN_FALSE;
}
@@ -2246,7 +2248,7 @@ PHP_FUNCTION(oci_collection_element_get)
}
}
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_collection), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_collection), "collection", sizeof("collection")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find collection property");
RETURN_FALSE;
}
@@ -2279,12 +2281,12 @@ PHP_FUNCTION(oci_collection_assign)
}
}
- if ((tmp_dest = zend_hash_str_find(Z_OBJPROP_P(z_collection_dest), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp_dest = zend_hash_str_find(Z_OBJPROP_P(z_collection_dest), "collection", sizeof("collection")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find collection property. The first argument should be valid collection object");
RETURN_FALSE;
}
- if ((tmp_from = zend_hash_str_find(Z_OBJPROP_P(z_collection_from), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp_from = zend_hash_str_find(Z_OBJPROP_P(z_collection_from), "collection", sizeof("collection")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find collection property. The second argument should be valid collection object");
RETURN_FALSE;
}
@@ -2320,7 +2322,7 @@ PHP_FUNCTION(oci_collection_element_assign)
}
}
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_collection), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_collection), "collection", sizeof("collection")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find collection property");
RETURN_FALSE;
}
@@ -2348,7 +2350,7 @@ PHP_FUNCTION(oci_collection_size)
}
}
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_collection), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_collection), "collection", sizeof("collection")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find collection property");
RETURN_FALSE;
}
@@ -2376,7 +2378,7 @@ PHP_FUNCTION(oci_collection_max)
}
}
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_collection), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_collection), "collection", sizeof("collection")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find collection property");
RETURN_FALSE;
}
@@ -2409,7 +2411,7 @@ PHP_FUNCTION(oci_collection_trim)
}
}
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_collection), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_collection), "collection", sizeof("collection")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find collection property");
RETURN_FALSE;
}
diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c
index b007cce428..d27a728d3c 100644
--- a/ext/oci8/oci8_statement.c
+++ b/ext/oci8/oci8_statement.c
@@ -359,8 +359,8 @@ int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows)
continue;
}
- zval_dtor(&column->define->zval);
- php_oci_column_to_zval(column, &column->define->zval, 0);
+ zval_dtor(column->define->zval);
+ php_oci_column_to_zval(column, column->define->zval, 0);
}
return 0;
@@ -875,17 +875,17 @@ void php_oci_statement_free(php_oci_statement *statement)
if (statement->columns) {
zend_hash_destroy(statement->columns);
- FREE_HASHTABLE(statement->columns);
+ efree(statement->columns);
}
if (statement->binds) {
zend_hash_destroy(statement->binds);
- FREE_HASHTABLE(statement->binds);
+ efree(statement->binds);
}
if (statement->defines) {
zend_hash_destroy(statement->defines);
- FREE_HASHTABLE(statement->defines);
+ efree(statement->defines);
}
if (statement->parent_stmtid) {
@@ -907,7 +907,7 @@ int php_oci_bind_pre_exec(zval *data, void *result)
*(int *)result = 0;
- if (Z_TYPE(bind->zval) == IS_ARRAY) {
+ if (Z_TYPE_P(bind->zval) == IS_ARRAY) {
/* These checks are currently valid for oci_bind_by_name, not
* oci_bind_array_by_name. Also bind->type and
* bind->indicator are not used for oci_bind_array_by_name.
@@ -921,7 +921,7 @@ int php_oci_bind_pre_exec(zval *data, void *result)
case SQLT_CLOB:
case SQLT_BLOB:
case SQLT_RDD:
- if (Z_TYPE(bind->zval) != IS_OBJECT) {
+ if (Z_TYPE_P(bind->zval) != IS_OBJECT) {
php_error_docref(NULL, E_WARNING, "Invalid variable used for bind");
*(int *)result = 1;
}
@@ -937,14 +937,14 @@ int php_oci_bind_pre_exec(zval *data, void *result)
case SQLT_LBI:
case SQLT_BIN:
case SQLT_LNG:
- if (Z_TYPE(bind->zval) == IS_RESOURCE || Z_TYPE(bind->zval) == IS_OBJECT) {
+ if (Z_TYPE_P(bind->zval) == IS_RESOURCE || Z_TYPE_P(bind->zval) == IS_OBJECT) {
php_error_docref(NULL, E_WARNING, "Invalid variable used for bind");
*(int *)result = 1;
}
break;
case SQLT_RSET:
- if (Z_TYPE(bind->zval) != IS_RESOURCE) {
+ if (Z_TYPE_P(bind->zval) != IS_RESOURCE) {
php_error_docref(NULL, E_WARNING, "Invalid variable used for bind");
*(int *)result = 1;
}
@@ -967,27 +967,27 @@ int php_oci_bind_post_exec(zval *data)
sword errstatus;
if (bind->indicator == -1) { /* NULL */
- zval *val = &bind->zval;
+ zval *val = bind->zval;
if (Z_TYPE_P(val) == IS_STRING) {
*Z_STRVAL_P(val) = '\0'; /* XXX avoid warning in debug mode */
}
zval_dtor(val);
ZVAL_NULL(val);
- } else if (Z_TYPE(bind->zval) == IS_STRING
- && Z_STRLEN(bind->zval) > 0
- && Z_STRVAL(bind->zval)[ Z_STRLEN(bind->zval) ] != '\0') {
+ } else if (Z_TYPE_P(bind->zval) == IS_STRING
+ && Z_STRLEN_P(bind->zval) > 0
+ && Z_STRVAL_P(bind->zval)[ Z_STRLEN_P(bind->zval) ] != '\0') {
/* The post- PHP 5.3 feature for "interned" strings disallows
* their reallocation but (i) any IN binds either interned or
* not should already be null terminated and (ii) for OUT
* binds, php_oci_bind_out_callback() should have allocated a
* new string that we can modify here.
*/
- Z_STR(bind->zval) = zend_string_extend(Z_STR(bind->zval), Z_STRLEN(bind->zval)+1, 0);
- Z_STRVAL(bind->zval)[ Z_STRLEN(bind->zval) ] = '\0';
- } else if (Z_TYPE(bind->zval) == IS_ARRAY) {
+ Z_STR_P(bind->zval) = zend_string_extend(Z_STR_P(bind->zval), Z_STRLEN_P(bind->zval)+1, 0);
+ Z_STRVAL_P(bind->zval)[ Z_STRLEN_P(bind->zval) ] = '\0';
+ } else if (Z_TYPE_P(bind->zval) == IS_ARRAY) {
int i;
zval *entry = NULL;
- HashTable *hash = HASH_OF(&bind->zval);
+ HashTable *hash = HASH_OF(bind->zval);
zend_hash_internal_pointer_reset(hash);
@@ -1001,7 +1001,7 @@ int php_oci_bind_post_exec(zval *data)
ZVAL_LONG(entry, ((ub4 *)(bind->array.elements))[i]);
zend_hash_move_forward(hash);
} else {
- add_next_index_long(&bind->zval, ((ub4 *)(bind->array.elements))[i]);
+ add_next_index_long(bind->zval, ((ub4 *)(bind->array.elements))[i]);
}
}
break;
@@ -1012,7 +1012,7 @@ int php_oci_bind_post_exec(zval *data)
ZVAL_DOUBLE(entry, ((double *)(bind->array.elements))[i]);
zend_hash_move_forward(hash);
} else {
- add_next_index_double(&bind->zval, ((double *)(bind->array.elements))[i]);
+ add_next_index_double(bind->zval, ((double *)(bind->array.elements))[i]);
}
}
break;
@@ -1041,10 +1041,10 @@ int php_oci_bind_post_exec(zval *data)
if (errstatus != OCI_SUCCESS) {
connection->errcode = php_oci_error(connection->err, errstatus);
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
- add_next_index_null(&bind->zval);
+ add_next_index_null(bind->zval);
} else {
connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
- add_next_index_stringl(&bind->zval, (char *)buff, buff_len);
+ add_next_index_stringl(bind->zval, (char *)buff, buff_len);
}
}
}
@@ -1064,11 +1064,16 @@ int php_oci_bind_post_exec(zval *data)
ZVAL_STRINGL(entry, (char *)(((text *)bind->array.elements)+i*bind->array.max_length), curr_element_length);
zend_hash_move_forward(hash);
} else {
- add_next_index_stringl(&bind->zval, (char *)(((text *)bind->array.elements)+i*bind->array.max_length), curr_element_length);
+ add_next_index_stringl(bind->zval, (char *)(((text *)bind->array.elements)+i*bind->array.max_length), curr_element_length);
}
}
break;
}
+ } else if ((Z_TYPE_P(bind->zval) == IS_TRUE) || (Z_TYPE_P(bind->zval) == IS_FALSE)) {
+ if (Z_LVAL_P(bind->zval) == 0)
+ ZVAL_BOOL(bind->zval, FALSE);
+ else if (Z_LVAL_P(bind->zval) == 1)
+ ZVAL_BOOL(bind->zval, TRUE);
}
return 0;
@@ -1096,7 +1101,7 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len,
{
zval *tmp;
- if (Z_TYPE_P(var) != IS_OBJECT || (tmp = zend_hash_str_find(Z_OBJPROP_P(var), "collection", sizeof("collection"))) == NULL) {
+ if (Z_TYPE_P(var) != IS_OBJECT || (tmp = zend_hash_str_find(Z_OBJPROP_P(var), "collection", sizeof("collection")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find collection property");
return 1;
}
@@ -1118,7 +1123,7 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len,
{
zval *tmp;
- if (Z_TYPE_P(var) != IS_OBJECT || (tmp = zend_hash_str_find(Z_OBJPROP_P(var), "descriptor", sizeof("descriptor"))) == NULL) {
+ if (Z_TYPE_P(var) != IS_OBJECT || (tmp = zend_hash_str_find(Z_OBJPROP_P(var), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property");
return 1;
}
@@ -1212,10 +1217,12 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len,
if ((old_bind = zend_hash_str_find_ptr(statement->binds, name, name_len)) != NULL) {
bindp = old_bind;
- zval_ptr_dtor(&bindp->zval);
+ if (bindp->zval) {
+ zval_ptr_dtor(bindp->zval);
+ }
} else {
zend_string *zvtmp;
- zvtmp = zend_string_init(name, name_len + 1, 0);
+ zvtmp = zend_string_init(name, name_len, 0);
bindp = (php_oci_bind *) ecalloc(1, sizeof(php_oci_bind));
bindp = zend_hash_update_ptr(statement->binds, zvtmp, bindp);
zend_string_release(zvtmp);
@@ -1224,8 +1231,9 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len,
bindp->descriptor = oci_desc;
bindp->statement = oci_stmt;
bindp->parent_statement = statement;
- ZVAL_COPY(&bindp->zval, var);
+ bindp->zval = var;
bindp->type = type;
+ Z_TRY_ADDREF_P(bindp->zval);
PHP_OCI_CALL_RETURN(errstatus,
OCIBindByName,
@@ -1313,7 +1321,7 @@ sb4 php_oci_bind_in_callback(
php_oci_bind *phpbind;
zval *val;
- if (!(phpbind=(php_oci_bind *)ictxp) || !(val = &phpbind->zval)) {
+ if (!(phpbind=(php_oci_bind *)ictxp) || !(val = phpbind->zval)) {
php_error_docref(NULL, E_WARNING, "Invalid phpbind pointer value");
return OCI_ERROR;
}
@@ -1366,7 +1374,7 @@ sb4 php_oci_bind_out_callback(
zval *val;
sb4 retval = OCI_ERROR;
- if (!(phpbind=(php_oci_bind *)octxp) || !(val = &phpbind->zval)) {
+ if (!(phpbind=(php_oci_bind *)octxp) || !(val = phpbind->zval)) {
php_error_docref(NULL, E_WARNING, "Invalid phpbind pointer value");
return retval;
}
@@ -1393,7 +1401,7 @@ sb4 php_oci_bind_out_callback(
* out-bind as the contents would have been changed for in/out
* binds (Bug #46994).
*/
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(val), "descriptor", sizeof("descriptor"))) == NULL) {
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(val), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find object outbind descriptor property");
return OCI_ERROR;
}
@@ -1423,8 +1431,8 @@ sb4 php_oci_bind_out_callback(
#endif
/* XXX we assume that zend-zval len has 4 bytes */
- *alenpp = (ub4*) &Z_STRLEN(phpbind->zval);
- *bufpp = Z_STRVAL(phpbind->zval);
+ *alenpp = (ub4*) &Z_STRLEN_P(phpbind->zval);
+ *bufpp = Z_STRVAL_P(phpbind->zval);
*piecep = OCI_ONE_PIECE;
*rcodepp = &phpbind->retcode;
*indpp = &phpbind->indicator;
@@ -1584,7 +1592,7 @@ int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, int nam
zend_hash_init(statement->binds, 13, NULL, php_oci_bind_hash_dtor, 0);
}
- zvtmp = zend_string_init(name, name_len + 1, 0);
+ zvtmp = zend_string_init(name, name_len, 0);
bindp = zend_hash_update_ptr(statement->binds, zvtmp, bind);
zend_string_release(zvtmp);
@@ -1592,11 +1600,12 @@ int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, int nam
bindp->statement = NULL;
bindp->parent_statement = statement;
bindp->bind = NULL;
- ZVAL_COPY(&bindp->zval, var);
+ bindp->zval = var;
bindp->array.type = type;
bindp->indicator = 0; /* not used for array binds */
bindp->type = 0; /* not used for array binds */
- Z_ADDREF_P(var);
+
+ Z_TRY_ADDREF_P(var);
PHP_OCI_CALL_RETURN(errstatus,
OCIBindByName,
@@ -1620,6 +1629,7 @@ int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, int nam
if (errstatus != OCI_SUCCESS) {
+ efree(bindp);
statement->errcode = php_oci_error(statement->err, errstatus);
PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode);
return 1;
diff --git a/ext/oci8/php_oci8_int.h b/ext/oci8/php_oci8_int.h
index 9f1da48cd1..4a23f06168 100644
--- a/ext/oci8/php_oci8_int.h
+++ b/ext/oci8/php_oci8_int.h
@@ -202,7 +202,7 @@ typedef struct {
/* {{{ php_oci_define */
typedef struct {
- zval zval; /* zval used in define */
+ zval *zval; /* zval used in define */
text *name; /* placeholder's name */
ub4 name_len; /* placeholder's name length */
ub4 type; /* define type */
@@ -237,7 +237,7 @@ typedef struct {
/* {{{ php_oci_bind */
typedef struct {
OCIBind *bind; /* bind handle */
- zval zval; /* value */
+ zval *zval; /* value */
dvoid *descriptor; /* used for binding of LOBS etc */
OCIStmt *statement; /* used for binding REFCURSORs */
php_oci_statement *parent_statement; /* pointer to the parent statement */