diff options
author | unknown <davi@mysql.com/endora.local> | 2008-02-04 16:39:55 -0200 |
---|---|---|
committer | unknown <davi@mysql.com/endora.local> | 2008-02-04 16:39:55 -0200 |
commit | ff8651c4ecb33305c84bf545b000241d34a9ed2a (patch) | |
tree | e12e1f4a1826cc8e642dfb1cf60b9845cd118495 /sql/sp.cc | |
parent | 7d5a858d2c600d4b16d721b0159790ab6482afe3 (diff) | |
download | mariadb-git-ff8651c4ecb33305c84bf545b000241d34a9ed2a.tar.gz |
Bug#21801 SQL exception handlers and warnings
The problem is that deprecated syntax warnings were not being
suppressed when the stored routine is being parsed for the first
execution. It's doesn't make sense to print out deprecated
syntax warnings when the routine is being executed because this
kind of warning only matters when the routine is being created.
The solution is to suppress deprecated syntax warnings when
parsing the stored routine for loading into the cache (might
mean that the routine is being executed for the first time).
mysql-test/r/sp-error.result:
Add test case result for Bug#21801
mysql-test/t/sp-error.test:
Add test case for Bug#21801
sql/sp.cc:
Implement a internal error handler to catch deprecated
syntax warnings when loading a stored procedure into the
cache.
Diffstat (limited to 'sql/sp.cc')
-rw-r--r-- | sql/sp.cc | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/sql/sp.cc b/sql/sp.cc index 99ffc18deea..5514cf0ed5f 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -507,6 +507,31 @@ db_find_routine(THD *thd, int type, sp_name *name, sp_head **sphp) } +/** + Silence DEPRECATED SYNTAX warnings when loading a stored procedure + into the cache. +*/ +struct Silence_deprecated_warning : public Internal_error_handler +{ +public: + virtual bool handle_error(uint sql_errno, const char *message, + MYSQL_ERROR::enum_warning_level level, + THD *thd); +}; + +bool +Silence_deprecated_warning::handle_error(uint sql_errno, const char *message, + MYSQL_ERROR::enum_warning_level level, + THD *thd) +{ + if (sql_errno == ER_WARN_DEPRECATED_SYNTAX && + level == MYSQL_ERROR::WARN_LEVEL_WARN) + 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, @@ -523,7 +548,8 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, ulong old_sql_mode= thd->variables.sql_mode; ha_rows old_select_limit= thd->variables.select_limit; sp_rcontext *old_spcont= thd->spcont; - + Silence_deprecated_warning warning_handler; + char definer_user_name_holder[USERNAME_LENGTH + 1]; LEX_STRING definer_user_name= { definer_user_name_holder, USERNAME_LENGTH }; @@ -583,7 +609,9 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, lex_start(thd); + thd->push_internal_handler(&warning_handler); ret= parse_sql(thd, &lip, creation_ctx) || newlex.sphead == NULL; + thd->pop_internal_handler(); /* Force switching back to the saved current database (if changed), |