Commit e99e6f29 authored by Sergei Golubchik's avatar Sergei Golubchik

cleanup: trg2bit() helper

parent 0e1f7f5c
...@@ -13445,9 +13445,8 @@ bool Write_rows_compressed_log_event::print(FILE *file, ...@@ -13445,9 +13445,8 @@ bool Write_rows_compressed_log_event::print(FILE *file,
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) #if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
uint8 Write_rows_log_event::get_trg_event_map() uint8 Write_rows_log_event::get_trg_event_map()
{ {
return (static_cast<uint8> (1 << static_cast<int>(TRG_EVENT_INSERT)) | return trg2bit(TRG_EVENT_INSERT) | trg2bit(TRG_EVENT_UPDATE) |
static_cast<uint8> (1 << static_cast<int>(TRG_EVENT_UPDATE)) | trg2bit(TRG_EVENT_DELETE);
static_cast<uint8> (1 << static_cast<int>(TRG_EVENT_DELETE)));
} }
#endif #endif
...@@ -14154,7 +14153,7 @@ bool Delete_rows_compressed_log_event::print(FILE *file, ...@@ -14154,7 +14153,7 @@ bool Delete_rows_compressed_log_event::print(FILE *file,
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) #if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
uint8 Delete_rows_log_event::get_trg_event_map() uint8 Delete_rows_log_event::get_trg_event_map()
{ {
return static_cast<uint8> (1 << static_cast<int>(TRG_EVENT_DELETE)); return trg2bit(TRG_EVENT_DELETE);
} }
#endif #endif
...@@ -14429,7 +14428,7 @@ Update_rows_compressed_log_event::print(FILE *file, ...@@ -14429,7 +14428,7 @@ Update_rows_compressed_log_event::print(FILE *file,
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) #if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
uint8 Update_rows_log_event::get_trg_event_map() uint8 Update_rows_log_event::get_trg_event_map()
{ {
return static_cast<uint8> (1 << static_cast<int>(TRG_EVENT_UPDATE)); return trg2bit(TRG_EVENT_UPDATE);
} }
#endif #endif
......
...@@ -3473,12 +3473,8 @@ void LEX::set_trg_event_type_for_tables() ...@@ -3473,12 +3473,8 @@ void LEX::set_trg_event_type_for_tables()
On a LOCK TABLE, all triggers must be pre-loaded for this TABLE_LIST On a LOCK TABLE, all triggers must be pre-loaded for this TABLE_LIST
when opening an associated TABLE. when opening an associated TABLE.
*/ */
new_trg_event_map= static_cast<uint8> new_trg_event_map= trg2bit(TRG_EVENT_INSERT) | trg2bit(TRG_EVENT_UPDATE) |
(1 << static_cast<int>(TRG_EVENT_INSERT)) | trg2bit(TRG_EVENT_DELETE);
static_cast<uint8>
(1 << static_cast<int>(TRG_EVENT_UPDATE)) |
static_cast<uint8>
(1 << static_cast<int>(TRG_EVENT_DELETE));
break; break;
/* /*
Basic INSERT. If there is an additional ON DUPLIATE KEY UPDATE Basic INSERT. If there is an additional ON DUPLIATE KEY UPDATE
...@@ -3509,20 +3505,17 @@ void LEX::set_trg_event_type_for_tables() ...@@ -3509,20 +3505,17 @@ void LEX::set_trg_event_type_for_tables()
*/ */
case SQLCOM_CREATE_TABLE: case SQLCOM_CREATE_TABLE:
case SQLCOM_CREATE_SEQUENCE: case SQLCOM_CREATE_SEQUENCE:
new_trg_event_map|= static_cast<uint8> new_trg_event_map|= trg2bit(TRG_EVENT_INSERT);
(1 << static_cast<int>(TRG_EVENT_INSERT));
break; break;
/* Basic update and multi-update */ /* Basic update and multi-update */
case SQLCOM_UPDATE: /* fall through */ case SQLCOM_UPDATE: /* fall through */
case SQLCOM_UPDATE_MULTI: case SQLCOM_UPDATE_MULTI:
new_trg_event_map|= static_cast<uint8> new_trg_event_map|= trg2bit(TRG_EVENT_UPDATE);
(1 << static_cast<int>(TRG_EVENT_UPDATE));
break; break;
/* Basic delete and multi-delete */ /* Basic delete and multi-delete */
case SQLCOM_DELETE: /* fall through */ case SQLCOM_DELETE: /* fall through */
case SQLCOM_DELETE_MULTI: case SQLCOM_DELETE_MULTI:
new_trg_event_map|= static_cast<uint8> new_trg_event_map|= trg2bit(TRG_EVENT_DELETE);
(1 << static_cast<int>(TRG_EVENT_DELETE));
break; break;
default: default:
break; break;
...@@ -3530,12 +3523,10 @@ void LEX::set_trg_event_type_for_tables() ...@@ -3530,12 +3523,10 @@ void LEX::set_trg_event_type_for_tables()
switch (duplicates) { switch (duplicates) {
case DUP_UPDATE: case DUP_UPDATE:
new_trg_event_map|= static_cast<uint8> new_trg_event_map|= trg2bit(TRG_EVENT_UPDATE);
(1 << static_cast<int>(TRG_EVENT_UPDATE));
break; break;
case DUP_REPLACE: case DUP_REPLACE:
new_trg_event_map|= static_cast<uint8> new_trg_event_map|= trg2bit(TRG_EVENT_DELETE);
(1 << static_cast<int>(TRG_EVENT_DELETE));
break; break;
case DUP_ERROR: case DUP_ERROR:
default: default:
......
...@@ -2192,8 +2192,7 @@ bool Table_triggers_list::process_triggers(THD *thd, ...@@ -2192,8 +2192,7 @@ bool Table_triggers_list::process_triggers(THD *thd,
This trigger must have been processed by the pre-locking This trigger must have been processed by the pre-locking
algorithm. algorithm.
*/ */
DBUG_ASSERT(trigger_table->pos_in_table_list->trg_event_map & DBUG_ASSERT(trigger_table->pos_in_table_list->trg_event_map & trg2bit(event));
static_cast<uint>(1 << static_cast<int>(event)));
thd->reset_sub_statement_state(&statement_state, SUB_STMT_TRIGGER); thd->reset_sub_statement_state(&statement_state, SUB_STMT_TRIGGER);
...@@ -2245,8 +2244,7 @@ add_tables_and_routines_for_triggers(THD *thd, ...@@ -2245,8 +2244,7 @@ add_tables_and_routines_for_triggers(THD *thd,
for (int i= 0; i < (int)TRG_EVENT_MAX; i++) for (int i= 0; i < (int)TRG_EVENT_MAX; i++)
{ {
if (table_list->trg_event_map & if (table_list->trg_event_map & trg2bit(static_cast<trg_event_type>(i)))
static_cast<uint8>(1 << static_cast<int>(i)))
{ {
for (int j= 0; j < (int)TRG_ACTION_MAX; j++) for (int j= 0; j < (int)TRG_ACTION_MAX; j++)
{ {
......
...@@ -38,6 +38,9 @@ enum trg_event_type ...@@ -38,6 +38,9 @@ enum trg_event_type
TRG_EVENT_MAX TRG_EVENT_MAX
}; };
static inline uint8 trg2bit(enum trg_event_type trg)
{ return static_cast<uint8>(1 << static_cast<int>(trg)); }
#include "table.h" /* GRANT_INFO */ #include "table.h" /* GRANT_INFO */
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment