• Jon Olav Hauglid's avatar
    Bug#16385711: HANDLER, CREATE TABLE IF NOT EXISTS, · a4a50271
    Jon Olav Hauglid authored
                  PROBLEM AFTER MYSQL_HA_FIND
    
    This problem occured if a prepared statement tried to create a table
    for which there already existed a view with the same name while a
    SQL handler was opened.
    
    Before DDL statements are executed, mysql_ha_rm_tables() is called
    to remove any matching tables from the internal list of opened SQL
    handler tables. This match was done on TABLE_LIST::db and 
    TABLE_LIST::table_name. This is problematic for views (which use
    TABLE_LIST::view_db and TABLE_LIST::view_name) and anonymous
    derived tables.
    
    This patch fixes the problem by skipping TABLE_LISTs representing
    anonymous derived tables and using get_db_name()/get_table_name()
    which handles views when looking for SQL handler tables to remove.
    a4a50271
sql_handler.cc 28.8 KB