Bug #54221 [Opn->Asn]: mysqli::get_warnings segfault when used in multi queries
| From: | andrey@php.net | Date: | Thu, 17 Mar 2011 10:06:30 +0000 |
| Subject: | Bug #54221 [Opn->Asn]: mysqli::get_warnings segfault when used in multi queries | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-159546@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=54221&edit=1
ID: 54221
Updated by: andrey@php.net
Reported by: glen at delfi dot ee
Summary: mysqli::get_warnings segfault when used in multi
queries
-Status: Open
+Status: Assigned
Type: Bug
Package: MySQLi related
PHP Version: 5.3.5
-Assigned To:
+Assigned To: mysql
Block user comment: N
Private report: N
New Comment:
Reproduced
Previous Comments:
------------------------------------------------------------------------
[2011-03-11 09:39:58] glen at delfi dot ee
Description:
------------
http://php.net/manual/en/mysqli.get-warnings.php
can't use mysqli::get_warnings with multi queries reliably as it will
get either
segfault or empty result.
the code is supposed to print 2 times warning:
"Warning: 1050: Table 'a' already exists"
"Warning: 1050: Table 'a' already exists"
but instead it segfaults (PHP 5.3.5).
also if i run queries where only one warning is printed. it will not
segfault.
segfault seems to happen in ->next() call.
seems is because internally this is implemented as "SHOW WARNINGS" query
[1]
[1] http://svn.php.net/viewvc/php/php-
src/branches/PHP_5_3/ext/mysqli/mysqli_warning.c?annotate=306939#l76
segfault must be fixed, but regarding the usage, perhaps document that
you can't
use it sanely with multi queries, due limitations of mysql protocol, as
seems it
is problem in mysql protocol, that it returns warnings only from last of
the
multi query
Test script:
---------------
<?php
$dbh = new mysqli(null, null, null, "test");
if ($dbh->connect_error) {
die('Connect Error (' . $dbh->connect_errno . ') ' .
$dbh->connect_error);
}
$create = "create temporary table if not exists a (a int4)";
$query = "$create;$create";$create;";
if ($dbh->multi_query($query)) {
do {
$sth = $dbh->store_result();
if ($dbh->warning_count) {
$e = $dbh->get_warnings();
do {
echo "Warning: $e->errno:
$e->message\n";
} while ($e->next());
}
} while ($dbh->next_result());
}
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=54221&edit=1