summaryrefslogtreecommitdiff
path: root/ext/pdo
diff options
context:
space:
mode:
Diffstat (limited to 'ext/pdo')
-rwxr-xr-xext/pdo/TODO92
-rw-r--r--ext/pdo/package2.xml134
-rw-r--r--ext/pdo/pdo.c6
-rw-r--r--ext/pdo/pdo_dbh.c22
-rw-r--r--ext/pdo/pdo_stmt.c37
-rw-r--r--ext/pdo/php_pdo_driver.h8
6 files changed, 31 insertions, 268 deletions
diff --git a/ext/pdo/TODO b/ext/pdo/TODO
deleted file mode 100755
index e422bc05e6..0000000000
--- a/ext/pdo/TODO
+++ /dev/null
@@ -1,92 +0,0 @@
-$Id$
-
-Roadmap for PDO
-
-Core, version 1.1:
-==================
-
- - Add PDO::queryParams(), similar to PDO::query(), but accepts
- an array of parameters as the second argument, pushing the remaining
- args (which are args to setFetchMode()) up by one.
-
- - Separate the handle factory call into two phases:
- - handle creation
- - connecting
-
- This would then allow PDO to call setAttribute()
- for each driver option specified in the constructor.
- Right now, the handling of driver attributes is a bit sloppy.
-
- - Add:
- pdo.max_persistent
- pdo.persistent_timeout
- pdo.ping_interval
-
- with the same meanings as those options from oci8.
-
- - BLOB/CLOB.
- Investigate the various APIs to determine if we can
- transparently map BLOBs and CLOBs as PDO_PARAM_LOB.
- If the API needs hints from the client side, we need
- to introduce a PDO_PARAM_CLOB to differentiate between
- binary and character data.
-
- - Character set selection.
- Generalize/standardize this.
-
- - meta data.
- Formalize getColumnMeta().
- Look at retrieving lists of tables and other objects in the db.
-
- - tracing/logging/debugging
- Add ini options:
-
- pdo.trace_file
- pdo.enable_tracing
-
- And corresponding attributes, ATTR_TRACE_FILE, ATTR_TRACING_ENABLE,
- settable at dbh and stmt levels independently. If set at the dbh level,
- the stmt will inherit its value. If not set explicitly in code, the
- defaults for the dbh will come from the INI settings.
-
- ATTR_TRACE_FILE will accept a string or a stream.
-
- The INI options are useful for administrative tracing/debugging.
- Trace mode will output very verbose info.
-
-
-General DB API Roundup:
-=========
- Consider how the following can be implemented in PDO:
-
- mysqli_change_user(); alters auth credentials on a live connection
- mysqli_info(); info about rows affected by last query
- mysqli_master_query(); force query to run on master
- mysqli_ping(); ping / reconnect
- mysqli_stat(); one line summary of server status
-
- oci_password_change()
-
- Also consider master/slave and/or failover server configuration.
-
-
-Postgres:
-=========
-
- - Real large object support.
- - Someone with more pgsql experience can suggest more features
-
-Oracle:
-=======
-
- - Support for array types and collections.
-
-PDO Session module:
-===================
-
- - Is it worth writing in C?
- Probably not.
-
-
-vim:se et ts=2 sw=2 tw=78:
-
diff --git a/ext/pdo/package2.xml b/ext/pdo/package2.xml
deleted file mode 100644
index add5a47fc3..0000000000
--- a/ext/pdo/package2.xml
+++ /dev/null
@@ -1,134 +0,0 @@
-<?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>2006-05-01</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>
-It is highly recommended that you update to PHP 5.1 or higher before using PDO.
-This PECL release corresponds to the PHP 5.1.3 release.
-
-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.
-
-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 **
-- Added PDO::PARAM_EVT_* family of constants. (Sara)
-- Fixed bug #37167 (PDO segfaults when throwing exception from the
- fetch handler). (Tony)
-- Fixed memory corruption when PDO::FETCH_LAZY mode is being used. (Ilia)
-- Fixed bug #36222 (errorInfo in PDOException is always NULL). (Ilia)
-- Fixed bug #35797 (segfault on PDOStatement::execute() with
- zend.ze1_compatibility_mode = On). (Tony, Ilia)
-- 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; &quot;new PDOStatement&quot; 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 b89c951755..77f731a666 100644
--- a/ext/pdo/pdo.c
+++ b/ext/pdo/pdo.c
@@ -156,7 +156,7 @@ static PHP_GINIT_FUNCTION(pdo)
}
/* }}} */
-PDO_API int php_pdo_register_driver(pdo_driver_t *driver) /* {{{ */
+PDO_API int php_pdo_register_driver(const pdo_driver_t *driver) /* {{{ */
{
if (driver->api_version != PDO_DRIVER_API) {
zend_error(E_ERROR, "PDO: driver %s requires PDO API version " ZEND_ULONG_FMT "; this is PDO version %d",
@@ -168,11 +168,11 @@ PDO_API int php_pdo_register_driver(pdo_driver_t *driver) /* {{{ */
return FAILURE; /* NOTREACHED */
}
- return zend_hash_str_add_ptr(&pdo_driver_hash, (char*)driver->driver_name, driver->driver_name_len, driver) != NULL;
+ return zend_hash_str_add_ptr(&pdo_driver_hash, (char*)driver->driver_name, driver->driver_name_len, (void*)driver) != NULL;
}
/* }}} */
-PDO_API void php_pdo_unregister_driver(pdo_driver_t *driver) /* {{{ */
+PDO_API void php_pdo_unregister_driver(const pdo_driver_t *driver) /* {{{ */
{
if (!zend_hash_str_exists(&module_registry, "pdo", sizeof("pdo") - 1)) {
return;
diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c
index afca2d1cfb..9fbfc1ff57 100644
--- a/ext/pdo/pdo_dbh.c
+++ b/ext/pdo/pdo_dbh.c
@@ -359,18 +359,11 @@ static PHP_METHOD(PDO, dbh_constructor)
/* all set */
if (is_persistent) {
- zend_resource le;
-
/* register in the persistent list etc. */
/* we should also need to replace the object store entry,
since it was created with emalloc */
-
- le.type = php_pdo_list_entry();
- le.ptr = dbh;
- GC_REFCOUNT(&le) = 1;
-
- if ((zend_hash_str_update_mem(&EG(persistent_list),
- (char*)dbh->persistent_id, dbh->persistent_id_len, &le, sizeof(le))) == NULL) {
+ if ((zend_register_persistent_resource(
+ (char*)dbh->persistent_id, dbh->persistent_id_len, dbh, php_pdo_list_entry())) == NULL) {
php_error_docref(NULL, E_ERROR, "Failed to register persistent entry");
}
}
@@ -449,7 +442,6 @@ static void pdo_stmt_construct(zend_execute_data *execute_data, pdo_stmt_t *stmt
zend_fcall_info_args(&fci, ctor_args);
- fcc.initialized = 1;
fcc.function_handler = dbstmt_ce->constructor;
fcc.calling_scope = zend_get_executed_scope();
fcc.called_scope = Z_OBJCE_P(object);
@@ -880,7 +872,7 @@ static PHP_METHOD(PDO, getAttribute)
array_init(return_value);
add_next_index_str(return_value, zend_string_copy(dbh->def_stmt_ce->name));
if (!Z_ISUNDEF(dbh->def_stmt_ctor_args)) {
- if (Z_REFCOUNTED(dbh->def_stmt_ctor_args)) Z_ADDREF(dbh->def_stmt_ctor_args);
+ Z_TRY_ADDREF(dbh->def_stmt_ctor_args);
add_next_index_zval(return_value, &dbh->def_stmt_ctor_args);
}
return;
@@ -1352,9 +1344,6 @@ static union _zend_function *dbh_method_get(zend_object **object, zend_string *m
pdo_dbh_object_t *dbh_obj = php_pdo_dbh_fetch_object(*object);
zend_string *lc_method_name;
- lc_method_name = zend_string_init(ZSTR_VAL(method_name), ZSTR_LEN(method_name), 0);
- zend_str_tolower_copy(ZSTR_VAL(lc_method_name), ZSTR_VAL(method_name), ZSTR_LEN(method_name));
-
if ((fbc = std_object_handlers.get_method(object, method_name, key)) == NULL) {
/* not a pre-defined method, nor a user-defined method; check
* the driver specific methods */
@@ -1366,11 +1355,12 @@ static union _zend_function *dbh_method_get(zend_object **object, zend_string *m
}
}
+ lc_method_name = zend_string_tolower(method_name);
fbc = zend_hash_find_ptr(dbh_obj->inner->cls_methods[PDO_DBH_DRIVER_METHOD_KIND_DBH], lc_method_name);
+ zend_string_release(lc_method_name);
}
out:
- zend_string_release(lc_method_name);
return fbc;
}
@@ -1561,7 +1551,7 @@ zend_object *pdo_dbh_new(zend_class_entry *ce)
{
pdo_dbh_object_t *dbh;
- dbh = ecalloc(1, sizeof(pdo_dbh_object_t) + zend_object_properties_size(ce));
+ dbh = zend_object_alloc(sizeof(pdo_dbh_object_t), ce);
zend_object_std_init(&dbh->std, ce);
object_properties_init(&dbh->std, ce);
rebuild_object_properties(&dbh->std);
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index 4f3d4cedb5..4805af76bf 100644
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -246,8 +246,8 @@ static void get_lazy_object(pdo_stmt_t *stmt, zval *return_value) /* {{{ */
zend_object_std_init(&row->std, pdo_row_ce);
ZVAL_OBJ(&stmt->lazy_object_ref, &row->std);
row->std.handlers = &pdo_row_object_handlers;
- GC_REFCOUNT(&stmt->std)++;
- GC_REFCOUNT(&row->std)--;
+ GC_ADDREF(&stmt->std);
+ GC_DELREF(&row->std);
}
ZVAL_COPY(return_value, &stmt->lazy_object_ref);
}
@@ -305,7 +305,7 @@ static int really_register_bound_param(struct pdo_bound_param_data *param, pdo_s
if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_STR && param->max_value_len <= 0 && !Z_ISNULL_P(parameter)) {
if (Z_TYPE_P(parameter) == IS_DOUBLE) {
char *p;
- int len = spprintf(&p, 0, "%.*H", (int) EG(precision), Z_DVAL_P(parameter));
+ int len = zend_spprintf_unchecked(&p, 0, "%.*H", (int) EG(precision), Z_DVAL_P(parameter));
ZVAL_STRINGL(parameter, p, len);
efree(p);
} else {
@@ -731,7 +731,6 @@ static int do_fetch_class_prepare(pdo_stmt_t *stmt) /* {{{ */
zend_fcall_info_args_ex(fci, ce->constructor, &stmt->fetch.cls.ctor_args);
- fcc->initialized = 1;
fcc->function_handler = ce->constructor;
fcc->calling_scope = zend_get_executed_scope();
fcc->called_scope = ce;
@@ -857,8 +856,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_
case PDO_FETCH_NUM:
case PDO_FETCH_NAMED:
if (!return_all) {
- ZVAL_NEW_ARR(return_value);
- zend_hash_init(Z_ARRVAL_P(return_value), stmt->column_count, NULL, ZVAL_PTR_DTOR, 0);
+ array_init_size(return_value, stmt->column_count);
} else {
array_init(return_value);
}
@@ -2133,11 +2131,15 @@ static PHP_METHOD(PDOStatement, debugDumpParams)
php_stream_printf(out, "Key: Position #" ZEND_ULONG_FMT ":\n", num);
}
- php_stream_printf(out, "paramno=%pd\nname=[%zd] \"%.*s\"\nis_param=%d\nparam_type=%d\n",
- param->paramno, param->name ? ZSTR_LEN(param->name) : 0, param->name ? (int) ZSTR_LEN(param->name) : 0,
- param->name ? ZSTR_VAL(param->name) : "",
- param->is_param,
- param->param_type);
+ php_stream_printf(out,
+ "paramno=" ZEND_LONG_FMT "\n"
+ "name=[%zd] \"%.*s\"\n"
+ "is_param=%d\n"
+ "param_type=%d\n",
+ param->paramno, param->name ? ZSTR_LEN(param->name) : 0, param->name ? (int) ZSTR_LEN(param->name) : 0,
+ param->name ? ZSTR_VAL(param->name) : "",
+ param->is_param,
+ param->param_type);
} ZEND_HASH_FOREACH_END();
}
@@ -2220,9 +2222,7 @@ static union _zend_function *dbstmt_method_get(zend_object **object_pp, zend_str
zend_string *lc_method_name;
zend_object *object = *object_pp;
- lc_method_name = zend_string_alloc(ZSTR_LEN(method_name), 0);
- zend_str_tolower_copy(ZSTR_VAL(lc_method_name), ZSTR_VAL(method_name), ZSTR_LEN(method_name));
-
+ lc_method_name = zend_string_tolower(method_name);
if ((fbc = zend_hash_find_ptr(&object->ce->function_table, lc_method_name)) == NULL) {
pdo_stmt_t *stmt = php_pdo_stmt_fetch_object(object);
@@ -2264,7 +2264,7 @@ static zend_object *dbstmt_clone_obj(zval *zobject)
pdo_stmt_t *stmt;
pdo_stmt_t *old_stmt;
- stmt = ecalloc(1, sizeof(pdo_stmt_t) + zend_object_properties_size(Z_OBJCE_P(zobject)));
+ stmt = zend_object_alloc(sizeof(pdo_stmt_t), Z_OBJCE_P(zobject));
zend_object_std_init(&stmt->std, Z_OBJCE_P(zobject));
object_properties_init(&stmt->std, Z_OBJCE_P(zobject));
@@ -2372,7 +2372,7 @@ zend_object *pdo_dbstmt_new(zend_class_entry *ce)
{
pdo_stmt_t *stmt;
- stmt = ecalloc(1, sizeof(pdo_stmt_t) + zend_object_properties_size(ce));
+ stmt = zend_object_alloc(sizeof(pdo_stmt_t), ce);
zend_object_std_init(&stmt->std, ce);
object_properties_init(&stmt->std, ce);
@@ -2453,7 +2453,7 @@ static void pdo_stmt_iter_move_forwards(zend_object_iterator *iter)
I->key++;
}
-static zend_object_iterator_funcs pdo_stmt_iter_funcs = {
+static const zend_object_iterator_funcs pdo_stmt_iter_funcs = {
pdo_stmt_iter_dtor,
pdo_stmt_iter_valid,
pdo_stmt_iter_get_data,
@@ -2634,8 +2634,7 @@ static union _zend_function *row_method_get(
zend_function *fbc;
zend_string *lc_method_name;
- lc_method_name = zend_string_alloc(ZSTR_LEN(method_name), 0);
- zend_str_tolower_copy(ZSTR_VAL(lc_method_name), ZSTR_VAL(method_name), ZSTR_LEN(method_name));
+ lc_method_name = zend_string_tolower(method_name);
if ((fbc = zend_hash_find_ptr(&pdo_row_ce->function_table, lc_method_name)) == NULL) {
zend_string_release(lc_method_name);
diff --git a/ext/pdo/php_pdo_driver.h b/ext/pdo/php_pdo_driver.h
index bcbe5b3672..52c64cda1c 100644
--- a/ext/pdo/php_pdo_driver.h
+++ b/ext/pdo/php_pdo_driver.h
@@ -435,7 +435,7 @@ enum pdo_placeholder_support {
struct _pdo_dbh_t {
/* driver specific methods */
- struct pdo_dbh_methods *methods;
+ const struct pdo_dbh_methods *methods;
/* driver specific data */
void *driver_data;
@@ -563,7 +563,7 @@ struct pdo_bound_param_data {
/* represents a prepared statement */
struct _pdo_stmt_t {
/* driver specifics */
- struct pdo_stmt_methods *methods;
+ const struct pdo_stmt_methods *methods;
void *driver_data;
/* if true, we've already successfully executed this statement at least
@@ -661,9 +661,9 @@ struct _pdo_row_t {
};
/* call this in MINIT to register your PDO driver */
-PDO_API int php_pdo_register_driver(pdo_driver_t *driver);
+PDO_API int php_pdo_register_driver(const pdo_driver_t *driver);
/* call this in MSHUTDOWN to unregister your PDO driver */
-PDO_API void php_pdo_unregister_driver(pdo_driver_t *driver);
+PDO_API void php_pdo_unregister_driver(const pdo_driver_t *driver);
/* For the convenience of drivers, this function will parse a data source
* string, of the form "name=value; name2=value2" and populate variables