From ba7c7439831a56580ea7d21197c176ea2bf59d52 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 6 Aug 2004 15:21:28 +0200 Subject: [PATCH] Fixed BUG#4904: Stored procedure crash if continue handler for HY000 errors. The description is not entirerly correct. The issue was follow-up errors where the first error is not caught - in which case it's often a system error with errcode < 1000 (which are mapped by default to 'HY000'). In this case the error state is different from what was assumed in the execution loop. mysql-test/r/sp.result: New test case for BUG#4902. mysql-test/t/sp.test: New test case for BUG#4902. sql/sp_head.cc: Don't test the net.report_error flag in the execution loop. (Don't know why this was done in the first place, as it seems to serve no purpose.) --- mysql-test/r/sp.result | 8 ++++++++ mysql-test/t/sp.test | 18 ++++++++++++++++++ sql/sp_head.cc | 5 ++--- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 91617d5681d..5bacffcb778 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -2237,6 +2237,14 @@ Tables_in_test (foo) table_type Variable_name Value Level Code Message drop procedure bug4902| +drop table if exists t3| +create procedure bug4904() +begin +declare continue handler for sqlstate 'HY000' begin end; +create table t2 as select * from t; +end| +call bug4904()| +drop procedure bug4904| drop table if exists fac| create table fac (n int unsigned not null primary key, f bigint unsigned)| create procedure ifac(n int unsigned) diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 6e562fa79ce..ef2371f45cd 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -1717,6 +1717,24 @@ call bug4902()| drop procedure bug4902| +# +# BUG#4904 +# +--disable_warnings +drop table if exists t3| +--enable_warnings + +create procedure bug4904() +begin + declare continue handler for sqlstate 'HY000' begin end; + + create table t2 as select * from t; +end| + +call bug4904()| + +drop procedure bug4904| + # # Some "real" examples diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 987f20c23f6..6ba72215e39 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -486,8 +486,7 @@ sp_head::execute(THD *thd) continue; } } - } while (ret == 0 && !thd->killed && !thd->query_error && - !thd->net.report_error); + } while (ret == 0 && !thd->killed && !thd->query_error); if (thd->current_arena) cleanup_items(thd->current_arena->free_list); @@ -497,7 +496,7 @@ sp_head::execute(THD *thd) DBUG_PRINT("info", ("ret=%d killed=%d query_error=%d", ret, thd->killed, thd->query_error)); - if (thd->killed || thd->query_error || thd->net.report_error) + if (thd->killed || thd->query_error) ret= -1; /* If the DB has changed, the pointer has changed too, but the original thd->db will then have been freed */