• unknown's avatar
    Fix for bug#21216 "Simultaneous DROP TABLE and SHOW OPEN TABLES causes · c9a9d014
    unknown authored
    server to crash".
    
    Crash caused by assertion failure happened when one ran SHOW OPEN TABLES
    while concurrently doing DROP TABLE (or RENAME TABLE, CREATE TABLE LIKE
    or any other command that takes name-lock) in other connection.
    For non-debug version of server problem exposed itself as wrong output
    of SHOW OPEN TABLES statement (it was missing name-locked tables).
    Finally in 5.1 both debug and non-debug versions simply crashed in
    this situation due to NULL-pointer dereference.
    
    This problem was caused by the fact that table placeholders which were
    added to table cache in order to obtain name-lock had TABLE_SHARE::table_name
    set to 0. Therefore they broke assumption that this member is non-0 for
    all tables in table cache which was checked by assert in list_open_tables()
    (in 5.1 this function simply relies on it).
    The fix simply sets this member for such placeholders to appropriate value
    making this assumption true again.
    
    This patch also includes test for similar bug 12212 "Crash that happens
    during removing of database name from cache" reappeared in 5.1 as bug 19403.
    
    
    mysql-test/r/drop.result:
      Added test for bug#21216 "Simultaneous DROP TABLE and SHOW OPEN TABLES
      causes server to crash" and bug#12212/19403 "Crash that happens during
      removing of database name from cache".
    mysql-test/t/drop.test:
      Added test for bug#21216 "Simultaneous DROP TABLE and SHOW OPEN TABLES
      causes server to crash" and bug#12212/19403 "Crash that happens during
      removing of database name from cache".
    sql/lock.cc:
      lock_table_name():
        Our code assumes that TABLE_SHARE::table_name for objects in table cache
        is non-NULL (for example look at assertion in list_open_tables()). This
        was not true for table placeholders that were added to table cache for
        name-locking. So let us set this member for such placeholders.
    c9a9d014
drop.result 2.36 KB