php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50416 PROCEDURE db.myproc can't return a result set in the given context
Submitted: 2009-12-08 20:28 UTC Modified: 2010-02-08 13:10 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: ernesto_vargas at yahoo dot com Assigned: mysql (profile)
Status: Closed Package: MySQL related
PHP Version: 5.3, 6 OS: *
Private report: No CVE-ID: None
 [2009-12-08 20:28 UTC] ernesto_vargas at yahoo dot com
Description:
------------
Any call to a mysql stored procedure produces the following error:

"PROCEDURE database.store_proc_name can't return a result set in the given context"

When calling the stored procedure from mysql cli client do return the results correctly.

Tested against MySql 5.0 and 5.1.

Work on php-5.2.9 but not on php-5.3.0 or php-5.3.1


Reproduce code:
---------------
DELIMITER $$
CREATE PROCEDURE `myproc`()
BEGIN
SELECT 'it works!';
END$$

<?php
$link = mysql_connect('127.0.0.1','root','',false,65536);
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db('test', $link);
if (!$db_selected) {
    die ('Can\'t use maxdb : ' . mysql_error());
}
$query = 'CALL myproc();';
$result = mysql_query($query);
if (!$result) {
    $message  = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $query;
    die($message);
}
$row = mysql_fetch_row($result);
var_dump($row);
mysql_free_result($result);
mysql_close($link);

Expected result:
----------------
array(1) {
  ["it works!"]=>
  string(9) "it works!"
}


Actual result:
--------------
Warning: mysql_query(): PROCEDURE test.myproc can't return a result set in the given context in /home/html/sp_test.php on line 11
Invalid query: PROCEDURE test.myproc can't return a result set in the given context
Whole query: CALL myproc();

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-08 21:57 UTC] jani@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

And if that does not work, please provide your configure line.
 [2009-12-08 22:44 UTC] ermesto_vargas at yahoo dot com
./configure --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --target=x86_64-redhat-linux-gnu --program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --cache-file=../config.cache --with-libdir=lib64 --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --disable-debug --with-pic --disable-rpath --without-pear --with-bz2 --with-exec-dir=/usr/bin --with-freetype-dir=/usr --with-png-dir=/usr --with-xpm-dir=/usr --enable-gd-native-ttf --with-t1lib=/usr --without-gdbm --with-gettext --with-gmp --with-iconv --with-jpeg-dir=/usr --with-openssl --with-pcre-regex=/usr --with-zlib --with-layout=GNU --enable-exif --enable-ftp --enable-magic-quotes --enable-sockets --enable-sysvsem --enable-sysvshm --enable-sysvmsg --with-kerberos --enable-ucd-snmp-hack --enable-shmop --enable-calendar --without-mime-magic --without-sqlite --with-libxml-dir=/usr --enable-xml --with-system-tzdata --with-mysql --without-gd --disable-dom --disable-dba --without-unixODBC --disable-pdo --disable-xmlreader --disable-xmlwriter --without-sqlite3 --disable-phar --disable-fileinfo --disable-json --without-pspell --disable-wddx --without-curl --disable-posix --disable-sysvmsg --disable-sysvshm --disable-sysvsem


Same results here is the result:
---------------------------------------------------------------------
Current PHP version: 5.3.2-dev
Current MYSQL version: 1.0

Warning: mysql_query(): PROCEDURE test.myproc can't return a result set in the given context in /home/html/sp_test.php on line 14
Invalid query: PROCEDURE test.myproc can't return a result set in the given context
Whole query: CALL myproc();
 [2009-12-17 08:23 UTC] jani@php.net
Works with latest PHP 5.2, fails with 5.3+.
 [2010-01-04 10:51 UTC] uw@php.net
This may be a valid error message, http://dev.mysql.com/doc/refman/5.0/en/create-procedure.html . What's the code of the SP?
 [2010-01-05 14:53 UTC] ernesto_vargas at yahoo dot com
@uw@php.net;

The store procedure code is a simple Hello World. Code is below.

DELIMITER $$
CREATE PROCEDURE `myproc`()
BEGIN
SELECT 'it works!';
END$$
 [2010-01-07 10:16 UTC] jani@php.net
Uwe, please notice my comment: It _works_ with PHP 5.2.x but NOT with 5.3, ergo, there's a bug in _PHP_ mysql stuff..
 [2010-01-12 21:11 UTC] ermesto_vargas at yahoo dot com
Any ETA on when this issue will be review? 

jani@php.net have clearly assert that the error occur on PHP 5.3+
 [2010-01-28 23:32 UTC] ermesto_vargas at yahoo dot com
Any news on these bug?
 [2010-02-08 11:41 UTC] andrey@php.net
andrey@winnie:~/dev/php/PHP_5_3$ ./php a.php
string(6) "5.1.44"
array(1) {
  [0]=>
  string(9) "it works!"
}


This is a mysqlnd build, with libmysql I see the error message. This will be further investigated.
 [2010-02-08 13:09 UTC] svn@php.net
Automatic comment from SVN on behalf of andrey
Revision: http://svn.php.net/viewvc/?view=revision&revision=294762
Log: Fix bug#50416
PROCEDURE db.myproc can't return a result set in the given context
 [2010-02-08 13:10 UTC] andrey@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Fix will be part of 5.3.3 and HEAD
 [2010-02-11 17:14 UTC] svn@php.net
Automatic comment from SVN on behalf of johannes
Revision: http://svn.php.net/viewvc/?view=revision&revision=294891
Log: merge r294762: Fix bug#50416
PROCEDURE db.myproc can't return a result set in the given context (andrey)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 13:01:29 2024 UTC