Bug #11616 A prepared query crashes libmysql.dll in mysql 5.0
Submitted: 28 Jun 2005 17:32 Modified: 28 Jun 2005 17:49
Reporter: D SW Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:mysql 5.0 beta OS:Windows (Windows XP Professional SP2)
Assigned to: CPU Architecture:Any

[28 Jun 2005 17:32] D SW
Description:
Hi.

I have trying MySQL 5.0 and I found a severe bug (well, I think :-) ) that ocurrs using mySQL Browser and crashes the mysqld-nt service indefinitely, and there no are possible restart it. 

I try this stored procedure (yes, is a rare SP.... :-)   ):

delimiter \\
drop procedure if exists siscontrol.listado_clientes\\
create procedure listado_clientes
(
  out resultado tinyint
)
begin

  set @qry = concat('select * from', ' clientes where dni=?');

  prepare strQuery from @qry;
  set @a = '123456789' ;
  execute strQuery using @a;

  deallocate prepare strQuery;

--  select found_rows() into resultado;

end\\

delimiter ;

I created this SP several times, for learning the use of PREPARE statement, and when I create the SP at second, third,  or fourth..... time (random), appear the following message in the status bar of the query browser:

"Access violation at address 00814E34 in module libmysql.dll. Read of access 0000025C".

When I run the mySQL browser again, and when appears the message "Fetching data" in the schema tree (at right side of the query browser), few seconds later appears a message that says "Windows has encountered a problem in mysqld-nt service and must close it"

As I could not restart the mysqld-nt service, I had to uninstall all mySQL 5.0 applications, and edit manually the windows registry, deleting all references to mysql, and re-install mysql, mysql administrator, query browser, etc.

I hope to be helped to you to do mysql greater ;-)

How to repeat:
1. Create a database
2. Enter to mySQL Query browser selecting the database as default schema.
3. Create a stored procedure as I show above (don't forget the drop statement)
4. Press Execute Script several times.
5. If it crashes or appear the message of "access violation....", close the Query browser, try restarting mysqld-nt, the service starts successfully, run the Query Browser again.
6. However, when you run mySQL Query Browser again, the mysqld-nt service will crash again.

Suggested fix:
I don't know.... sorry :-(
[28 Jun 2005 17:49] MySQL Verification Team
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

Prepare is not more allowed in stored procedures:

c:\mysql\bin>mysql -uroot test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.9-beta-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> delimiter //
mysql> drop procedure if exists siscontrol.listado_clientes //
Query OK, 0 rows affected, 1 warning (0.09 sec)

mysql> create procedure listado_clientes
    -> (
    ->   out resultado tinyint
    -> )
    -> begin
    ->
    ->   set @qry = concat('select * from', ' clientes where dni=?');
    ->
    ->   prepare strQuery from @qry;
    ->   set @a = '123456789' ;
    ->   execute strQuery using @a;
    ->
    ->   deallocate prepare strQuery;
    ->
    -> --  select found_rows() into resultado;
    ->
    -> end //
ERROR 1314 (0A000): PREPARE is not allowed in stored procedures
mysql>
mysql> delimiter ;
mysql>
[28 Jun 2005 19:29] D SW
Thanks for your answer.

Now....  I will have to look for another way to execute a "dynamic" queries. He he he :-D

Bye's ;-)