diff options
Diffstat (limited to 'ext/pdo')
| -rwxr-xr-x | ext/pdo/package.xml | 116 | ||||
| -rw-r--r-- | ext/pdo/package2.xml | 131 | ||||
| -rwxr-xr-x | ext/pdo/pdo.c | 12 | ||||
| -rwxr-xr-x | ext/pdo/pdo_dbh.c | 34 | ||||
| -rw-r--r-- | ext/pdo/pdo_sql_parser.c | 12 | ||||
| -rw-r--r-- | ext/pdo/pdo_sql_parser.c.orig | 30 | ||||
| -rw-r--r-- | ext/pdo/pdo_sql_parser.re | 8 | ||||
| -rw-r--r-- | ext/pdo/pdo_sqlstate.c | 8 | ||||
| -rwxr-xr-x | ext/pdo/pdo_stmt.c | 75 | ||||
| -rwxr-xr-x | ext/pdo/php_pdo.h | 8 | ||||
| -rwxr-xr-x | ext/pdo/php_pdo_driver.h | 15 | ||||
| -rwxr-xr-x | ext/pdo/php_pdo_int.h | 14 | ||||
| -rw-r--r-- | ext/pdo/tests/pdo_test.inc | 4 |
13 files changed, 272 insertions, 195 deletions
diff --git a/ext/pdo/package.xml b/ext/pdo/package.xml deleted file mode 100755 index 2abd3ca55..000000000 --- a/ext/pdo/package.xml +++ /dev/null @@ -1,116 +0,0 @@ -<?xml version="1.0" encoding="iso-8859-1"?> -<!DOCTYPE package SYSTEM "../pear/package.dtd"> -<package version="1.0"> - <name>PDO</name> - <summary>PHP Data Objects Interface</summary> - <maintainers> - <maintainer> - <user>wez</user> - <name>Wez Furlong</name> - <email>wez@php.net</email> - <role>lead</role> - </maintainer> - <maintainer> - <user>helly</user> - <name>Marcus Boerger</name> - <email>helly@php.net</email> - <role>lead</role> - </maintainer> - <maintainer> - <user>iliaa</user> - <name>Ilia Alshanetsky</name> - <email>iliaa@php.net</email> - <role>lead</role> - </maintainer> - <maintainer> - <user>gschlossnagle</user> - <name>George Schlossnagle</name> - <email>george@omniti.com</email> - <role>lead</role> - </maintainer> - </maintainers> - - <description> - PDO provides a uniform data access interface, sporting advanced features such - as prepared statements and bound parameters. PDO drivers are dynamically - loadable and may be developed independently from the core, but still accessed - using the same API. - - Read the documentation at http://www.php.net/pdo for more information. - </description> - <license>PHP</license> - <release> - <state>stable</state> - <version>1.0.1</version> - <date>2005-11-26</date> - - <notes> -** NOTE WELL! ** -All the PDO_XXX constants have been renamed to PDO::XXX form for future -compatibility with PHP namespaces. Sorry for the inconvenience, especially -after Release Candidate 1. - -You need to install a PDO database driver to make use of PDO, -check http://pecl.php.net/package-search.php?pkg_name=PDO -for a list of available PDO drivers. - -It is highly recommended that you update to PHP 5.1 before using PDO. - -If you are running on Windows, you can find a precompiled binary at: -http://pecl4win.php.net/ext.php/php_pdo.dll - -You can find additional PDO drivers at: -http://pecl4win.php.net - -** Changes ** -- Changed PDO_XXX constants to PDO::XXX -- It is now possible to extend PDO and PDOStatement and override their constructors - -- Fixed Bug #35303; PDO::prepare() can cause crashes with invalid parameters -- Fixed Bug #35135; "new PDOStatement" can cause crashes. -- Fixed Bug #35293 and PECL Bug #5589; segfault when creating persistent connections -- Fixed PECL Bug #5010, problem installing headers -- renamed pdo_drivers() to PDO::getAvailableDrivers() -- Various fixes when building with SPL -- PDO::setAttribute(PDO::ATTR_STATEMENT_CLASS) allows you to set your own - PDOStatement replacement when extending PDO and PDOStatement -- Fixed Bug #34687; error information from PDO::query() was not always returned -- Fixed PECL Bug #5750; uri: DSN was not handled correctly -- Fixed PECL Bug #5589; segfault when persistent connection attempt fails -- Fixed Bug #34590; User defined PDOStatement class methods are not callable -- Fixed Bug #34908; FETCH_INTO segfaults without destination object -- Fixed PECL Bug #5809; PDOStatement::execute(array(...)) modifies args -- Fixed PECL Bug #5772; FETCH_FUNC cannot call functions with mixed case names - -** Note ** - -You should uninstall and re-install your individual database drivers whenever -you upgrade the base PDO package, otherwise you will see an error about PDO API -numbers when you run your PHP scripts. - - </notes> - - <filelist> - <file role="src" name="config.m4"/> - <file role="src" name="config.w32"/> - <file role="src" name="pdo.c"/> - <file role="src" name="pdo_dbh.c"/> - <file role="src" name="pdo_stmt.c"/> - <file role="src" name="php_pdo.h"/> - <file role="src" name="php_pdo_driver.h"/> - <file role="src" name="php_pdo_int.h"/> - <file role="src" name="pdo_sql_parser.re"/> - <file role="src" name="pdo_sql_parser.c"/> - <file role="src" name="pdo_sqlstate.c"/> - <file role="src" name="Makefile.frag"/> - - <file role="doc" name="README"/> - <file role="doc" name="TODO"/> - <file role="doc" name="pdo.php"/> - <file role="doc" name="CREDITS"/> - </filelist> - <deps> - <dep type="php" rel="ge" version="5.0.3"/> - </deps> - </release> -</package> diff --git a/ext/pdo/package2.xml b/ext/pdo/package2.xml new file mode 100644 index 000000000..d402867df --- /dev/null +++ b/ext/pdo/package2.xml @@ -0,0 +1,131 @@ +<?xml version="1.0" encoding="UTF-8"?> +<package packagerversion="1.4.2" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 +http://pear.php.net/dtd/tasks-1.0.xsd +http://pear.php.net/dtd/package-2.0 +http://pear.php.net/dtd/package-2.0.xsd"> + <name>PDO</name> + <channel>pecl.php.net</channel> + <summary>PHP Data Objects Interface</summary> + <description>PDO provides a uniform data access interface, sporting advanced features such +as prepared statements and bound parameters. PDO drivers are dynamically +loadable and may be developed independently from the core, but still accessed +using the same API. +Read the documentation at http://www.php.net/pdo for more information. + </description> + <lead> + <name>Wez Furlong</name> + <user>wez</user> + <email>wez@php.net</email> + <active>yes</active> + </lead> + <lead> + <name>Marcus Boerger</name> + <user>helly</user> + <email>helly@php.net</email> + <active>yes</active> + </lead> + <lead> + <name>Ilia Alshanetsky</name> + <user>iliaa</user> + <email>iliaa@php.net</email> + <active>yes</active> + </lead> + <lead> + <name>George Schlossnagle</name> + <user>gschlossnagle</user> + <email>george@omniti.com</email> + <active>yes</active> + </lead> + <date>2005-12-04</date> + <version> + <release>1.0.3</release> + <api>1.0.3</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <license uri="http://www.php.net/license">PHP</license> + <notes>** NOTE WELL! ** +All the PDO_XXX constants have been renamed to PDO::XXX form for future +compatibility with PHP namespaces. Sorry for the inconvenience, especially +after Release Candidate 1. + +You need to install a PDO database driver to make use of PDO, +check http://pecl.php.net/package-search.php?pkg_name=PDO +for a list of available PDO drivers. + +It is highly recommended that you update to PHP 5.1 before using PDO. + +If you are running on Windows, you can find a precompiled binary at: +http://pecl4win.php.net/ext.php/php_pdo.dll + +You can find additional PDO drivers at: +http://pecl4win.php.net + +** Changes ** +- Fixed bug #35543 (crash when calling non-existing method in extended class). (Tony) +- Fixed bug #35508 (improved validation of fetch modes). (Tony) +- Fixed bug #35431 (PDO crashes when using LAZY fetch with fetchAll). (Wez) +- Fixed bug #35430 (PDO crashes on incorrect FETCH_FUNC use). (Tony) + +- Changed PDO_XXX constants to PDO::XXX +- It is now possible to extend PDO and PDOStatement and override their constructors + +- Fixed Bug #35303; PDO::prepare() can cause crashes with invalid parameters +- Fixed Bug #35135; "new PDOStatement" can cause crashes. +- Fixed Bug #35293 and PECL Bug #5589; segfault when creating persistent connections +- Fixed PECL Bug #5010, problem installing headers +- renamed pdo_drivers() to PDO::getAvailableDrivers() +- Various fixes when building with SPL +- PDO::setAttribute(PDO::ATTR_STATEMENT_CLASS) allows you to set your own + PDOStatement replacement when extending PDO and PDOStatement +- Fixed Bug #34687; error information from PDO::query() was not always returned +- Fixed PECL Bug #5750; uri: DSN was not handled correctly +- Fixed PECL Bug #5589; segfault when persistent connection attempt fails +- Fixed Bug #34590; User defined PDOStatement class methods are not callable +- Fixed Bug #34908; FETCH_INTO segfaults without destination object +- Fixed PECL Bug #5809; PDOStatement::execute(array(...)) modifies args +- Fixed PECL Bug #5772; FETCH_FUNC cannot call functions with mixed case names + +** Note ** + +You should uninstall and re-install your individual database drivers whenever +you upgrade the base PDO package, otherwise you will see an error about PDO API +numbers when you run your PHP scripts. + + + </notes> + <contents> + <dir name="/"> + <file name="config.m4" role="src" /> + <file name="config.w32" role="src" /> + <file name="CREDITS" role="doc" /> + <file name="Makefile.frag" role="src" /> + <file name="pdo.c" role="src" /> + <file name="pdo.php" role="doc" /> + <file name="pdo_dbh.c" role="src" /> + <file name="pdo_sqlstate.c" role="src" /> + <file name="pdo_sql_parser.c" role="src" /> + <file name="pdo_sql_parser.re" role="src" /> + <file name="pdo_stmt.c" role="src" /> + <file name="php_pdo.h" role="src" /> + <file name="php_pdo_driver.h" role="src" /> + <file name="php_pdo_int.h" role="src" /> + <file name="README" role="doc" /> + <file name="TODO" role="doc" /> + </dir> <!-- / --> + </contents> + <dependencies> + <required> + <php> + <min>5.0.3</min> + </php> + <pearinstaller> + <min>1.4.0</min> + </pearinstaller> + </required> + </dependencies> + <providesextension>PDO</providesextension> + <extsrcrelease /> +</package> diff --git a/ext/pdo/pdo.c b/ext/pdo/pdo.c index b786ad982..10ece60c7 100755 --- a/ext/pdo/pdo.c +++ b/ext/pdo/pdo.c @@ -2,12 +2,12 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2005 The PHP Group | + | Copyright (c) 1997-2006 The PHP Group | +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | + | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | + | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo.c,v 1.57.2.13 2005/11/26 21:22:49 wez Exp $ */ +/* $Id: pdo.c,v 1.57.2.17 2006/01/01 12:50:11 sniper Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -101,7 +101,7 @@ PHP_FUNCTION(pdo_drivers) /* }}} */ /* {{{ pdo_functions[] */ -function_entry pdo_functions[] = { +zend_function_entry pdo_functions[] = { PHP_FE(pdo_drivers, NULL) {NULL, NULL, NULL} }; @@ -133,7 +133,7 @@ zend_module_entry pdo_module_entry = { PHP_RINIT(pdo), PHP_RSHUTDOWN(pdo), PHP_MINFO(pdo), - "1.0.1", + "1.0.3", STANDARD_MODULE_PROPERTIES }; /* }}} */ diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index 987eedc25..ee72d5106 100755 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -2,12 +2,12 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2005 The PHP Group | + | Copyright (c) 1997-2006 The PHP Group | +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | + | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | + | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo_dbh.c,v 1.82.2.18 2005/11/25 00:20:12 wez Exp $ */ +/* $Id: pdo_dbh.c,v 1.82.2.26 2006/01/01 12:50:11 sniper Exp $ */ /* The PDO Database Handle Class */ @@ -283,7 +283,7 @@ static PHP_METHOD(PDO, dbh_constructor) zval **v; int plen; char *hashkey = NULL; - list_entry *le; + zend_rsrc_list_entry *le; pdo_dbh_t *pdbh = NULL; if (SUCCESS == zend_hash_index_find(Z_ARRVAL_P(options), PDO_ATTR_PERSISTENT, (void**)&v)) { @@ -377,7 +377,7 @@ static PHP_METHOD(PDO, dbh_constructor) /* all set */ if (is_persistent) { - list_entry le; + zend_rsrc_list_entry le; /* register in the persistent list etc. */ /* we should also need to replace the object store entry, @@ -1083,7 +1083,7 @@ static PHP_METHOD(PDO, getAvailableDrivers) } /* }}} */ -function_entry pdo_dbh_functions[] = { +zend_function_entry pdo_dbh_functions[] = { ZEND_MALIAS(PDO, __construct, dbh_constructor, NULL, ZEND_ACC_PUBLIC) PHP_ME(PDO, prepare, NULL, ZEND_ACC_PUBLIC) PHP_ME(PDO, beginTransaction,NULL, ZEND_ACC_PUBLIC) @@ -1106,13 +1106,13 @@ function_entry pdo_dbh_functions[] = { /* {{{ overloaded object handlers for PDO class */ int pdo_hash_methods(pdo_dbh_t *dbh, int kind TSRMLS_DC) { - function_entry *funcs; + zend_function_entry *funcs; zend_function func; zend_internal_function *ifunc = (zend_internal_function*)&func; int namelen; char *lc_name; - if (!dbh->methods->get_driver_methods) { + if (!dbh || !dbh->methods || !dbh->methods->get_driver_methods) { return 0; } funcs = dbh->methods->get_driver_methods(dbh, @@ -1344,6 +1344,11 @@ static void dbh_free(pdo_dbh_t *dbh TSRMLS_DC) if (--dbh->refcount) return; + if (dbh->query_stmt) { + zval_dtor(&dbh->query_stmt_zval); + dbh->query_stmt = NULL; + } + if (dbh->methods) { dbh->methods->closer(dbh TSRMLS_CC); } @@ -1365,12 +1370,23 @@ static void dbh_free(pdo_dbh_t *dbh TSRMLS_DC) for (i = 0; i < PDO_DBH_DRIVER_METHOD_KIND__MAX; i++) { if (dbh->cls_methods[i]) { zend_hash_destroy(dbh->cls_methods[i]); + pefree(dbh->cls_methods[i], dbh->is_persistent); } } pefree(dbh, dbh->is_persistent); } +PDO_API void php_pdo_dbh_addref(pdo_dbh_t *dbh TSRMLS_DC) +{ + dbh->refcount++; +} + +PDO_API void php_pdo_dbh_delref(pdo_dbh_t *dbh TSRMLS_DC) +{ + dbh_free(dbh TSRMLS_CC); +} + static void pdo_dbh_free_storage(pdo_dbh_t *dbh TSRMLS_DC) { if (dbh->in_txn && dbh->methods && dbh->methods->rollback) { diff --git a/ext/pdo/pdo_sql_parser.c b/ext/pdo/pdo_sql_parser.c index cf991268e..a6b20adfe 100644 --- a/ext/pdo/pdo_sql_parser.c +++ b/ext/pdo/pdo_sql_parser.c @@ -1,14 +1,14 @@ -/* Generated by re2c 0.9.9.rc1 on Sat Sep 10 15:53:03 2005 */ +/* Generated by re2c 0.9.11 on Sun Jan 1 14:38:30 2006 */ /* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2005 The PHP Group | + | Copyright (c) 1997-2006 The PHP Group | +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | + | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | + | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo_sql_parser.c,v 1.35.2.2 2005/09/10 20:58:57 wez Exp $ */ +/* $Id: pdo_sql_parser.c,v 1.35.2.5 2006/01/01 12:50:11 sniper Exp $ */ #include "php.h" #include "php_pdo_driver.h" @@ -85,7 +85,7 @@ static int scan(Scanner *s) { YYCTYPE yych; - unsigned int yyaccept; + unsigned int yyaccept = 0; goto yy0; ++YYCURSOR; yy0: diff --git a/ext/pdo/pdo_sql_parser.c.orig b/ext/pdo/pdo_sql_parser.c.orig index b20911698..453b35371 100644 --- a/ext/pdo/pdo_sql_parser.c.orig +++ b/ext/pdo/pdo_sql_parser.c.orig @@ -1,15 +1,15 @@ -/* Generated by re2c 0.9.9.rc1 on Sat Sep 10 15:53:03 2005 */ +/* Generated by re2c 0.9.11 on Sun Jan 1 14:38:30 2006 */ #line 1 "ext/pdo/pdo_sql_parser.re" /* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2005 The PHP Group | + | Copyright (c) 1997-2006 The PHP Group | +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | + | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | + | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo_sql_parser.c,v 1.35.2.2 2005/09/10 20:58:57 wez Exp $ */ +/* $Id: pdo_sql_parser.c,v 1.35.2.5 2006/01/01 12:50:11 sniper Exp $ */ #include "php.h" #include "php_pdo_driver.h" @@ -85,10 +85,10 @@ static int scan(Scanner *s) 162, 162, 162, 162, 162, 162, 162, 162, }; -#line 89 "<stdout>" +#line 89 "ext/pdo/pdo_sql_parser.c" { YYCTYPE yych; - unsigned int yyaccept; + unsigned int yyaccept = 0; goto yy0; ++YYCURSOR; yy0: @@ -113,7 +113,7 @@ yy2: yyaccept = 0; yy3: #line 63 "ext/pdo/pdo_sql_parser.re" { RET(PDO_PARSER_TEXT); } -#line 117 "<stdout>" +#line 117 "ext/pdo/pdo_sql_parser.c" yy4: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); if(yybm[0+yych] & 16) { @@ -150,7 +150,7 @@ yy6: ++YYCURSOR; yy7: #line 62 "ext/pdo/pdo_sql_parser.re" { RET(PDO_PARSER_BIND_POS); } -#line 154 "<stdout>" +#line 154 "ext/pdo/pdo_sql_parser.c" yy8: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -162,13 +162,13 @@ yy9: if(yybm[0+yych] & 2) { yy10: #line 64 "ext/pdo/pdo_sql_parser.re" { RET(PDO_PARSER_TEXT); } -#line 166 "<stdout>" +#line 166 "ext/pdo/pdo_sql_parser.c" yy11: ++YYCURSOR; goto yy12; yy12: #line 65 "ext/pdo/pdo_sql_parser.re" { RET(PDO_PARSER_EOI); } -#line 172 "<stdout>" +#line 172 "ext/pdo/pdo_sql_parser.c" yy13: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -180,7 +180,7 @@ yy14: if(yybm[0+yych] & 4) { yy15: #line 60 "ext/pdo/pdo_sql_parser.re" { RET(PDO_PARSER_TEXT); } -#line 184 "<stdout>" +#line 184 "ext/pdo/pdo_sql_parser.c" yy16: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -192,7 +192,7 @@ yy17: if(yybm[0+yych] & 8) { yy18: #line 61 "ext/pdo/pdo_sql_parser.re" { RET(PDO_PARSER_BIND); } -#line 196 "<stdout>" +#line 196 "ext/pdo/pdo_sql_parser.c" yy19: yyaccept = 1; YYMARKER = ++YYCURSOR; if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -218,7 +218,7 @@ yy21: ++YYCURSOR; yy22: #line 59 "ext/pdo/pdo_sql_parser.re" { RET(PDO_PARSER_TEXT); } -#line 222 "<stdout>" +#line 222 "ext/pdo/pdo_sql_parser.c" yy23: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -250,7 +250,7 @@ yy28: ++YYCURSOR; yy29: #line 58 "ext/pdo/pdo_sql_parser.re" { RET(PDO_PARSER_TEXT); } -#line 254 "<stdout>" +#line 254 "ext/pdo/pdo_sql_parser.c" yy30: yyaccept = 1; YYMARKER = ++YYCURSOR; if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); diff --git a/ext/pdo/pdo_sql_parser.re b/ext/pdo/pdo_sql_parser.re index 6e9d21f17..81b558c4e 100644 --- a/ext/pdo/pdo_sql_parser.re +++ b/ext/pdo/pdo_sql_parser.re @@ -2,12 +2,12 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2005 The PHP Group | + | Copyright (c) 1997-2006 The PHP Group | +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | + | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | + | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo_sql_parser.re,v 1.28.2.2 2005/09/10 20:58:19 wez Exp $ */ +/* $Id: pdo_sql_parser.re,v 1.28.2.3 2006/01/01 12:26:08 sniper Exp $ */ #include "php.h" #include "php_pdo_driver.h" diff --git a/ext/pdo/pdo_sqlstate.c b/ext/pdo/pdo_sqlstate.c index 8b833c5b6..338309f4c 100644 --- a/ext/pdo/pdo_sqlstate.c +++ b/ext/pdo/pdo_sqlstate.c @@ -2,12 +2,12 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2005 The PHP Group | + | Copyright (c) 1997-2006 The PHP Group | +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | + | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | + | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo_sqlstate.c,v 1.7 2005/07/01 23:32:39 edink Exp $ */ +/* $Id: pdo_sqlstate.c,v 1.7.2.1 2006/01/01 12:50:11 sniper Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index ac9e0a52f..dbc056247 100755 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -2,12 +2,12 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2005 The PHP Group | + | Copyright (c) 1997-2006 The PHP Group | +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | + | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | + | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo_stmt.c,v 1.118.2.21 2005/11/26 21:20:52 wez Exp $ */ +/* $Id: pdo_stmt.c,v 1.118.2.30 2006/01/01 20:07:41 iliaa Exp $ */ /* The PDO Statement Handle Class */ @@ -228,7 +228,7 @@ static void get_lazy_object(pdo_stmt_t *stmt, zval *return_value TSRMLS_DC) /* { Z_TYPE(stmt->lazy_object_ref) = IS_OBJECT; Z_OBJ_HANDLE(stmt->lazy_object_ref) = zend_objects_store_put(stmt, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t)pdo_row_free_storage, NULL TSRMLS_CC); Z_OBJ_HT(stmt->lazy_object_ref) = &pdo_row_object_handlers; - /* stmt->refcount++; */ + stmt->refcount++; } Z_TYPE_P(return_value) = IS_OBJECT; Z_OBJ_HANDLE_P(return_value) = Z_OBJ_HANDLE(stmt->lazy_object_ref); @@ -1116,9 +1116,14 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, static int pdo_stmt_verify_mode(pdo_stmt_t *stmt, int mode, int fetch_all TSRMLS_DC) /* {{{ */ { int flags = mode & PDO_FETCH_FLAGS; - + mode = mode & ~PDO_FETCH_FLAGS; + if (mode < 0 || mode > PDO_FETCH__MAX) { + pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "invalid fetch mode" TSRMLS_CC); + return 0; + } + if (mode == PDO_FETCH_USE_DEFAULT) { flags = stmt->default_fetch_type & PDO_FETCH_FLAGS; mode = stmt->default_fetch_type & ~PDO_FETCH_FLAGS; @@ -1138,6 +1143,13 @@ static int pdo_stmt_verify_mode(pdo_stmt_t *stmt, int mode, int fetch_all TSRMLS return 0; } return 1; + + case PDO_FETCH_LAZY: + if (fetch_all) { + pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "PDO::FETCH_LAZY can't be used with PDOStatement::fetchAll()" TSRMLS_CC); + return 0; + } + /* fall through */ default: if ((flags & PDO_FETCH_SERIALIZE) == PDO_FETCH_SERIALIZE) { @@ -1353,13 +1365,15 @@ static PHP_METHOD(PDOStatement, fetchAll) switch(ZEND_NUM_ARGS()) { case 0: case 1: + pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "no fetch function specified" TSRMLS_CC); + error = 1; break; case 3: case 2: stmt->fetch.func.function = arg2; + do_fetch_func_prepare(stmt TSRMLS_CC); break; } - do_fetch_func_prepare(stmt TSRMLS_CC); break; case PDO_FETCH_COLUMN: @@ -1704,10 +1718,12 @@ fail_out: mode = Z_LVAL_PP(args[skip]); if (!pdo_stmt_verify_mode(stmt, mode, 0 TSRMLS_CC)) { + efree(args); return FAILURE; } switch (mode & ~PDO_FETCH_FLAGS) { + case PDO_FETCH_USE_DEFAULT: case PDO_FETCH_LAZY: case PDO_FETCH_ASSOC: case PDO_FETCH_NUM: @@ -1782,12 +1798,8 @@ fail_out: break; default: - if ((mode & ~PDO_FETCH_FLAGS) < PDO_FETCH__MAX && (mode & ~PDO_FETCH_FLAGS) >= 0) { - pdo_raise_impl_error(stmt->dbh, stmt, "22003", "unhandled mode; this is a PDO bug, please report it" TSRMLS_CC); - } else { - pdo_raise_impl_error(stmt->dbh, stmt, "22003", "mode is out of range" TSRMLS_CC); - } - return FAILURE; + pdo_raise_impl_error(stmt->dbh, stmt, "22003", "Invalid fetch mode specified" TSRMLS_CC); + goto fail_out; } stmt->default_fetch_type = mode; @@ -1948,7 +1960,7 @@ static PHP_METHOD(PDOStatement, __sleep) } /* }}} */ -function_entry pdo_dbstmt_functions[] = { +zend_function_entry pdo_dbstmt_functions[] = { PHP_ME(PDOStatement, execute, NULL, ZEND_ACC_PUBLIC) PHP_ME(PDOStatement, fetch, NULL, ZEND_ACC_PUBLIC) PHP_ME(PDOStatement, bindParam, second_arg_force_ref, ZEND_ACC_PUBLIC) @@ -2048,6 +2060,34 @@ static int dbstmt_compare(zval *object1, zval *object2 TSRMLS_DC) return -1; } +static zend_object_value dbstmt_clone_obj(zval *zobject TSRMLS_DC) +{ + zend_object_value retval; + zval *tmp; + pdo_stmt_t *stmt; + pdo_stmt_t *old_stmt; + zend_object_handle handle = Z_OBJ_HANDLE_P(zobject); + + stmt = ecalloc(1, sizeof(*stmt)); + stmt->ce = Z_OBJCE_P(zobject); + stmt->refcount = 1; + ALLOC_HASHTABLE(stmt->properties); + zend_hash_init(stmt->properties, 0, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_copy(stmt->properties, &stmt->ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); + + old_stmt = (pdo_stmt_t *)zend_object_store_get_object(zobject TSRMLS_CC); + + retval.handle = zend_objects_store_put(stmt, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t)pdo_dbstmt_free_storage, (zend_objects_store_clone_t)dbstmt_clone_obj TSRMLS_CC); + retval.handlers = Z_OBJ_HT_P(zobject); + + zend_objects_clone_members((zend_object *)stmt, retval, (zend_object *)old_stmt, handle TSRMLS_CC); + + zend_objects_store_add_ref(&old_stmt->database_object_handle TSRMLS_CC); + stmt->database_object_handle = old_stmt->database_object_handle; + + return retval; +} + zend_object_handlers pdo_dbstmt_object_handlers; void pdo_stmt_init(TSRMLS_D) @@ -2066,6 +2106,7 @@ void pdo_stmt_init(TSRMLS_D) pdo_dbstmt_object_handlers.unset_property = dbstmt_prop_delete; pdo_dbstmt_object_handlers.get_method = dbstmt_method_get; pdo_dbstmt_object_handlers.compare_objects = dbstmt_compare; + pdo_dbstmt_object_handlers.clone_obj = dbstmt_clone_obj; INIT_CLASS_ENTRY(ce, "PDORow", pdo_row_functions); pdo_row_ce = zend_register_internal_class(&ce TSRMLS_CC); @@ -2160,7 +2201,7 @@ zend_object_value pdo_dbstmt_new(zend_class_entry *ce TSRMLS_DC) zend_hash_init(stmt->properties, 0, NULL, ZVAL_PTR_DTOR, 0); zend_hash_copy(stmt->properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); - retval.handle = zend_objects_store_put(stmt, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t)pdo_dbstmt_free_storage, NULL TSRMLS_CC); + retval.handle = zend_objects_store_put(stmt, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t)pdo_dbstmt_free_storage, (zend_objects_store_clone_t)dbstmt_clone_obj TSRMLS_CC); retval.handlers = &pdo_dbstmt_object_handlers; return retval; @@ -2285,7 +2326,7 @@ zend_object_iterator *pdo_stmt_iter_get(zend_class_entry *ce, zval *object TSRML /* {{{ overloaded handlers for PDORow class (used by PDO_FETCH_LAZY) */ -function_entry pdo_row_functions[] = { +zend_function_entry pdo_row_functions[] = { {NULL, NULL, NULL} }; @@ -2460,13 +2501,11 @@ zend_object_handlers pdo_row_object_handlers = { void pdo_row_free_storage(pdo_stmt_t *stmt TSRMLS_DC) { -#if 0 ZVAL_NULL(&stmt->lazy_object_ref); if (--stmt->refcount == 0) { free_statement(stmt TSRMLS_CC); } -#endif } zend_object_value pdo_row_new(zend_class_entry *ce TSRMLS_DC) diff --git a/ext/pdo/php_pdo.h b/ext/pdo/php_pdo.h index c5f9c4c5b..74078b4de 100755 --- a/ext/pdo/php_pdo.h +++ b/ext/pdo/php_pdo.h @@ -2,12 +2,12 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2005 The PHP Group | + | Copyright (c) 1997-2006 The PHP Group | +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | + | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | + | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_pdo.h,v 1.7.2.4 2005/10/02 20:38:18 helly Exp $ */ +/* $Id: php_pdo.h,v 1.7.2.5 2006/01/01 12:50:11 sniper Exp $ */ #ifndef PHP_PDO_H #define PHP_PDO_H diff --git a/ext/pdo/php_pdo_driver.h b/ext/pdo/php_pdo_driver.h index fefb5449d..321fdff65 100755 --- a/ext/pdo/php_pdo_driver.h +++ b/ext/pdo/php_pdo_driver.h @@ -2,12 +2,12 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2005 The PHP Group | + | Copyright (c) 1997-2006 The PHP Group | +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | + | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | + | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_pdo_driver.h,v 1.66.2.6 2005/10/31 02:07:37 wez Exp $ */ +/* $Id: php_pdo_driver.h,v 1.66.2.9 2006/01/01 12:50:11 sniper Exp $ */ #ifndef PHP_PDO_DRIVER_H #define PHP_PDO_DRIVER_H @@ -44,7 +44,7 @@ PDO_API char *php_pdo_int64_to_str(pdo_int64_t i64 TSRMLS_DC); # define FALSE 0 #endif -#define PDO_DRIVER_API 20051031 +#define PDO_DRIVER_API 20051128 enum pdo_param_type { PDO_PARAM_NULL, @@ -284,7 +284,7 @@ enum { PDO_DBH_DRIVER_METHOD_KIND__MAX }; -typedef function_entry *(*pdo_dbh_get_driver_methods_func)(pdo_dbh_t *dbh, int kind TSRMLS_DC); +typedef zend_function_entry *(*pdo_dbh_get_driver_methods_func)(pdo_dbh_t *dbh, int kind TSRMLS_DC); struct pdo_dbh_methods { pdo_dbh_close_func closer; @@ -645,6 +645,9 @@ PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, PDO_API void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *sqlstate, const char *supp TSRMLS_DC); +PDO_API void php_pdo_dbh_addref(pdo_dbh_t *dbh TSRMLS_DC); +PDO_API void php_pdo_dbh_delref(pdo_dbh_t *dbh TSRMLS_DC); + PDO_API void php_pdo_stmt_addref(pdo_stmt_t *stmt TSRMLS_DC); PDO_API void php_pdo_stmt_delref(pdo_stmt_t *stmt TSRMLS_DC); diff --git a/ext/pdo/php_pdo_int.h b/ext/pdo/php_pdo_int.h index 8a4724630..fb567af8c 100755 --- a/ext/pdo/php_pdo_int.h +++ b/ext/pdo/php_pdo_int.h @@ -2,12 +2,12 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2005 The PHP Group | + | Copyright (c) 1997-2006 The PHP Group | +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | + | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | + | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_pdo_int.h,v 1.17.2.4 2005/10/02 22:11:17 wez Exp $ */ +/* $Id: php_pdo_int.h,v 1.17.2.6 2006/01/01 12:50:11 sniper Exp $ */ /* Stuff private to the PDO extension and not for consumption by PDO drivers * */ @@ -32,12 +32,12 @@ void pdo_dbh_init(TSRMLS_D); void pdo_stmt_init(TSRMLS_D); extern zend_object_value pdo_dbh_new(zend_class_entry *ce TSRMLS_DC); -extern function_entry pdo_dbh_functions[]; +extern zend_function_entry pdo_dbh_functions[]; extern zend_class_entry *pdo_dbh_ce; extern ZEND_RSRC_DTOR_FUNC(php_pdo_pdbh_dtor); extern zend_object_value pdo_dbstmt_new(zend_class_entry *ce TSRMLS_DC); -extern function_entry pdo_dbstmt_functions[]; +extern zend_function_entry pdo_dbstmt_functions[]; extern zend_class_entry *pdo_dbstmt_ce; void pdo_dbstmt_free_storage(pdo_stmt_t *stmt TSRMLS_DC); zend_object_iterator *pdo_stmt_iter_get(zend_class_entry *ce, zval *object TSRMLS_DC); @@ -46,7 +46,7 @@ int pdo_stmt_describe_columns(pdo_stmt_t *stmt TSRMLS_DC); int pdo_stmt_setup_fetch_mode(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt, int skip_first_arg); extern zend_object_value pdo_row_new(zend_class_entry *ce TSRMLS_DC); -extern function_entry pdo_row_functions[]; +extern zend_function_entry pdo_row_functions[]; extern zend_class_entry *pdo_row_ce; void pdo_row_free_storage(pdo_stmt_t *stmt TSRMLS_DC); extern zend_object_handlers pdo_row_object_handlers; diff --git a/ext/pdo/tests/pdo_test.inc b/ext/pdo/tests/pdo_test.inc index 3a3040eac..a023fd89b 100644 --- a/ext/pdo/tests/pdo_test.inc +++ b/ext/pdo/tests/pdo_test.inc @@ -35,6 +35,10 @@ class PDOTest { $db = new $classname($dsn, $user, $pass, $attr); + if (!$db) { + die("Could not create PDO object (DSN=$dsn, user=$user)\n"); + } + // clean up any crufty test tables we might have left behind // on a previous run static $test_tables = array( |
