From 323bca33808c627a19bc5179d6617e9b475d39dc Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 3 Feb 2004 16:22:43 +0200 Subject: [PATCH] sp.test: test case for the fix for bug #2614 sp_head.cc: A fix for a crashing bug in stored procedures with INSERT ... SELECT ... (Bug #2514) sql/sp_head.cc: A fix for a crashing bug in stored procedures with INSERT ... SELECT ... (Bug #2514) mysql-test/t/sp.test: test case for the fix for bug #2614 --- mysql-test/t/sp.test | 15 ++++++++++++++- sql/sp_head.cc | 10 +++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index eefc6d71202..a852e8ae148 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -1299,7 +1299,20 @@ show create procedure bar| --replace_column 4 '0000-00-00 00:00:00' 5 '0000-00-00 00:00:00' show procedure status like 'bar'| drop procedure bar| - delimiter ;| drop table t1; drop table t2; +delimiter | +drop procedure if exists crash| +create procedure crash() + begin + drop table if exists t1; + create table t1 (id int default '0' not null); + insert into t1 select 12; + insert into t1 select * from t1; + end| +delimiter ; +call crash(); +call crash(); +drop table t1; +drop procedure if exists crash; diff --git a/sql/sp_head.cc b/sql/sp_head.cc index c40be15d21c..a68118cecd1 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -852,6 +852,11 @@ sp_instr_stmt::exec_stmt(THD *thd, LEX *lex) { TABLE_LIST *tabs; + if (lex->sql_command == SQLCOM_CREATE_TABLE || + lex->sql_command == SQLCOM_INSERT_SELECT) + { // Restore sl->table_list.first + sl->table_list.first= sl->table_list_first_copy; + } // We have closed all tables, get rid of pointers to them for (tabs=(TABLE_LIST *)sl->table_list.first ; tabs ; @@ -859,11 +864,6 @@ sp_instr_stmt::exec_stmt(THD *thd, LEX *lex) { tabs->table= NULL; } - if (lex->sql_command == SQLCOM_CREATE_TABLE || - lex->sql_command == SQLCOM_INSERT_SELECT) - { // Restore sl->table_list.first - sl->table_list.first= sl->table_list_first_copy; - } for (ORDER *order= (ORDER *)sl->order_list.first ; order ; order= order->next)