Edit report at http://bugs.php.net/bug.php?id=54221&edit=1

 ID:                 54221
 Updated by:         and...@php.net
 Reported by:        glen at delfi dot ee
 Summary:            mysqli::get_warnings segfault when used in multi
                     queries
-Status:             Assigned
+Status:             Closed
 Type:               Bug
 Package:            MySQLi related
 PHP Version:        5.3.5
 Assigned To:        mysql
 Block user comment: N
 Private report:     N

 New Comment:

Fixed. The fix will be part of 5.3.7.


Previous Comments:
------------------------------------------------------------------------
[2011-03-17 11:28:55] and...@php.net

Automatic comment from SVN on behalf of andrey
Revision: http://svn.php.net/viewvc/?view=revision&revision=309339
Log: Fix for bug #54221 mysqli::get_warnings segfault when used in multi
queries

------------------------------------------------------------------------
[2011-03-17 11:06:30] and...@php.net

Reproduced

------------------------------------------------------------------------
[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

Reply via email to