From 5d510fdbf006afa82c8acc9ea2e0c6cbeaebe0fa Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 5 Apr 2019 12:54:09 +0200 Subject: MDEV-18507 can't update temporary table when joined with table with triggers on read-only 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. --- sql/sql_view.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'sql/sql_view.cc') diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 5bd82fdd842..8f37c14c2d3 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -1511,6 +1511,7 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table, tbl->lock_type= table->lock_type; tbl->mdl_request.set_type((tbl->lock_type >= TL_WRITE_ALLOW_WRITE) ? MDL_SHARED_WRITE : MDL_SHARED_READ); + tbl->updating= table->updating; } /* If the view is mergeable, we might want to -- cgit v1.2.1