Bug #54221 [NEW]: mysqli::get_warnings segfault when used in multi queries
| From: | glen at delfi dot ee | Date: | Fri, 11 Mar 2011 08:39:59 +0000 |
| Subject: | Bug #54221 [NEW]: mysqli::get_warnings segfault when used in multi queries | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-159390@lists.php.net to get a copy of this message | ||
From:
Operating system:
PHP version: 5.3.5
Package: MySQLi related
Bug Type: Bug
Bug description:mysqli::get_warnings segfault when used in multi queries
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 bug report at http://bugs.php.net/bug.php?id=54221&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54221&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54221&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54221&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=54221&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54221&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=54221&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=54221&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=54221&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=54221&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=54221&r=support
Expected behavior: http://bugs.php.net/fix.php?id=54221&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=54221&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=54221&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=54221&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54221&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=54221&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=54221&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=54221&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=54221&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=54221&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=54221&r=mysqlcfg