On 09/06/2011 10:45 AM, Stas Malyshev wrote:
Hi!
On 9/6/11 1:24 AM, Andrey Hristov wrote:
no, it's about consistency, which you want. mysqlnd should behave like
libmysql, and it is a test that can test it. What libmysql returns in
filtered in mysqli, mysqli_num_rows() is a direct wrapper around
mysql_num_rows(), and this is what we test.
Sorry, I don't understand. mysqlnd returns non-zero number of rows after
last fetch, libmysql does not, and that's what you test for. Are you
saying it's a bug in libmysql or mysqli driver that it doesn't return
that number?
Have you actually checked what libmysql returns??!?
If _you_ just have tried to do it, you might actually find that libmysql
does what mysqlnd did long ago, but mysqli was hiding it. Here is output
from what libmysql does, after removing the following check from
mysqli_api.c:
// if (mysqli_result_is_unbuffered_and_not_everything_is_fetched(result)) {
// php_error_docref(NULL TSRMLS_CC, E_WARNING, "Function cannot be used
with MYSQL_USE_RESULT");
// RETURN_LONG(0);
// }
Read and learn:
--------------------- libmysql ---------------------
andrey@poohie:/work/vanilla/php/php-src/branches/PHP_5_3$ ./php_libmysql
-r
'$c=mysqli_connect("127.0.0.1","root","root","test");$c->real_query("SELECT
42 FROM mysql.user LIMIT
2");$res=$c->use_result();printf("num_rows=%d\n",
mysqli_num_rows($res)); var_dump($res->fetch_assoc());
printf("num_rows=%d\n", mysqli_num_rows($res));
var_dump($res->fetch_assoc()); printf("num_rows=%d\n",
mysqli_num_rows($res)); var_dump($res->fetch_assoc());
printf("num_rows=%d\n", mysqli_num_rows($res));'
num_rows=0
array(1) {
[42]=>
string(2) "42"
}
num_rows=1
array(1) {
[42]=>
string(2) "42"
}
num_rows=2
NULL
num_rows=2
-------------- mysqlnd ----------------
andrey@poohie:/work/vanilla/php/php-src/branches/PHP_5_3$ ./php_mysqlnd
-r
'$c=mysqli_connect("127.0.0.1","root","root","test");$c->real_query("SELECT
42 FROM mysql.user LIMIT
2");$res=$c->use_result();printf("num_rows=%d\n",
mysqli_num_rows($res)); var_dump($res->fetch_assoc());
printf("num_rows=%d\n", mysqli_num_rows($res));
var_dump($res->fetch_assoc()); printf("num_rows=%d\n",
mysqli_num_rows($res)); var_dump($res->fetch_assoc());
printf("num_rows=%d\n", mysqli_num_rows($res));'
num_rows=0
array(1) {
[42]=>
string(2) "42"
}
num_rows=0
array(1) {
[42]=>
string(2) "42"
}
num_rows=0
NULL
num_rows=2
---------------
As you can see, libmysql returns different numbers, it increments the
number of rows. The used client library is 5.1.54, which is stock from
Ubuntu 11.04 .
Best,
Andrey
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php