php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36658 mysqli_multi_query randomly fails
Submitted: 2006-03-08 21:30 UTC Modified: 2006-03-09 10:29 UTC
From: jacob at aub dot dk Assigned:
Status: Not a bug Package: MySQLi related
PHP Version: 5.1.2 OS: FreeBSD
Private report: No CVE-ID: None
 [2006-03-08 21:30 UTC] jacob at aub dot dk
Description:
------------
I'm seeing indeterministic behaviour from mysqli_multi_query(). In #35333 it is stated that one must process the result sets from mysql before executing another query. The following seem to somewhat disprove that, as it works sometimes. If processing of resultsets is a requirement then I believe the documentation should be updated to reflect this as it is not consistent behaviour in regard to regular query() calls, as I can perform multiple query() calls without processing anything.

Reproduce code:
---------------
<?php
require_once('dbsettings.php');
$mysqli = new mysqli($hostname, $username, $password, $database);
$mysqli->multi_query("CREATE TABLE IF NOT EXISTS bar(id int); INSERT INTO bar(id) VALUES(1); ");
$result = $mysqli->query("SELECT COUNT(*) FROM bar");
if($result === FALSE) {
  print "ERROR: ".$mysqli->error."\n";
} else {
  $row = $result->fetch_assoc();
  print $row['COUNT(*)']."\n";
}
?>

Expected result:
----------------
% php multiquerybug.php
3
% php multiquerybug.php
4
% php multiquerybug.php
5

Actual result:
--------------
% php multiquerybug.php
3
% php multiquerybug.php
ERROR: MySQL server has gone away
% php multiquerybug.php
5

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-09 10:29 UTC] georg@php.net
Can't reproduce (tested with MySQL 5.0.18 Server and client libs). 

As expected I'm always getting error "Packets out of order (Found: 2, expected 1)". This is correct behaviour, the server sends two errorcode packets.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC