diff options
author | Andrey Hristov <andrey@php.net> | 2014-04-10 16:44:54 +0300 |
---|---|---|
committer | Andrey Hristov <andrey@php.net> | 2014-04-10 16:44:54 +0300 |
commit | 63791d055ad64762c3f63e08ca7ad8ba1f44e0ab (patch) | |
tree | cf93f62a6b9b2c0c85cf00b0094501fa8166d938 /ext/mysqli/mysqli_api.c | |
parent | 973f379efcb43887a83317482c7916004d1a2506 (diff) | |
download | php-git-63791d055ad64762c3f63e08ca7ad8ba1f44e0ab.tar.gz |
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]
Diffstat (limited to 'ext/mysqli/mysqli_api.c')
-rw-r--r-- | ext/mysqli/mysqli_api.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index 53639a0670..d14625e0f7 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -1477,7 +1477,7 @@ void php_mysqli_init(INTERNAL_FUNCTION_PARAMETERS) We create always persistent, as if the user want to connecto to p:somehost, we can't convert the handle then */ - if (!(mysql->mysql = mysql_init(TRUE))) + if (!(mysql->mysql = mysqlnd_init(MYSQLND_CLIENT_KNOWS_RSET_COPY_DATA, TRUE))) #endif { efree(mysql); @@ -2557,7 +2557,7 @@ PHP_FUNCTION(mysqli_stmt_sqlstate) } /* }}} */ -/* {{{ proto object mysqli_store_result(object link) +/* {{{ proto object mysqli_store_result(object link [, flags]) Buffer result set on client */ PHP_FUNCTION(mysqli_store_result) { @@ -2565,13 +2565,19 @@ PHP_FUNCTION(mysqli_store_result) MYSQL_RES *result; zval *mysql_link; MYSQLI_RESOURCE *mysqli_resource; + long flags = 0; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|l", &mysql_link, mysqli_link_class_entry, &flags) == FAILURE) { return; } MYSQLI_FETCH_RESOURCE_CONN(mysql, &mysql_link, MYSQLI_STATUS_VALID); - - if (!(result = mysql_store_result(mysql->mysql))) { +#if MYSQLI_USE_MYSQLND + result = flags & MYSQLI_STORE_RESULT_COPY_DATA? mysqlnd_store_result_ofs(mysql->mysql) : mysqlnd_store_result(mysql->mysql); +#else + result = mysql_store_result(mysql->mysql); +#endif + if (!result) { MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); RETURN_FALSE; } |