#46448 [NEW]: mysqli_multi_query with buggy queries closes MySQL connection
From: pcdinh at gmail dot com
Operating system: Windows XP SP3
PHP version: 5.2.7RC2
PHP Bug Type: MySQLi related
Bug description: mysqli_multi_query with buggy queries closes MySQL connection
Description:
------------
Make a multiple queries that contains a buggy DML SQL command with
mysqli_multi_query can cause MySQL connection closed: mysqli_ping returns
false right after mysqli_multi_query() invocation.
Apache 2.2.6
MySQL 5.0.67
Reproduce code:
---------------
<?php
ini_set('mysqli.reconnect', 'Off');
$mysqli = mysqli_init();
mysqli_real_connect($mysqli, "localhost", "root", "123456",
"test");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/*
CREATE TABLE test2 (
id int(11) DEFAULT NULL,
username varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Buggy DML SQL command: INSERT INTO test2 VALUES (1008-, 'pcdinh5')
*/
$query = "INSERT INTO test2 VALUES (1007, 'pcdinh4');INSERT INTO test2
VALUES (1008-, 'pcdinh5');";
/* execute multi query */
mysqli_multi_query($mysqli, $query);
if (false === mysqli_ping($mysqli))
{
exit('Database connection is closed');
}
?>
Expected result:
----------------
Nothing happens. If this script produces a message: Database connection is
closed means there is a problem
Actual result:
--------------
This script produces a message: Database connection is closed
--
Edit bug report at http://bugs.php.net/?id=46448&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46448&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46448&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46448&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=46448&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=46448&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=46448&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=46448&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=46448&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=46448&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=46448&r=support
Expected behavior: http://bugs.php.net/fix.php?id=46448&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=46448&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=46448&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=46448&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46448&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=46448&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=46448&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=46448&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=46448&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=46448&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=46448&r=mysqlcfg
Thread (3 messages)
- pcdinh at gmail dot com