mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
A fix and a test case for Bug#26141 mixing table types in trigger
causes full table lock on innodb table. Also fixes Bug#28502 Triggers that update another innodb table will block on X lock unnecessarily (duplciate). Code review fixes. Both bugs' synopses are misleading: InnoDB table is not X locked. The statements, however, cannot proceed concurrently, but this happens due to lock conflicts for tables used in triggers, not for the InnoDB table. If a user had an InnoDB table, and two triggers, AFTER UPDATE and AFTER INSERT, competing for different resources (e.g. two distinct MyISAM tables), then these two triggers would not be able to execute concurrently. Moreover, INSERTS/UPDATES of the InnoDB table would not be able to run concurrently. The problem had other side-effects (see respective bug reports). This behavior was a consequence of a shortcoming of the pre-locking algorithm, which would not distinguish between different DML operations (e.g. INSERT and DELETE) and pre-lock all the tables that are used by any trigger defined on the subject table. The idea of the fix is to extend the pre-locking algorithm to keep track, for each table, what DML operation it is used for and not load triggers that are known to never be fired.
This commit is contained in:
@ -1153,7 +1153,20 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
|
||||
*/
|
||||
for (tbl= view_main_select_tables; tbl; tbl= tbl->next_local)
|
||||
tbl->lock_type= table->lock_type;
|
||||
/*
|
||||
If the view is mergeable, we might want to
|
||||
INSERT/UPDATE/DELETE into tables of this view. Preserve the
|
||||
original sql command and 'duplicates' of the outer lex.
|
||||
This is used later in set_trg_event_type_for_command.
|
||||
*/
|
||||
lex->sql_command= old_lex->sql_command;
|
||||
lex->duplicates= old_lex->duplicates;
|
||||
}
|
||||
/*
|
||||
This method has a dependency on the proper lock type being set,
|
||||
so in case of views should be called here.
|
||||
*/
|
||||
lex->set_trg_event_type_for_tables();
|
||||
|
||||
/*
|
||||
If we are opening this view as part of implicit LOCK TABLES, then
|
||||
|
Reference in New Issue
Block a user