From 6b804b96b8c454954d30ed8f0cf1a05d91801c4f Mon Sep 17 00:00:00 2001 From: Andrey Hristov Date: Wed, 5 Mar 2014 16:22:23 +0200 Subject: Refactor the result set data structures. Move more to the buffered and unbuffered substructures. Add methods to these too. Preparing for pluggable interface for returning data to the engine (zvals, c-style, something else) --- ext/mysqlnd/mysqlnd_ext_plugin.c | 62 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'ext/mysqlnd/mysqlnd_ext_plugin.c') diff --git a/ext/mysqlnd/mysqlnd_ext_plugin.c b/ext/mysqlnd/mysqlnd_ext_plugin.c index f40688b272..706111346f 100644 --- a/ext/mysqlnd/mysqlnd_ext_plugin.c +++ b/ext/mysqlnd/mysqlnd_ext_plugin.c @@ -70,6 +70,32 @@ PHPAPI void ** _mysqlnd_plugin_get_plugin_result_data(const MYSQLND_RES * result /* }}} */ +/* {{{ _mysqlnd_plugin_get_plugin_result_unbuffered_data */ +PHPAPI void ** _mysqlnd_plugin_get_plugin_result_unbuffered_data(const MYSQLND_RES_UNBUFFERED * result, unsigned int plugin_id TSRMLS_DC) +{ + DBG_ENTER("_mysqlnd_plugin_get_plugin_result_data"); + DBG_INF_FMT("plugin_id=%u", plugin_id); + if (!result || plugin_id >= mysqlnd_plugin_count()) { + return NULL; + } + DBG_RETURN((void *)((char *)result + sizeof(MYSQLND_RES_UNBUFFERED) + plugin_id * sizeof(void *))); +} +/* }}} */ + + +/* {{{ _mysqlnd_plugin_get_plugin_result_buffered_data */ +PHPAPI void ** _mysqlnd_plugin_get_plugin_result_buffered_data(const MYSQLND_RES_BUFFERED * result, unsigned int plugin_id TSRMLS_DC) +{ + DBG_ENTER("_mysqlnd_plugin_get_plugin_result_data"); + DBG_INF_FMT("plugin_id=%u", plugin_id); + if (!result || plugin_id >= mysqlnd_plugin_count()) { + return NULL; + } + DBG_RETURN((void *)((char *)result + sizeof(MYSQLND_RES_BUFFERED) + plugin_id * sizeof(void *))); +} +/* }}} */ + + /* {{{ _mysqlnd_plugin_get_plugin_protocol_data */ PHPAPI void ** _mysqlnd_plugin_get_plugin_protocol_data(const MYSQLND_PROTOCOL * protocol, unsigned int plugin_id TSRMLS_DC) @@ -161,6 +187,42 @@ mysqlnd_result_set_methods(struct st_mysqlnd_res_methods * methods) /* }}} */ +/* {{{ mysqlnd_result_unbuffered_get_methods */ +PHPAPI struct st_mysqlnd_result_unbuffered_methods * +mysqlnd_result_unbuffered_get_methods() +{ + return &MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_result_unbuffered); +} +/* }}} */ + + +/* {{{ mysqlnd_result_unbuffered_set_methods */ +PHPAPI void +mysqlnd_result_unbuffered_set_methods(struct st_mysqlnd_result_unbuffered_methods * methods) +{ + MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_result_unbuffered) = *methods; +} +/* }}} */ + + +/* {{{ mysqlnd_result_buffered_get_methods */ +PHPAPI struct st_mysqlnd_result_buffered_methods * +mysqlnd_result_buffered_get_methods() +{ + return &MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_result_buffered); +} +/* }}} */ + + +/* {{{ mysqlnd_result_buffered_set_methods */ +PHPAPI void +mysqlnd_result_buffered_set_methods(struct st_mysqlnd_result_buffered_methods * methods) +{ + MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_result_buffered) = *methods; +} +/* }}} */ + + /* {{{ mysqlnd_stmt_get_methods */ PHPAPI struct st_mysqlnd_stmt_methods * mysqlnd_stmt_get_methods() -- cgit v1.2.1 From 63791d055ad64762c3f63e08ca7ad8ba1f44e0ab Mon Sep 17 00:00:00 2001 From: Andrey Hristov Date: Thu, 10 Apr 2014 16:44:54 +0300 Subject: New result fetching mode for mysqlnd, which should use less memory but implies more memory copy. The old method is still available and can be used. It stays as default. Choosing the method is through a flag to mysqli_query()/mysqli_real_query() New mode can be forced with an INI setting, for all extensions that support this mode (ext/mysql and mysqli, because PDO due to it's architecture can't support it) The setting is mysqlnd.fetch_data_copy=[0|1] --- ext/mysqlnd/mysqlnd_ext_plugin.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'ext/mysqlnd/mysqlnd_ext_plugin.c') diff --git a/ext/mysqlnd/mysqlnd_ext_plugin.c b/ext/mysqlnd/mysqlnd_ext_plugin.c index 706111346f..13f1e294dc 100644 --- a/ext/mysqlnd/mysqlnd_ext_plugin.c +++ b/ext/mysqlnd/mysqlnd_ext_plugin.c @@ -84,14 +84,26 @@ PHPAPI void ** _mysqlnd_plugin_get_plugin_result_unbuffered_data(const MYSQLND_R /* {{{ _mysqlnd_plugin_get_plugin_result_buffered_data */ -PHPAPI void ** _mysqlnd_plugin_get_plugin_result_buffered_data(const MYSQLND_RES_BUFFERED * result, unsigned int plugin_id TSRMLS_DC) +PHPAPI void ** _mysqlnd_plugin_get_plugin_result_buffered_data_zval(const MYSQLND_RES_BUFFERED_ZVAL * result, unsigned int plugin_id TSRMLS_DC) { DBG_ENTER("_mysqlnd_plugin_get_plugin_result_data"); DBG_INF_FMT("plugin_id=%u", plugin_id); if (!result || plugin_id >= mysqlnd_plugin_count()) { return NULL; } - DBG_RETURN((void *)((char *)result + sizeof(MYSQLND_RES_BUFFERED) + plugin_id * sizeof(void *))); + DBG_RETURN((void *)((char *)result + sizeof(MYSQLND_RES_BUFFERED_ZVAL) + plugin_id * sizeof(void *))); +} +/* }}} */ + +/* {{{ _mysqlnd_plugin_get_plugin_result_buffered_data */ +PHPAPI void ** _mysqlnd_plugin_get_plugin_result_buffered_data_c(const MYSQLND_RES_BUFFERED_C * result, unsigned int plugin_id TSRMLS_DC) +{ + DBG_ENTER("_mysqlnd_plugin_get_plugin_result_data"); + DBG_INF_FMT("plugin_id=%u", plugin_id); + if (!result || plugin_id >= mysqlnd_plugin_count()) { + return NULL; + } + DBG_RETURN((void *)((char *)result + sizeof(MYSQLND_RES_BUFFERED_C) + plugin_id * sizeof(void *))); } /* }}} */ -- cgit v1.2.1