wez Mon Jul 11 22:43:39 2005 EDT Modified files: /php-src/ext/pdo_oci oci_statement.c php_pdo_oci_int.h Log: 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. http://cvs.php.net/diff.php/php-src/ext/pdo_oci/oci_statement.c?r1=1.15&r2=1.16&ty=u Index: php-src/ext/pdo_oci/oci_statement.c diff -u php-src/ext/pdo_oci/oci_statement.c:1.15 php-src/ext/pdo_oci/oci_statement.c:1.16 --- php-src/ext/pdo_oci/oci_statement.c:1.15 Thu Jul 7 19:02:22 2005 +++ php-src/ext/pdo_oci/oci_statement.c Mon Jul 11 22:43:39 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: oci_statement.c,v 1.15 2005/07/07 23:02:22 tony2001 Exp $ */ +/* $Id: oci_statement.c,v 1.16 2005/07/12 02:43:39 wez Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -97,6 +97,8 @@ } efree(S); + stmt->driver_data = NULL; + return 1; } /* }}} */ @@ -203,6 +205,7 @@ 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 @@ 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 @@ 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; http://cvs.php.net/diff.php/php-src/ext/pdo_oci/php_pdo_oci_int.h?r1=1.3&r2=1.4&ty=u Index: php-src/ext/pdo_oci/php_pdo_oci_int.h diff -u php-src/ext/pdo_oci/php_pdo_oci_int.h:1.3 php-src/ext/pdo_oci/php_pdo_oci_int.h:1.4 --- php-src/ext/pdo_oci/php_pdo_oci_int.h:1.3 Wed Jan 12 00:47:03 2005 +++ php-src/ext/pdo_oci/php_pdo_oci_int.h Mon Jul 11 22:43:39 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_pdo_oci_int.h,v 1.3 2005/01/12 05:47:03 wez Exp $ */ +/* $Id: php_pdo_oci_int.h,v 1.4 2005/07/12 02:43:39 wez Exp $ */ #include <oci.h> @@ -75,6 +75,8 @@ ub4 actual_len; dvoid *thing; /* for LOBS, REFCURSORS etc. */ + + unsigned used_for_output; } pdo_oci_bound_param; extern const ub4 PDO_OCI_INIT_MODE;
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php