summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorHartmut Holzgraefe <hholzgra@php.net>2008-01-01 16:51:09 +0000
committerHartmut Holzgraefe <hholzgra@php.net>2008-01-01 16:51:09 +0000
commit3e34e202d524e80984a3c1aa44bfa2ca78e5c796 (patch)
treed75b20ca1f7138963a4505916ed6f1aebfa6c12f /ext
parentaaeded2ac7cf22e60f31912cff1e7a85c8f42a24 (diff)
downloadphp-git-3e34e202d524e80984a3c1aa44bfa2ca78e5c796.tar.gz
MFH: Fix for bug #42548 "PROCEDURE xxx can't return a result set"
Diffstat (limited to 'ext')
-rw-r--r--ext/mysqli/mysqli_api.c3
-rw-r--r--ext/mysqli/tests/bug42548.phpt51
2 files changed, 54 insertions, 0 deletions
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c
index 8fce7b4f26..48027f0318 100644
--- a/ext/mysqli/mysqli_api.c
+++ b/ext/mysqli/mysqli_api.c
@@ -1438,6 +1438,9 @@ 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') || PG(safe_mode)) {
diff --git a/ext/mysqli/tests/bug42548.phpt b/ext/mysqli/tests/bug42548.phpt
new file mode 100644
index 0000000000..a7d5f39ff7
--- /dev/null
+++ b/ext/mysqli/tests/bug42548.phpt
@@ -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