• Sergey Vojtovich's avatar
    MDEV-17595 - ALTER TABLE ADD FOREIGN KEY crash · 149b7547
    Sergey Vojtovich authored
    ALTER TABLE ... ADD FOREIGN KEY may trigger assertion failure when
    it has LOCK=EXCLUSIVE clause or concurrent FLUSH TABLES is being
    executed.
    
    In both cases being altered table is marked as flushed, which forces
    subsequent attempt to open parent table to re-open. Which in turn is
    not allowed while transaction is running.
    
    Rather than opening parent table, just take appropriate MDL lock.
    
    Also removed table_already_fk_prelocked() check: MDL itself has much
    better methods to handle duplicate locks. E.g. the former won't acquire
    MDL_SHARED_NO_WRITE if it already has MDL_SHARED_READ.
    149b7547
sql_table.cc 327 KB