diff options
author | Kent Boortz <kent.boortz@oracle.com> | 2011-07-04 01:25:49 +0200 |
---|---|---|
committer | Kent Boortz <kent.boortz@oracle.com> | 2011-07-04 01:25:49 +0200 |
commit | 0f03af653cd9891dc6b8d855d7ebffc27b1db288 (patch) | |
tree | aae7686092aab07db57ff0fe0150741ffbc9689d /sql/sp.cc | |
parent | 9da00ebec99cd8963b63d011d6dd8111cbf9217e (diff) | |
parent | bc9f870fb12d4aedc6239ec485dee6ebc23d9b94 (diff) | |
download | mariadb-git-0f03af653cd9891dc6b8d855d7ebffc27b1db288.tar.gz |
Updated/added copyright headers
Diffstat (limited to 'sql/sp.cc')
-rw-r--r-- | sql/sp.cc | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/sql/sp.cc b/sql/sp.cc index 1eaeb777d5a..b257e23c8c7 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -756,6 +757,43 @@ static sp_head *sp_compile(THD *thd, String *defstr, ulong sql_mode, } +class Bad_db_error_handler : public Internal_error_handler +{ +public: + Bad_db_error_handler() + :m_error_caught(false) + {} + + virtual bool handle_condition(THD *thd, + uint sql_errno, + const char* sqlstate, + MYSQL_ERROR::enum_warning_level level, + const char* message, + MYSQL_ERROR ** cond_hdl); + + bool error_caught() const { return m_error_caught; } + +private: + bool m_error_caught; +}; + +bool +Bad_db_error_handler::handle_condition(THD *thd, + uint sql_errno, + const char* sqlstate, + MYSQL_ERROR::enum_warning_level level, + const char* message, + MYSQL_ERROR ** cond_hdl) +{ + if (sql_errno == ER_BAD_DB_ERROR) + { + m_error_caught= true; + return true; + } + return false; +} + + static int db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, ulong sql_mode, const char *params, const char *returns, @@ -769,7 +807,7 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, LEX_STRING saved_cur_db_name= { saved_cur_db_name_buf, sizeof(saved_cur_db_name_buf) }; bool cur_db_changed; - + Bad_db_error_handler db_not_exists_handler; char definer_user_name_holder[USERNAME_LENGTH + 1]; LEX_STRING definer_user_name= { definer_user_name_holder, USERNAME_LENGTH }; @@ -808,6 +846,7 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, goto end; } + thd->push_internal_handler(&db_not_exists_handler); /* Change the current database (if needed). @@ -818,6 +857,15 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, &cur_db_changed)) { ret= SP_INTERNAL_ERROR; + thd->pop_internal_handler(); + goto end; + } + thd->pop_internal_handler(); + if (db_not_exists_handler.error_caught()) + { + ret= SP_INTERNAL_ERROR; + my_error(ER_BAD_DB_ERROR, MYF(0), name->m_db.str); + goto end; } |