php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37732 calling mysqli_multi_query with multiple queries stops subsequent queries
Submitted: 2006-06-07 16:13 UTC Modified: 2006-06-08 09:40 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: jerry dot walsh at gmail dot com Assigned:
Status: Not a bug Package: MySQLi related
PHP Version: 5.1.4 OS: FreeBSD 6.1-STABLE
Private report: No CVE-ID: None
 [2006-06-07 16:13 UTC] jerry dot walsh at gmail dot com
Description:
------------
Calling mysqli_multi_query with multiple insert queries causes subsequent calls to mysqli_query or mysqli_multi_query to fail with a MySQL lost connection to server (err#2031).

OS - FreeBSD 6.1
MySQL - 5.0.22 (also tested on 5.0.18)
PHP - 5.1.4
MySQLi version - 5.1.4

Reproduce code:
---------------
 $strTestDatabaseName = "Testdb";
 $db_hostname = "localhost";
 $db_username = "username";
 $db_password = "password";
 
 $m_mysqlTestConn = mysqli_connect($db_hostname, $db_username, $db_password, $strTestDatabaseName);

 // succeeds...
 $strSQL="INSERT INTO billingrecurringinvoicedetail (billingrecurringinvoicedetail_quantity, billingrecurringinvoicedetail_dontrecur)
      VALUES (1,false);INSERT INTO billingrecurringinvoicedetail (billingrecurringinvoicedetail_quantity, billingrecurringinvoicedetail_dontrecur)
      VALUES (1,false);";
 
  mysqli_multi_query($m_mysqlTestConn, $strSQL) ||
  print ("Database insert Failed:<br>".mysqli_error($m_mysqlTestConn)." Code:".mysqli_errno ($m_mysqlTestConn));
 
 $strSQL="SELECT *  FROM billingrecurringinvoice WHERE billingrecurringinvoice_id = 429;";

 // fails
  (mysqli_multi_query($m_mysqlTestConn, $strSQL)) || 
  print ("Database select Failed:<br>".mysqli_error($m_mysqlTestConn)." Code:".mysqli_errno ($m_mysqlTestConn));
 $mysql_result = mysqli_store_result($m_mysqlTestConn);  

 mysqli_close($m_mysqlTestConn);


Expected result:
----------------
I expected the select to work after the double insert

Actual result:
--------------
This line fails:

$strSQL="SELECT *  FROM billingrecurringinvoice WHERE billingrecurringinvoice_id = 429;";

 // fails
  (mysqli_multi_query($m_mysqlTestConn, $strSQL)) || 
  print ("Database select Failed:<br>".mysqli_error($m_mysqlTestConn)." 

With:

Database select Failed:
Lost connection to MySQL server during query Code:2013

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-06-07 16:18 UTC] jerry dot walsh at gmail dot com
This will create the table structure:


DROP TABLE IF EXISTS `billingrecurringinvoice`;
CREATE TABLE `billingrecurringinvoice` (
  `billingrecurringinvoice_id` int(10) unsigned NOT NULL auto_increment,
  `billingrecurringinvoice_currencyid` int(10) unsigned NOT NULL,
  `billingrecurringinvoice_status` enum('ACTIVE','PENDING_APPROVAL') NOT NULL,
  `billingrecurringinvoice_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
  PRIMARY KEY  (`billingrecurringinvoice_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;


DROP TABLE IF EXISTS `billingrecurringinvoicedetail`;
CREATE TABLE `billingrecurringinvoicedetail` (
  `billingrecurringinvoicedetail_id` int(10) unsigned NOT NULL auto_increment,
  `billingrecurringinvoicedetail_billingrecurringinvoiceid` int(10) unsigned default NULL,
  `billingrecurringinvoicedetail_productid` int(10) unsigned default NULL,
  `billingrecurringinvoicedetail_quantity` int(10) unsigned NOT NULL,
  `billingrecurringinvoicedetail_dontrecur` tinyint(3) unsigned NOT NULL default '0',
  `billingrecurringinvoicedetail_description` char(255) default NULL,
  `billingrecurringinvoicedetail_price` float default NULL,
  PRIMARY KEY  (`billingrecurringinvoicedetail_id`),
  KEY `IX_productfilesearch` (`billingrecurringinvoicedetail_billingrecurringinvoiceid`,`billingrecurringinvoicedetail_productid`)

 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 [2006-06-08 09:40 UTC] georg@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

when using mysqli_multi_query you always have to process the resultsets before sending a new statement to the server. Even if there is NO resultset (for non SELECT/SHOW/DESRIBE statements) you have to do that to obtain errorcodes for the single statements.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 16:01:29 2024 UTC