List:Commits« Previous MessageNext Message »
From:Konstantin Osipov Date:June 4 2008 11:16am
Subject:bzr commit into mysql-6.0 branch (konstantin:2645) Bug#26141
View as plain text  
#At file:///opt/local/work/mysql-6.0-runtime/

 2645 Konstantin Osipov	2008-06-04
      Fix a code regression (not observable externally) that I introduced
      in the fix for Bug#26141
modified:
  sql/sp.cc

per-file comments:
  sql/sp.cc
    Do not process trigger keys in sp_cache_routines_and_add_tables_aux():
    all tables used by triggers are added in sp_cache_routines_and_add_tables_for_triggers().
    This avoids an extra disk seek for each trigger and makes
    the code follow the design.
=== modified file 'sql/sp.cc'
--- a/sql/sp.cc	2008-05-21 10:17:29 +0000
+++ b/sql/sp.cc	2008-06-04 11:16:37 +0000
@@ -1683,6 +1683,12 @@ sp_cache_routines_and_add_tables_aux(THD
     int type= rt->key.str[0];
     sp_head *sp;
 
+    /*
+      Triggers can't happen here: their bodies are always processed
+      in sp_cache_routines_and_add_tables_for_triggers().
+    */
+    DBUG_ASSERT(type == TYPE_ENUM_FUNCTION || type == TYPE_ENUM_PROCEDURE);
+
     if (!(sp= sp_cache_lookup((type == TYPE_ENUM_FUNCTION ?
                               &thd->sp_func_cache : &thd->sp_proc_cache),
                               &name)))
@@ -1826,11 +1832,6 @@ int
 sp_cache_routines_and_add_tables_for_triggers(THD *thd, LEX *lex,
                                               TABLE_LIST *table)
 {
-  int ret= 0;
-
-  Sroutine_hash_entry **last_cached_routine_ptr=
-    (Sroutine_hash_entry **)lex->sroutines_list.next;
-
   if (static_cast<int>(table->lock_type) >=
       static_cast<int>(TL_WRITE_ALLOW_WRITE))
   {
@@ -1847,21 +1848,28 @@ sp_cache_routines_and_add_tables_for_tri
               add_used_routine(lex, thd->stmt_arena, &trigger->m_sroutines_key,
                                table->belong_to_view))
           {
+            /* Sic: excludes the trigger key from processing */
+            Sroutine_hash_entry **last_cached_routine_ptr=
+              (Sroutine_hash_entry **)lex->sroutines_list.next;
+
             trigger->add_used_tables_to_table_list(thd, &lex->query_tables_last,
                                                    table->belong_to_view);
             trigger->propagate_attributes(lex);
             sp_update_stmt_used_routines(thd, lex,
                                          &trigger->m_sroutines,
                                          table->belong_to_view);
+
+            ret= sp_cache_routines_and_add_tables_aux(thd, lex,
+                                                      *last_cached_routine_ptr,
+                                                      FALSE);
+            if (ret)
+              return ret;
           }
         }
       }
     }
   }
-  ret= sp_cache_routines_and_add_tables_aux(thd, lex,
-                                            *last_cached_routine_ptr,
-                                            FALSE);
-  return ret;
+  return 0;
 }
 
 

Thread
bzr commit into mysql-6.0 branch (konstantin:2645) Bug#26141Konstantin Osipov4 Jun