diff options
author | Wez Furlong <wez@php.net> | 2005-07-12 02:43:39 +0000 |
---|---|---|
committer | Wez Furlong <wez@php.net> | 2005-07-12 02:43:39 +0000 |
commit | 4f22ac0cdde49f24a12e9b7e980c7e9fc08ac5ae (patch) | |
tree | 10bfff6290c0364afa8f329d49402212ff977a7b /ext | |
parent | 664ebfa4990171891f84b18ee1a50f734948d80f (diff) | |
download | php-git-4f22ac0cdde49f24a12e9b7e980c7e9fc08ac5ae.tar.gz |
improve handling of bound input parameters when no maximal length value is set;
default to 4000 as the maximal length, which is the biggest size possible
without using a LONG type (if you specify anything larger than this, you'll end
up with ORA-1461).
Don't assume that all parameters were output parameters after execution, as
this would clobber the input values when used in a loop.
Diffstat (limited to 'ext')
-rwxr-xr-x | ext/pdo_oci/oci_statement.c | 39 | ||||
-rwxr-xr-x | ext/pdo_oci/php_pdo_oci_int.h | 2 |
2 files changed, 25 insertions, 16 deletions
diff --git a/ext/pdo_oci/oci_statement.c b/ext/pdo_oci/oci_statement.c index 6f775313f6..10a4d2f325 100755 --- a/ext/pdo_oci/oci_statement.c +++ b/ext/pdo_oci/oci_statement.c @@ -97,6 +97,8 @@ static int oci_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */ } efree(S); + stmt->driver_data = NULL; + return 1; } /* }}} */ @@ -203,6 +205,7 @@ static sb4 oci_bind_output_cb(dvoid *ctx, OCIBind *bindp, ub4 iter, ub4 index, d Z_STRLEN_P(param->parameter) = param->max_value_len; Z_STRVAL_P(param->parameter) = emalloc(Z_STRLEN_P(param->parameter)+1); + P->used_for_output = 1; P->actual_len = Z_STRLEN_P(param->parameter); *alenpp = &P->actual_len; @@ -246,9 +249,10 @@ static int oci_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *pa case PDO_PARAM_STR: default: P->oci_type = SQLT_CHR; - convert_to_string(param->parameter); value_sz = param->max_value_len + 1; - P->actual_len = Z_STRLEN_P(param->parameter); + if (param->max_value_len == 0) { + value_sz = 4000; /* maximum size before value is interpreted as a LONG value */ + } } @@ -275,30 +279,33 @@ static int oci_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *pa case PDO_PARAM_EVT_EXEC_PRE: P->indicator = 0; + P->used_for_output = 0; return 1; case PDO_PARAM_EVT_EXEC_POST: /* fixup stuff set in motion in oci_bind_output_cb */ - if (P->indicator == -1) { - /* set up a NULL value */ - if (Z_TYPE_P(param->parameter) == IS_STRING + if (P->used_for_output) { + if (P->indicator == -1) { + /* set up a NULL value */ + if (Z_TYPE_P(param->parameter) == IS_STRING #if ZEND_EXTENSION_API_NO < 220040718 && Z_STRVAL_P(param->parameter) != empty_string #endif - ) { - /* OCI likes to stick non-terminated strings in things */ - *Z_STRVAL_P(param->parameter) = '\0'; - } - zval_dtor(param->parameter); - ZVAL_NULL(param->parameter); - } else if (Z_TYPE_P(param->parameter) == IS_STRING + ) { + /* OCI likes to stick non-terminated strings in things */ + *Z_STRVAL_P(param->parameter) = '\0'; + } + zval_dtor(param->parameter); + ZVAL_NULL(param->parameter); + } else if (Z_TYPE_P(param->parameter) == IS_STRING #if ZEND_EXTENSION_API_NO < 220040718 && Z_STRVAL_P(param->parameter) != empty_string #endif - ) { - Z_STRLEN_P(param->parameter) = P->actual_len; - Z_STRVAL_P(param->parameter) = erealloc(Z_STRVAL_P(param->parameter), P->actual_len+1); - Z_STRVAL_P(param->parameter)[P->actual_len] = '\0'; + ) { + Z_STRLEN_P(param->parameter) = P->actual_len; + Z_STRVAL_P(param->parameter) = erealloc(Z_STRVAL_P(param->parameter), P->actual_len+1); + Z_STRVAL_P(param->parameter)[P->actual_len] = '\0'; + } } return 1; diff --git a/ext/pdo_oci/php_pdo_oci_int.h b/ext/pdo_oci/php_pdo_oci_int.h index 2ebd4f2226..a28d466eac 100755 --- a/ext/pdo_oci/php_pdo_oci_int.h +++ b/ext/pdo_oci/php_pdo_oci_int.h @@ -75,6 +75,8 @@ typedef struct { ub4 actual_len; dvoid *thing; /* for LOBS, REFCURSORS etc. */ + + unsigned used_for_output; } pdo_oci_bound_param; extern const ub4 PDO_OCI_INIT_MODE; |