• Konstantin Osipov's avatar
    ------------------------------------------------------------ · 38798f9b
    Konstantin Osipov authored
    revno: 2617.68.23
    committer: Dmitry Lenev <dlenev@mysql.com>
    branch nick: mysql-next-bg-pre1
    timestamp: Wed 2009-09-16 09:34:42 +0400
    message:
      Pre-requisite patch for fixing bug #30977 "Concurrent statement
      using stored function and DROP FUNCTION breaks SBR".
    
      CREATE TABLE SELECT statements take exclusive metadata lock on table
      being created. Invariant of metadata locking subsystem states that
      such lock should be taken before taking any kind of shared locks.
      Once metadata locks on stored routines are introduced statements like
      "CREATE TABLE ... SELECT f1()" will break this invariant by taking
      shared locks on routines before exclusive lock on target table.
      To avoid this, open_tables() is reworked to process tables which are
      directly used by the statement before stored routines are processed.
    
    sql/sql_base.cc:
      Refactored open_tables() implementation to process stored routines 
      only after tables which are directly used by statement were processed.
                
      To achieve this moved handling of routines in open_tables() out of 
      loop which iterates over tables to a new separate loop. And in its 
      turn this allowed to split handling of particular table or view to 
      an auxiliary function, which made code in open_tables() simpler and 
      more easy to understand.
    38798f9b
sql_base.cc 275 KB