diff options
author | unknown <pem@mysql.com> | 2005-12-13 13:12:42 +0100 |
---|---|---|
committer | unknown <pem@mysql.com> | 2005-12-13 13:12:42 +0100 |
commit | 5e84bbcb8f6b174906fca986c3404df4d2e9128c (patch) | |
tree | 0c4f24629e56f6ea1439956f9ebf628ed1883877 /sql/sp_rcontext.cc | |
parent | 95cabee1dc3a6d44a7e7a4c74c0bd49e00047f5b (diff) | |
download | mariadb-git-5e84bbcb8f6b174906fca986c3404df4d2e9128c.tar.gz |
Fixed BUG#15231: Stored procedure bug with not found condition handler
Make the distinction between "exception conditions" and "completion
conditions" (warning and "no data") as defined by the standard. The latter
should not terminate a routine if no handler is found in the lexical scope.
mysql-test/r/sp.result:
New test case for BUG#15231.
Moved part of the test for BUG#7049 to the new testcase (since it was actually
an example of 15231).
mysql-test/t/sp.test:
New test case for BUG#15231.
Moved part of the test for BUG#7049 to the new testcase (since it was actually
an example of 15231).
sql/sp_rcontext.cc:
Only search for matching condition handlers in caller's contexts if it's
an exception conditition.
Diffstat (limited to 'sql/sp_rcontext.cc')
-rw-r--r-- | sql/sp_rcontext.cc | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc index eca87e69f8e..c36c904f45d 100644 --- a/sql/sp_rcontext.cc +++ b/sql/sp_rcontext.cc @@ -160,6 +160,10 @@ sp_rcontext::set_return_value(THD *thd, Item *return_value_item) } +#define IS_WARNING_CONDITION(S) ((S)[0] == '0' && (S)[1] == '1') +#define IS_NOT_FOUND_CONDITION(S) ((S)[0] == '0' && (S)[1] == '2') +#define IS_EXCEPTION_CONDITION(S) ((S)[0] != '0' || (S)[1] > '2') + bool sp_rcontext::find_handler(uint sql_errno, MYSQL_ERROR::enum_warning_level level) @@ -193,18 +197,17 @@ sp_rcontext::find_handler(uint sql_errno, found= i; break; case sp_cond_type_t::warning: - if ((sqlstate[0] == '0' && sqlstate[1] == '1' || - level == MYSQL_ERROR::WARN_LEVEL_WARN) && - found < 0) + if ((IS_WARNING_CONDITION(sqlstate) || + level == MYSQL_ERROR::WARN_LEVEL_WARN) && + found < 0) found= i; break; case sp_cond_type_t::notfound: - if (sqlstate[0] == '0' && sqlstate[1] == '2' && - found < 0) + if (IS_NOT_FOUND_CONDITION(sqlstate) && found < 0) found= i; break; case sp_cond_type_t::exception: - if ((sqlstate[0] != '0' || sqlstate[1] > '2') && + if (IS_EXCEPTION_CONDITION(sqlstate) && level == MYSQL_ERROR::WARN_LEVEL_ERROR && found < 0) found= i; @@ -213,7 +216,13 @@ sp_rcontext::find_handler(uint sql_errno, } if (found < 0) { - if (m_prev_runtime_ctx) + /* + Only "exception conditions" are propagated to handlers in calling + contexts. If no handler is found locally for a "completion condition" + (warning or "not found") we will simply resume execution. + */ + if (m_prev_runtime_ctx && IS_EXCEPTION_CONDITION(sqlstate) && + level == MYSQL_ERROR::WARN_LEVEL_ERROR) return m_prev_runtime_ctx->find_handler(sql_errno, level); return FALSE; } |