|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2021-10-01 14:22 UTC] madri2 at gmail dot com
Description:
------------
Do an unbuffered mysqli query and do a while to read all results,
kill the mysql request in mysql, then php will only trigger a warning when doing fetch_assoc
Warning: mysqli_result::fetch_assoc(): Error while reading a row
while ($found = $req->fetch_assoc()) {
}
will only stop the loop when the mysql query is killed, instead of throwing an error
I've tried to set mysqli_report(MYSQLI_REPORT_ALL & ~MYSQLI_REPORT_INDEX);
but this doesn't change anything
Expected result:
----------------
An exception thrown
Actual result:
--------------
Warning: mysqli_result::fetch_assoc(): Error while reading a row
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 19:00:01 2025 UTC |
<?php error_reporting(E_ALL); set_time_limit(0); ini_set('memory_limit','2000M'); ini_set('display_errors', true); $dbo = mysqli_connect('localhost', 'xxx', 'yyy', ''); $dbo2 = mysqli_connect('localhost', 'xxx', 'yyy', ''); mysqli_report(MYSQLI_REPORT_ALL & ~MYSQLI_REPORT_INDEX); $req = $dbo->query("SELECT * FROM mustBeATableBigEnough", MYSQLI_USE_RESULT); $numFound = 0; while ($found = $req->fetch_assoc()) { $numFound++; $req2 = $dbo2->query("SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE ID = '".$dbo->thread_id."'"); if ($found2 = $req2->fetch_assoc()) { print_r($found2); $dbo2->query("KILL ".$found2['ID']); } $req2->free(); } $req->free(); echo 'numFound : '.$numFound."\n"; it outputs : Array ( [ID] => 2348965 [USER] => yyyyy [HOST] => localhost [DB] => zzzzzz [COMMAND] => Query [TIME] => 0 [STATE] => Sending data [INFO] => SELECT * FROM xxxx [TIME_MS] => 1.708 [STAGE] => 0 [MAX_STAGE] => 0 [PROGRESS] => 0.000 [MEMORY_USED] => 212672 [MAX_MEMORY_USED] => 212672 [EXAMINED_ROWS] => 0 [QUERY_ID] => 554751313 [INFO_BINARY] => SELECT * FROM xxxx [TID] => 3625133 ) Warning: mysqli_result::fetch_assoc(): Error while reading a row in ....testBug.php on line 54 numFound : 52 the table contains millions of entries