From 0b5a5258abbeaf8a0c3a18c7e753699787fdf46e Mon Sep 17 00:00:00 2001 From: sjaakola Date: Fri, 6 Oct 2017 09:49:42 +0300 Subject: MW-416 DDL replication moved after acl checking galera_events test shows a regression with the original fix for MW-416 Reason was that Events::drop_event() can be called also from inside event execution, and there we have a speacial treatment for event, which executes "DROP EVENT" statement, and runs TOI replication inside the event processing body. This resulted in executing WSREP_TO_ISOLATION two times for such DROP EVENT statement. Fix is to call WSREP_TO_ISOLATION_BEGIN only in Events::drop_event() --- sql/event_data_objects.cc | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'sql/event_data_objects.cc') diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc index e494b4a429b..90e839debb5 100644 --- a/sql/event_data_objects.cc +++ b/sql/event_data_objects.cc @@ -1472,19 +1472,33 @@ end: bool save_tx_read_only= thd->tx_read_only; thd->tx_read_only= false; - if (WSREP(thd)) - { + /* + This code is processing event execution and does not have client + connection. Here, event execution will now execute a prepared + DROP EVENT statement, but thd->lex->sql_command is set to + SQLCOM_CREATE_PROCEDURE + DROP EVENT will be logged in binlog, and we have to + replicate it to make all nodes have consistent event definitions + Wsrep DDL replication is triggered inside Events::drop_event(), + and here we need to prepare the THD so that DDL replication is + possible, essentially it requires setting sql_command to + SQLCOMM_DROP_EVENT, we will switch sql_command for the duration + of DDL replication only. + */ + const enum_sql_command sql_command_save= thd->lex->sql_command; + const bool sql_command_set= WSREP(thd); + + if (sql_command_set) thd->lex->sql_command = SQLCOM_DROP_EVENT; - WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL); - } ret= Events::drop_event(thd, dbname, name, FALSE); - WSREP_TO_ISOLATION_END; + if (sql_command_set) + { + WSREP_TO_ISOLATION_END; + thd->lex->sql_command = sql_command_save; + } -#ifdef WITH_WSREP - error: -#endif thd->tx_read_only= save_tx_read_only; thd->security_ctx->master_access= saved_master_access; } -- cgit v1.2.1 From 75aabd03d57f85d63d57b25a239b4f930a3ae3c0 Mon Sep 17 00:00:00 2001 From: halfspawn Date: Fri, 13 Oct 2017 15:55:42 +0200 Subject: MDEV-14013 : sql_mode=EMPTY_STRING_IS_NULL --- sql/event_data_objects.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sql/event_data_objects.cc') diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc index 4df981700ef..7b08d1754ad 100644 --- a/sql/event_data_objects.cc +++ b/sql/event_data_objects.cc @@ -431,7 +431,7 @@ Event_job_data::load_from_row(THD *thd, TABLE *table) definer_host.str= strmake_root(&mem_root, ptr + 1, len); definer_host.length= len; - sql_mode= (ulong) table->field[ET_FIELD_SQL_MODE]->val_int(); + sql_mode= (sql_mode_t) table->field[ET_FIELD_SQL_MODE]->val_int(); DBUG_RETURN(FALSE); } @@ -637,7 +637,7 @@ Event_timed::load_from_row(THD *thd, TABLE *table) else comment.length= 0; - sql_mode= (ulong) table->field[ET_FIELD_SQL_MODE]->val_int(); + sql_mode= (sql_mode_t) table->field[ET_FIELD_SQL_MODE]->val_int(); DBUG_RETURN(FALSE); } -- cgit v1.2.1