List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:February 4 2008 6:40pm
Subject:bk commit into 5.1 tree (davi:1.2516) BUG#21801
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of davi.  When davi does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2008-02-04 16:39:55-02:00, davi@stripped +3 -0
  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@stripped, 2008-02-04 16:39:50-02:00, davi@stripped +11 -0
    Add test case result for Bug#21801

  mysql-test/t/sp-error.test@stripped, 2008-02-04 16:39:50-02:00, davi@stripped +18 -0
    Add test case for Bug#21801

  sql/sp.cc@stripped, 2008-02-04 16:39:51-02:00, davi@stripped +29 -1
    Implement a internal error handler to catch deprecated
    syntax warnings when loading a stored procedure into the
    cache.

diff -Nrup a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result
--- a/mysql-test/r/sp-error.result	2008-01-23 21:21:04 -02:00
+++ b/mysql-test/r/sp-error.result	2008-02-04 16:39:50 -02:00
@@ -1627,3 +1627,14 @@ end loop label1;
 end loop;
 end|
 ERROR 42000: End-label label1 without match
+drop procedure if exists p1;
+create procedure p1()
+begin
+create table t1 (a int) type=MyISAM;
+drop table t1;
+end|
+Warnings:
+Warning	1287	The syntax 'TYPE=storage_engine' is deprecated and will be removed in MySQL 5.2. Please use 'ENGINE=storage_engine' instead
+call p1();
+call p1();
+drop procedure p1;
diff -Nrup a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test
--- a/mysql-test/t/sp-error.test	2008-01-23 21:21:04 -02:00
+++ b/mysql-test/t/sp-error.test	2008-02-04 16:39:50 -02:00
@@ -2369,6 +2369,24 @@ end|
 delimiter ;|
 
 #
+# Bug#21801: SQL exception handlers and warnings
+#
+
+--disable_warnings
+drop procedure if exists p1;
+--enable_warnings
+delimiter |;
+create procedure p1()
+begin
+  create table t1 (a int) type=MyISAM;
+  drop table t1;
+end|
+delimiter ;|
+call p1();
+call p1();
+drop procedure p1;
+
+#
 # BUG#NNNN: New bug synopsis
 #
 #--disable_warnings
diff -Nrup a/sql/sp.cc b/sql/sp.cc
--- a/sql/sp.cc	2008-01-22 20:45:42 -02:00
+++ b/sql/sp.cc	2008-02-04 16:39:51 -02:00
@@ -507,6 +507,31 @@ db_find_routine(THD *thd, int type, sp_n
 }
 
 
+/**
+  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_n
   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_n
 
     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),
Thread
bk commit into 5.1 tree (davi:1.2516) BUG#21801Davi Arnaut4 Feb
  • Re: bk commit into 5.1 tree (davi:1.2516) BUG#21801Konstantin Osipov6 Feb