• Sergei Golubchik's avatar
    MDEV-18507 can't update temporary table when joined with table with triggers on read-only · 5d510fdb
    Sergei Golubchik authored
    triggers are opened and tables used in triggers are prelocked in
    open_tables(). But multi-update can detect what tables will actually
    be updated only later, after all main tables are opened.
    
    Meaning, if a table is used in multi-update, but is not actually updated,
    its on-update treggers will be opened and tables will be prelocked,
    even if it's unnecessary. This can cause more tables to be
    write-locked than needed, causing read_only errors, privilege errors
    and lock waits.
    
    Fix: don't open/prelock triggers unless table->updating is true.
    In multi-update after setting table->updating=true, do a second
    open_tables() for newly added tables, if any.
    5d510fdb
multi_update.test 39.2 KB