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,
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
uint8 Write_rows_log_event::get_trg_event_map()
{
return (static_cast<uint8> (1 << static_cast<int>(TRG_EVENT_INSERT)) |
static_cast<uint8> (1 << static_cast<int>(TRG_EVENT_UPDATE)) |
static_cast<uint8> (1 << static_cast<int>(TRG_EVENT_DELETE)));
return trg2bit(TRG_EVENT_INSERT) | trg2bit(TRG_EVENT_UPDATE) |
trg2bit(TRG_EVENT_DELETE);
}
#endif
......@@ -14154,7 +14153,7 @@ bool Delete_rows_compressed_log_event::print(FILE *file,
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
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
......@@ -14429,7 +14428,7 @@ Update_rows_compressed_log_event::print(FILE *file,
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
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
......
......@@ -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
when opening an associated TABLE.
*/
new_trg_event_map= static_cast<uint8>
(1 << static_cast<int>(TRG_EVENT_INSERT)) |
static_cast<uint8>
(1 << static_cast<int>(TRG_EVENT_UPDATE)) |
static_cast<uint8>
(1 << static_cast<int>(TRG_EVENT_DELETE));
new_trg_event_map= trg2bit(TRG_EVENT_INSERT) | trg2bit(TRG_EVENT_UPDATE) |
trg2bit(TRG_EVENT_DELETE);
break;
/*
Basic INSERT. If there is an additional ON DUPLIATE KEY UPDATE
......@@ -3509,20 +3505,17 @@ void LEX::set_trg_event_type_for_tables()
*/
case SQLCOM_CREATE_TABLE:
case SQLCOM_CREATE_SEQUENCE:
new_trg_event_map|= static_cast<uint8>
(1 << static_cast<int>(TRG_EVENT_INSERT));
new_trg_event_map|= trg2bit(TRG_EVENT_INSERT);
break;
/* Basic update and multi-update */
case SQLCOM_UPDATE: /* fall through */
case SQLCOM_UPDATE_MULTI:
new_trg_event_map|= static_cast<uint8>
(1 << static_cast<int>(TRG_EVENT_UPDATE));
new_trg_event_map|= trg2bit(TRG_EVENT_UPDATE);
break;
/* Basic delete and multi-delete */
case SQLCOM_DELETE: /* fall through */
case SQLCOM_DELETE_MULTI:
new_trg_event_map|= static_cast<uint8>
(1 << static_cast<int>(TRG_EVENT_DELETE));
new_trg_event_map|= trg2bit(TRG_EVENT_DELETE);
break;
default:
break;
......@@ -3530,12 +3523,10 @@ void LEX::set_trg_event_type_for_tables()
switch (duplicates) {
case DUP_UPDATE:
new_trg_event_map|= static_cast<uint8>
(1 << static_cast<int>(TRG_EVENT_UPDATE));
new_trg_event_map|= trg2bit(TRG_EVENT_UPDATE);
break;
case DUP_REPLACE:
new_trg_event_map|= static_cast<uint8>
(1 << static_cast<int>(TRG_EVENT_DELETE));
new_trg_event_map|= trg2bit(TRG_EVENT_DELETE);
break;
case DUP_ERROR:
default:
......
......@@ -2192,8 +2192,7 @@ bool Table_triggers_list::process_triggers(THD *thd,
This trigger must have been processed by the pre-locking
algorithm.
*/
DBUG_ASSERT(trigger_table->pos_in_table_list->trg_event_map &
static_cast<uint>(1 << static_cast<int>(event)));
DBUG_ASSERT(trigger_table->pos_in_table_list->trg_event_map & trg2bit(event));
thd->reset_sub_statement_state(&statement_state, SUB_STMT_TRIGGER);
......@@ -2245,8 +2244,7 @@ add_tables_and_routines_for_triggers(THD *thd,
for (int i= 0; i < (int)TRG_EVENT_MAX; i++)
{
if (table_list->trg_event_map &
static_cast<uint8>(1 << static_cast<int>(i)))
if (table_list->trg_event_map & trg2bit(static_cast<trg_event_type>(i)))
{
for (int j= 0; j < (int)TRG_ACTION_MAX; j++)
{
......
......@@ -38,6 +38,9 @@ enum trg_event_type
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 */
/*
......
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