]> granicus.if.org Git - php/commitdiff
MFH: Fix for bug #42548 "PROCEDURE xxx can't return a result set"
authorHartmut Holzgraefe <hholzgra@php.net>
Tue, 25 Dec 2007 18:55:40 +0000 (18:55 +0000)
committerHartmut Holzgraefe <hholzgra@php.net>
Tue, 25 Dec 2007 18:55:40 +0000 (18:55 +0000)
NEWS
ext/mysqli/mysqli_api.c
ext/mysqli/tests/bug42548.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 9706a29393d6b03bbb439b07faa573b729ce59a3..509a7cd118cb386435308ee235ba6ecb9b42684d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -77,6 +77,7 @@ PHP                                                                        NEWS
 - Fixed bug #42657 (ini_get() returns incorrect value when default is NULL).
   (Jani)
 - Fixed bug #42637 (SoapFault : Only http and https are allowed). (Bill Moran)
+- Fixed bug #42548 (mysqli PROCEDURE calls can't return result sets). (hartmut)
 - Fixed bug #42509 (gmp leaks memory when gmp_init() not used). (Stas)
 - Fixed bug #42284 (duplicate of #39700). (Lars W)
 - Fixed bug #42069 (parse_ini_file() allows using some non-alpha numeric
index d857706a4e1aada32c223c1dd3315c81891f8125..258ba8e863e764d887a9581346d48c03fbe3e214 100644 (file)
@@ -1621,6 +1621,8 @@ PHP_FUNCTION(mysqli_real_connect)
 
        MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_INITIALIZED);
 
+       /* set some required options */
+       flags |= CLIENT_MULTI_RESULTS; /* needed for mysql_multi_query() */
        /* remove some insecure options */
        flags &= ~CLIENT_MULTI_STATEMENTS;   /* don't allow multi_queries via connect parameter */
        if (PG(open_basedir) && PG(open_basedir)[0] != '\0') {
diff --git a/ext/mysqli/tests/bug42548.phpt b/ext/mysqli/tests/bug42548.phpt
new file mode 100644 (file)
index 0000000..a7d5f39
--- /dev/null
@@ -0,0 +1,51 @@
+--TEST--
+Bug #42548 PROCEDURE xxx can't return a result set in the given context (works in 5.2.3!!)
+--SKIPIF--
+<?php if (!extension_loaded("mysqli")) print "skip"; ?>
+--FILE--
+<?php
+$mysqli = mysqli_init();
+$mysqli->real_connect('localhost', 'root', '', 'test');
+if (mysqli_connect_errno()) {
+  printf("Connect failed: %s\n", mysqli_connect_error());
+  exit();
+}
+
+$mysqli->query("DROP PROCEDURE IF EXISTS p1") or die($mysqli->error);
+$mysqli->query("CREATE PROCEDURE p1() BEGIN SELECT 23; SELECT 42; END") or die($mysqli->error);
+
+if ($mysqli->multi_query("CALL p1();"))
+{      
+  do   
+  {    
+    if ($objResult = $mysqli->store_result()) {
+      while ($row = $objResult->fetch_assoc()) {
+        print_r($row);
+      }
+      $objResult->close();
+      if ($mysqli->more_results()) {
+        print "----- next result -----------\n";
+      }
+    } else {
+      print "no results found";
+    }
+  } while ($mysqli->more_results() && $mysqli->next_result());
+} else {
+  print $mysqli->error;
+}
+
+$mysqli->query("DROP PROCEDURE p1") or die($mysqli->error);
+$mysqli->close();
+?>
+--EXPECT--     
+Array
+(
+    [23] => 23
+)
+----- next result -----------
+Array
+(
+    [42] => 42
+)
+----- next result -----------
+no results found