[PHP-CVS] cvs: php-src /ext/pdo pdo.c pdo_dbh.c pdo_stmt.c php_pdo_driver.h
wez Mon Jul 11 22:41:00 2005 EDT Modified files: /php-src/ext/pdopdo.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.109Mon 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) {
[PHP-CVS] cvs: php-src /ext/pdo pdo.c pdo_dbh.c pdo_stmt.c php_pdo_driver.h /ext/pdo/tests pdo_test.inc
wez Fri Jul 8 00:13:01 2005 EDT Modified files: /php-src/ext/pdopdo.c pdo_dbh.c pdo_stmt.c php_pdo_driver.h /php-src/ext/pdo/tests pdo_test.inc Log: Add a PDO_ATTR_STRINGIFY_FETCHES attribute, which is used to convert integer or floating point values into strings during fetch. This is a compatibility hack for drivers that return native types rather than string representations. We use this flag in the test suite to persuade postgres tests to pass. http://cvs.php.net/diff.php/php-src/ext/pdo/pdo.c?r1=1.53&r2=1.54&ty=u Index: php-src/ext/pdo/pdo.c diff -u php-src/ext/pdo/pdo.c:1.53 php-src/ext/pdo/pdo.c:1.54 --- php-src/ext/pdo/pdo.c:1.53 Thu Jul 7 13:08:01 2005 +++ php-src/ext/pdo/pdo.c Fri Jul 8 00:12:57 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: pdo.c,v 1.53 2005/07/07 17:08:01 wez Exp $ */ +/* $Id: pdo.c,v 1.54 2005/07/08 04:12:57 wez Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -337,6 +337,7 @@ REGISTER_LONG_CONSTANT("PDO_ATTR_FETCH_TABLE_NAMES", (long)PDO_ATTR_FETCH_TABLE_NAMES, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("PDO_ATTR_FETCH_CATALOG_NAMES", (long)PDO_ATTR_FETCH_CATALOG_NAMES, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("PDO_ATTR_DRIVER_NAME", (long)PDO_ATTR_DRIVER_NAME, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("PDO_ATTR_STRINGIFY_FETCHES",(long)PDO_ATTR_STRINGIFY_FETCHES, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("PDO_ERRMODE_SILENT", (long)PDO_ERRMODE_SILENT, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("PDO_ERRMODE_WARNING", (long)PDO_ERRMODE_WARNING, CONST_CS|CONST_PERSISTENT); http://cvs.php.net/diff.php/php-src/ext/pdo/pdo_dbh.c?r1=1.78&r2=1.79&ty=u Index: php-src/ext/pdo/pdo_dbh.c diff -u php-src/ext/pdo/pdo_dbh.c:1.78 php-src/ext/pdo/pdo_dbh.c:1.79 --- php-src/ext/pdo/pdo_dbh.c:1.78 Thu Jul 7 13:08:01 2005 +++ php-src/ext/pdo/pdo_dbh.c Fri Jul 8 00:12:58 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: pdo_dbh.c,v 1.78 2005/07/07 17:08:01 wez Exp $ */ +/* $Id: pdo_dbh.c,v 1.79 2005/07/08 04:12:58 wez Exp $ */ /* The PDO Database Handle Class */ @@ -693,6 +693,11 @@ convert_to_long(value); dbh->oracle_nulls = Z_LVAL_P(value) ? 1 : 0; RETURN_TRUE; + + case PDO_ATTR_STRINGIFY_FETCHES: + convert_to_long(value); + dbh->stringify = Z_LVAL_P(value) ? 1 : 0; + RETURN_TRUE; default: ; http://cvs.php.net/diff.php/php-src/ext/pdo/pdo_stmt.c?r1=1.104&r2=1.105&ty=u Index: php-src/ext/pdo/pdo_stmt.c diff -u php-src/ext/pdo/pdo_stmt.c:1.104 php-src/ext/pdo/pdo_stmt.c:1.105 --- php-src/ext/pdo/pdo_stmt.c:1.104Thu Jul 7 11:14:10 2005 +++ php-src/ext/pdo/pdo_stmt.c Fri Jul 8 00:12:58 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: pdo_stmt.c,v 1.104 2005/07/07 15:14:10 iliaa Exp $ */ +/* $Id: pdo_stmt.c,v 1.105 2005/07/08 04:12:58 wez Exp $ */ /* The PDO Statement Handle Class */ @@ -481,6 +481,15 @@ if (caller_frees && value) { efree(value); } + + if (stmt->dbh->stringify) { + switch (Z_TYPE_P(dest)) { + case IS_LONG: + case IS_DOUBLE: + convert_to_string(dest); + break; + } + } } /* }}} */ http://cvs.php.net/diff.php/php-src/ext/pdo/php_pdo_driver.h?r1=1.60&r2=1.61&ty=u Index: php-src/ext/pdo/php_pdo_driver.h diff -u php-src/ext/pdo/php_pdo_driver.h:1.60 php-src/ext/pdo/php_pdo_driver.h:1.61 --- php-src/ext/pdo/php_pdo_driver.h:1.60 Thu Jul 7 12:24:51 2005 +++ php-src/ext/pdo/php_pdo_driver.hFri Jul 8 00:12:58 2005 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_pdo_driver.h,v 1.60 2005/07/07 16:24:51 wez Exp $ */ +/* $Id: php_pdo_driver.h,v 1.61 2005/07/08 04:12:58 wez Exp $ */ #ifndef PHP_PDO_DRIVER_H #define PHP_PDO_DRIVER_H @@ -44,7 +44,7 @@ # define FALSE 0 #endif -#define PDO_DRIVER_API 20050707 +#define PDO_DRIVER_API 20050708 enum pdo_param_type { PDO_PARAM_NULL, @@ -127,6 +127,7 @@ PDO_ATTR_FETCH_TABLE_NAMES, /* include table names in the column names, where available */ PDO_ATTR_FETCH_CATALOG_NAMES, /* include the catalog/db name names in the column names, where available */ PDO_ATTR_DRIVER_NAME, /* name of the driver (as used in the constru