Bug #2614 Sotred procedure with INSERT .. SELECT crash 5t.0
Submitted: 2 Feb 2004 11:02 Modified: 6 Feb 2004 11:56
Reporter: Sinisa Milivojevic
Status: Closed
Category:Server Severity:S2 (Serious)
Version:5.0 OS:Any (any)
Assigned to: Sinisa Milivojevic Target Version:

[2 Feb 2004 11:02] Sinisa Milivojevic
Description:
Stored procedure with INSERT .. from SELECT, that does not contain any tables in 
it will crash MySQL 5.0.

I also discovered that INSERT .. from SELECT, both involving the same table, will 
also crash a server.

How to repeat:
DELIMITER |
DROP PROCEDURE IF EXISTS  crash|
CREATE PROCEDURE crash()
 BEGIN
    DROP TABLE IF EXISTS bug.c1;
    CREATE TABLE bug.c1 (id INT DEFAULT '0' NOT NULL);
    INSERT INTO bug.c1 select 12;
 END|
DELIMITER ;
call crash();
call crash();
DROP TABLE IF EXISTS bug.c1;
DROP PROCEDURE  IF EXISTS crash;

Suggested fix:
I have proposed a fix that first returns a pointer to TABLE_LIST and then
annulls a table pointer within it.

All tests pass.
[2 Feb 2004 11:12] Sinisa Milivojevic
A fix for the bug was proposed.

When approved, it will find it's way into 5.0.1 release.
[6 Feb 2004 11:56] Sinisa Milivojevic
A patch is pushed.