Crash Mysql 5.0 - Stored Procedure (2)

Crash Mysql 5.0 - Stored Procedure (2)

am 02.02.2004 22:05:44 von Szymon Okraska

For previous exaple patch works correctly but....

Another example of stored procedure:

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 5.0.0-alpha

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

mysql> DELIMITER |
mysql> DROP PROCEDURE IF EXISTS crash|
Query OK, 0 rows affected (0,00 sec)

mysql> CREATE PROCEDURE crash()
-> BEGIN
-> DROP TABLE IF EXISTS test.c1;
-> CREATE TABLE test.c1 (id INT DEFAULT '0' NOT NULL);
-> INSERT INTO test.c1 set id=13;
-> INSERT INTO test.c1 select id from test.c1 limit 1;
-> END|
Query OK, 0 rows affected (0,00 sec)

mysql> DELIMITER ;
mysql> call crash();
Query OK, 0 rows affected (0,00 sec)

mysql> call crash();
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql>


If I use subselect it cause server crash


When I declare cursor and never open in procedure that cause server crash


Your MySQL connection id is 1 to server version: 5.0.0-alpha

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

mysql> DELIMITER |
mysql> DROP PROCEDURE IF EXISTS crash|
Query OK, 0 rows affected (0,00 sec)

mysql> CREATE PROCEDURE crash()
-> BEGIN
-> DECLARE cursor_test CURSOR FOR SELECT id FROM test.c1;
->
-> DROP TABLE IF EXISTS test.c1;
-> CREATE TABLE test.c1 (id INT DEFAULT '0' NOT NULL);
-> END|
Query OK, 0 rows affected (0,00 sec)

mysql> DELIMITER ;
mysql> call crash();
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql>



When I have empy field - field whitch zero length and I select it

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

mysql> DELIMITER |
mysql> DROP PROCEDURE IF EXISTS crash|
Query OK, 0 rows affected (0,00 sec)

mysql> CREATE PROCEDURE crash()
-> BEGIN
-> DECLARE done INT DEFAULT 0;
-> DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
-> DECLARE my_id INT DEFAULT 0;
-> DECLARE my_data VARCHAR(255) DEFAULT '';
-> DECLARE cursor_test CURSOR FOR SELECT id, data FROM test.c1;
->
-> DROP TABLE IF EXISTS test.c1;
-> CREATE TABLE test.c1 (id INT DEFAULT '0' NOT NULL, data
VARCHAR(255) NOT NULL DEFAULT '');
-> INSERT INTO test.c1 SET id=1, data='';
-> INSERT INTO test.c1 SET id=2, data='not empty';
->
-> OPEN cursor_test;
-> REPEAT
-> FETCH cursor_test INTO my_id, my_data;
-> UNTIL done END REPEAT;
-> CLOSE cursor_test;
->
-> END|
Query OK, 0 rows affected (0,00 sec)

mysql> DELIMITER ;
mysql> call crash();
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql>

And another example :
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> DELIMITER |
mysql> DROP PROCEDURE IF EXISTS crash|
Query OK, 0 rows affected (0,00 sec)

mysql> CREATE PROCEDURE crash()
-> BEGIN
-> DECLARE done INT DEFAULT 0;
-> DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
-> DECLARE my_id INT DEFAULT 0;
-> DECLARE my_data VARCHAR(255) DEFAULT '';
-> DECLARE cursor_test CURSOR FOR SELECT id, data FROM test.c1;
->
-> DROP TABLE IF EXISTS test.c1;
-> CREATE TABLE test.c1 (id INT DEFAULT '0' NOT NULL, data
VARCHAR(255) NOT NULL DEFAULT '');
-> INSERT INTO test.c1 SET id=1, data='ugly data';
-> INSERT INTO test.c1 SET id=2, data='not empty';
->
-> OPEN cursor_test;
-> REPEAT
-> FETCH cursor_test INTO my_id, my_data;
-> UNTIL done END REPEAT;
-> CLOSE cursor_test;
->
-> END|
Query OK, 0 rows affected (0,00 sec)

mysql> DELIMITER ;
mysql> call crash();
Query OK, 0 rows affected (0,00 sec)

mysql> call crash();
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql>


Szymon Okraska


--
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe: http://lists.mysql.com/bugs?unsub=gcdmb-bugs@m.gmane.org