wez Mon Jul 11 22:41:00 2005 EDT Modified files: /php-src/ext/pdo pdo.c pdo_dbh.c pdo_stmt.c php_pdo_driver.h Log: expand oracle null handling compatability by offering the ability to convert NULLs into empty strings as well as the other way around. It still doesn't help a great deal in the long run, but at least the option is there. Make sure hash tables are nulled out to avoid double freeing them. http://cvs.php.net/diff.php/php-src/ext/pdo/pdo.c?r1=1.54&r2=1.55&ty=u Index: php-src/ext/pdo/pdo.c diff -u php-src/ext/pdo/pdo.c:1.54 php-src/ext/pdo/pdo.c:1.55 --- php-src/ext/pdo/pdo.c:1.54 Fri Jul 8 00:12:57 2005 +++ php-src/ext/pdo/pdo.c Mon Jul 11 22:40:59 2005 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo.c,v 1.54 2005/07/08 04:12:57 wez Exp $ */ +/* $Id: pdo.c,v 1.55 2005/07/12 02:40:59 wez Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -346,7 +346,11 @@ REGISTER_LONG_CONSTANT("PDO_CASE_NATURAL", (long)PDO_CASE_NATURAL, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("PDO_CASE_LOWER", (long)PDO_CASE_LOWER, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("PDO_CASE_UPPER", (long)PDO_CASE_UPPER, CONST_CS|CONST_PERSISTENT); - + + REGISTER_LONG_CONSTANT("PDO_NULL_NATURAL", (long)PDO_NULL_NATURAL, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("PDO_NULL_EMPTY_STRING", (long)PDO_NULL_EMPTY_STRING, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("PDO_NULL_TO_STRING", (long)PDO_NULL_TO_STRING, CONST_CS|CONST_PERSISTENT); + REGISTER_STRING_CONSTANT("PDO_ERR_NONE", PDO_ERR_NONE, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("PDO_FETCH_ORI_NEXT", (long)PDO_FETCH_ORI_NEXT, CONST_CS|CONST_PERSISTENT); http://cvs.php.net/diff.php/php-src/ext/pdo/pdo_dbh.c?r1=1.81&r2=1.82&ty=u Index: php-src/ext/pdo/pdo_dbh.c diff -u php-src/ext/pdo/pdo_dbh.c:1.81 php-src/ext/pdo/pdo_dbh.c:1.82 --- php-src/ext/pdo/pdo_dbh.c:1.81 Fri Jul 8 22:53:05 2005 +++ php-src/ext/pdo/pdo_dbh.c Mon Jul 11 22:40:59 2005 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo_dbh.c,v 1.81 2005/07/09 02:53:05 iliaa Exp $ */ +/* $Id: pdo_dbh.c,v 1.82 2005/07/12 02:40:59 wez Exp $ */ /* The PDO Database Handle Class */ @@ -691,7 +691,7 @@ case PDO_ATTR_ORACLE_NULLS: convert_to_long(value); - dbh->oracle_nulls = Z_LVAL_P(value) ? 1 : 0; + dbh->oracle_nulls = Z_LVAL_P(value); RETURN_TRUE; case PDO_ATTR_STRINGIFY_FETCHES: @@ -746,7 +746,7 @@ RETURN_LONG(dbh->desired_case); case PDO_ATTR_ORACLE_NULLS: - RETURN_BOOL(dbh->oracle_nulls); + RETURN_LONG(dbh->oracle_nulls); case PDO_ATTR_ERRMODE: RETURN_LONG(dbh->error_mode); http://cvs.php.net/diff.php/php-src/ext/pdo/pdo_stmt.c?r1=1.109&r2=1.110&ty=u Index: php-src/ext/pdo/pdo_stmt.c diff -u php-src/ext/pdo/pdo_stmt.c:1.109 php-src/ext/pdo/pdo_stmt.c:1.110 --- php-src/ext/pdo/pdo_stmt.c:1.109 Mon Jul 11 10:14:56 2005 +++ php-src/ext/pdo/pdo_stmt.c Mon Jul 11 22:40:59 2005 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo_stmt.c,v 1.109 2005/07/11 14:14:56 andrey Exp $ */ +/* $Id: pdo_stmt.c,v 1.110 2005/07/12 02:40:59 wez Exp $ */ /* The PDO Statement Handle Class */ @@ -476,7 +476,7 @@ break; case PDO_PARAM_STR: - if (value && !(value_len == 0 && stmt->dbh->oracle_nulls)) { + if (value && !(value_len == 0 && stmt->dbh->oracle_nulls == PDO_NULL_EMPTY_STRING)) { ZVAL_STRINGL(dest, value, value_len, !caller_frees); if (caller_frees) { caller_frees = 0; @@ -499,6 +499,10 @@ break; } } + + if (Z_TYPE_P(dest) == IS_NULL && stmt->dbh->oracle_nulls == PDO_NULL_TO_STRING) { + ZVAL_EMPTY_STRING(dest); + } } /* }}} */ @@ -1898,14 +1902,17 @@ if (stmt->bound_params) { zend_hash_destroy(stmt->bound_params); FREE_HASHTABLE(stmt->bound_params); + stmt->bound_params = NULL; } if (stmt->bound_param_map) { zend_hash_destroy(stmt->bound_param_map); FREE_HASHTABLE(stmt->bound_param_map); + stmt->bound_param_map = NULL; } if (stmt->bound_columns) { zend_hash_destroy(stmt->bound_columns); FREE_HASHTABLE(stmt->bound_columns); + stmt->bound_columns = NULL; } if (stmt->methods && stmt->methods->dtor) { http://cvs.php.net/diff.php/php-src/ext/pdo/php_pdo_driver.h?r1=1.64&r2=1.65&ty=u Index: php-src/ext/pdo/php_pdo_driver.h diff -u php-src/ext/pdo/php_pdo_driver.h:1.64 php-src/ext/pdo/php_pdo_driver.h:1.65 --- php-src/ext/pdo/php_pdo_driver.h:1.64 Fri Jul 8 23:52:39 2005 +++ php-src/ext/pdo/php_pdo_driver.h Mon Jul 11 22:40:59 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_pdo_driver.h,v 1.64 2005/07/09 03:52:39 wez Exp $ */ +/* $Id: php_pdo_driver.h,v 1.65 2005/07/12 02:40:59 wez Exp $ */ #ifndef PHP_PDO_DRIVER_H #define PHP_PDO_DRIVER_H @@ -44,7 +44,7 @@ # define FALSE 0 #endif -#define PDO_DRIVER_API 20050709 +#define PDO_DRIVER_API 20050711 enum pdo_param_type { PDO_PARAM_NULL, @@ -174,6 +174,13 @@ PDO_CASE_LOWER }; +/* oracle interop settings */ +enum pdo_null_handling { + PDO_NULL_NATURAL = 0, + PDO_NULL_EMPTY_STRING = 1, + PDO_NULL_TO_STRING = 2, +}; + /* {{{ utils for reading attributes set as driver_options */ static inline long pdo_attr_lval(zval *options, enum pdo_fetch_type option_name, long defval TSRMLS_DC) { @@ -437,15 +444,15 @@ /* max length a single character can become after correct quoting */ unsigned max_escaped_char_length:3; - /* when set, convert empty strings to NULL */ - unsigned oracle_nulls:1; + /* oracle compat; see enum pdo_null_handling */ + unsigned oracle_nulls:2; /* when set, convert int/floats to strings */ unsigned stringify:1; /* the sum of the number of bits here and the bit fields preceeding should * equal 32 */ - unsigned _reserved_flags:22; + unsigned _reserved_flags:21; /* data source string used to open this handle */ const char *data_source;
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php