summaryrefslogtreecommitdiff
path: root/sql/table.h
diff options
context:
space:
mode:
authorkostja@bodhi.(none) <>2007-07-12 22:26:41 +0400
committerkostja@bodhi.(none) <>2007-07-12 22:26:41 +0400
commit5ab4b6f1ac489967ed1853e75ef86828bc2fbf9d (patch)
treed11bf2d3e42fc0c5131eb24ddd22755bafd5796f /sql/table.h
parent392b283f3d85a20ff4d3b91d40c83f0295eda25d (diff)
downloadmariadb-git-5ab4b6f1ac489967ed1853e75ef86828bc2fbf9d.tar.gz
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.
Diffstat (limited to 'sql/table.h')
-rw-r--r--sql/table.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/sql/table.h b/sql/table.h
index b29ef8c6566..f8f7d7f06b7 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -59,6 +59,17 @@ enum tmp_table_type {NO_TMP_TABLE=0,
NON_TRANSACTIONAL_TMP_TABLE=1, TRANSACTIONAL_TMP_TABLE=2,
SYSTEM_TMP_TABLE=3};
+
+/** Event on which trigger is invoked. */
+enum trg_event_type
+{
+ TRG_EVENT_INSERT= 0,
+ TRG_EVENT_UPDATE= 1,
+ TRG_EVENT_DELETE= 2,
+ TRG_EVENT_MAX
+};
+
+
enum frm_type_enum
{
FRMTYPE_ERROR= 0,
@@ -702,6 +713,13 @@ struct TABLE_LIST
*/
bool create;
+ /**
+ Indicates what triggers we need to pre-load for this TABLE_LIST
+ when opening an associated TABLE. This is filled after
+ the parsed tree is created.
+ */
+ uint8 trg_event_map;
+
enum enum_schema_table_state schema_table_state;
void calc_md5(char *buffer);
void set_underlying_merge();
@@ -752,6 +770,7 @@ struct TABLE_LIST
void reinit_before_use(THD *thd);
Item_subselect *containing_subselect();
+ void set_trg_event_type(const st_lex *lex);
private:
bool prep_check_option(THD *thd, uint8 check_opt_type);
bool prep_where(THD *thd, Item **conds, bool no_where_clause);