Bug #20210 Connector/PHP stored procedure query error
Submitted: 1 Jun 2006 18:46 Modified: 1 Jul 2006 19:29
Reporter: BattleMan BattleClan Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:MySQL 5.0.21 + PHP 5.1.4 OS:Windows (win XP)
Assigned to: CPU Architecture:Any

[1 Jun 2006 18:46] BattleMan BattleClan
Description:
i have defined a simple stored procedure named 'a' which performs a "select 1;" statement.

when i try to execute the stored procedure via a single MySQL object [Connector/PHP] i sometimes [about 1 in 3 attempts] get a "lost connection to MySQL server during query" and on the server end i retrieve the error log of "[Warning] Aborted connection 21 to db: 'budget' user: 'root' host: 'localhost' (Got an error reading communication packets)"

the query i use to execute the stored procedure is "call a();"

when i attempt the same with the query "select 1;" [as in the procedure body] everything works as it should have.

i have performed two more tests....
1. d/l the latest Connector/PHP from mysql.com [i.e. am not using the built it mysql version shipped along with php]
2. to test if the problem is Connector/PHP specific i have d/l Connector/J and tested the same. only this time everything worked as should have.

i hereby conclude that there is some kind of a problem with Connector/PHP regarding stored procedures.

i should mention that when i performed some kind of delay between the query executions the frequency of the problem deminished.

i would be more than happy to help in any way i can. i have also TCP dumps of the client-server communication.

thanks.

How to repeat:
definition of the Stored procedure >>>

DELIMITER $$

DROP PROCEDURE IF EXISTS `budget`.`a` $$
CREATE PROCEDURE `a`()
BEGIN

select "HI_I_AM_HERE" as C;

END $$

DELIMITER ;

the PHP code >>>
    $MySQL = new mysqli( "localhost" , "root" , "" );
    $MySQL->real_query( "use Budget" );
    
    $r = $MySQL->query( "call a()" );
    
    if ($MySQL->error )
      echo $MySQL->error . "\n";
    else
      echo "ok on #1\n";

    $r = $MySQL->query( "call a()" );
    
    if ($MySQL->error )
      echo $MySQL->error . "\n";
    else
      echo "ok on #2\n";

output [for a few runs] >>>

D:\Program Files\php>php trial.php
ok on #1
ok on #2

D:\Program Files\php>php trial.php
ok on #1
ok on #2

D:\Program Files\php>php trial.php
ok on #1
Lost connection to MySQL server during query

D:\Program Files\php>php trial.php
ok on #1
ok on #2

D:\Program Files\php>php trial.php
ok on #1
ok on #2

D:\Program Files\php>php trial.php
ok on #1
Lost connection to MySQL server during query

D:\Program Files\php>php trial.php
ok on #1
ok on #2

D:\Program Files\php>php trial.php
ok on #1
ok on #2

D:\Program Files\php>php trial.php
ok on #1
ok on #2
[1 Jun 2006 18:55] BattleMan BattleClan
i wanted to note that i have tried another option listed below.
this time i used multi_query calls.
the results are....

for code >>>

    $MySQL = new mysqli( "localhost" , "root" , "" );
    $MySQL->real_query( "use Budget" );
    
    $MySQL->multi_query( "call a()" );
    
    $r = $MySQL->store_result( );
    $r->free( );
    
    if ($MySQL->error )
      echo $MySQL->error . "\n";
    else
      echo "ok on #1\n";
      
    $MySQL->multi_query( "call a()" );
    
    $r = $MySQL->store_result( );
    $r->free( );
    
    if ($MySQL->error )
      echo $MySQL->error . "\n";
    else
      echo "ok on #2\n";

the output >>>

D:\Program Files\php>php trial.php
ok on #1
PHP Fatal error:  Call to a member function free() on a non-object in D:\Program Files\php\trial.php on line 19

Fatal error: Call to a member function free() on a non-object in D:\Program File s\php\trial.php on line 19

D:\Program Files\php>php trial.php
ok on #1
ok on #2

D:\Program Files\php>php trial.php
ok on #1
ok on #2
[1 Jun 2006 19:16] BattleMan BattleClan
wanted to add that this bug is probably the same as #15853 only i believe that the time elapsed, the diffrent version and the extra checks i've done [being it Connector/J and multi_query] justify opening a new bug report.
[1 Jun 2006 19:29] Valeriy Kravchuk
Thank you for a problem report. Your initial description looks similar to a (verified) bug #15752. Please, check.
[1 Jul 2006 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".