Skip to content

Commit 8596b70

Browse files
committed
cleanup: simplify the usage of WSREP_FORMAT macro
1 parent d103e35 commit 8596b70

File tree

7 files changed

+27
-31
lines changed

7 files changed

+27
-31
lines changed

include/wsrep.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@
2222
#define IF_WSREP(A,B) A
2323
#define DBUG_ASSERT_IF_WSREP(A) DBUG_ASSERT(A)
2424

25-
#if !defined(EMBEDDED_LIBRARY)
26-
#define WSREP_FORMAT(my_format) \
27-
((wsrep_forced_binlog_format != BINLOG_FORMAT_UNSPEC) ? \
28-
((enum enum_binlog_format)wsrep_forced_binlog_format) : my_format)
29-
#else
30-
#define WSREP_FORMAT(my_format) my_format
31-
#endif /* && !EMBEDDED_LIBRARY */
32-
3325
#define WSREP_MYSQL_DB (char *)"mysql"
3426
#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) \
3527
if (WSREP_ON && WSREP(thd) && wsrep_to_isolation_begin(thd, db_, table_, table_list_)) \
@@ -52,7 +44,6 @@
5244
#define WSREP_INFO(...)
5345
#define WSREP_WARN(...)
5446
#define WSREP_ERROR(...)
55-
#define WSREP_FORMAT(my_format) my_format
5647
#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_)
5748
#define WSREP_TO_ISOLATION_END
5849
#endif

sql/log.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,12 +1910,12 @@ static bool trans_cannot_safely_rollback(THD *thd, bool all)
19101910

19111911
return ((thd->variables.option_bits & OPTION_KEEP_LOG) ||
19121912
(trans_has_updated_non_trans_table(thd) &&
1913-
WSREP_FORMAT((enum enum_binlog_format) thd->variables.binlog_format) == BINLOG_FORMAT_STMT) ||
1913+
thd->wsrep_binlog_format() == BINLOG_FORMAT_STMT) ||
19141914
(cache_mngr->trx_cache.changes_to_non_trans_temp_table() &&
1915-
WSREP_FORMAT((enum enum_binlog_format) thd->variables.binlog_format) == BINLOG_FORMAT_MIXED) ||
1915+
thd->wsrep_binlog_format() == BINLOG_FORMAT_MIXED) ||
19161916
(trans_has_updated_non_trans_table(thd) &&
19171917
ending_single_stmt_trans(thd,all) &&
1918-
WSREP_FORMAT((enum enum_binlog_format) thd->variables.binlog_format) == BINLOG_FORMAT_MIXED));
1918+
thd->wsrep_binlog_format() == BINLOG_FORMAT_MIXED));
19191919
}
19201920

19211921

@@ -2064,9 +2064,9 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all)
20642064
else if (ending_trans(thd, all) ||
20652065
(!(thd->variables.option_bits & OPTION_KEEP_LOG) &&
20662066
(!stmt_has_updated_non_trans_table(thd) ||
2067-
WSREP_FORMAT((enum enum_binlog_format) thd->variables.binlog_format) != BINLOG_FORMAT_STMT) &&
2067+
thd->wsrep_binlog_format() != BINLOG_FORMAT_STMT) &&
20682068
(!cache_mngr->trx_cache.changes_to_non_trans_temp_table() ||
2069-
WSREP_FORMAT((enum enum_binlog_format) thd->variables.binlog_format) != BINLOG_FORMAT_MIXED)))
2069+
thd->wsrep_binlog_format() != BINLOG_FORMAT_MIXED)))
20702070
error= binlog_truncate_trx_cache(thd, cache_mngr, all);
20712071
}
20722072

sql/sql_base.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3557,8 +3557,7 @@ thr_lock_type read_lock_type_for_table(THD *thd,
35573557
at THD::variables::sql_log_bin member.
35583558
*/
35593559
bool log_on= mysql_bin_log.is_open() && thd->variables.sql_log_bin;
3560-
ulong binlog_format= thd->variables.binlog_format;
3561-
if ((log_on == FALSE) || (WSREP_FORMAT((enum enum_binlog_format) binlog_format) == BINLOG_FORMAT_ROW) ||
3560+
if ((log_on == FALSE) || (thd->wsrep_binlog_format() == BINLOG_FORMAT_ROW) ||
35623561
(table_list->table->s->table_category == TABLE_CATEGORY_LOG) ||
35633562
(table_list->table->s->table_category == TABLE_CATEGORY_PERFORMANCE) ||
35643563
!(is_update_query(prelocking_ctx->sql_command) ||
@@ -5327,7 +5326,7 @@ bool lock_tables(THD *thd, TABLE_LIST *tables, uint count,
53275326
We can solve these problems in mixed mode by switching to binlogging
53285327
if at least one updated table is used by sub-statement
53295328
*/
5330-
if (WSREP_FORMAT((enum enum_binlog_format) thd->variables.binlog_format) != BINLOG_FORMAT_ROW && tables &&
5329+
if (thd->wsrep_binlog_format() != BINLOG_FORMAT_ROW && tables &&
53315330
has_write_table_with_auto_increment(thd->lex->first_not_own_table()))
53325331
thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_AUTOINC_COLUMNS);
53335332
}

sql/sql_class.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4350,7 +4350,7 @@ extern "C" int thd_binlog_format(const MYSQL_THD thd)
43504350
{
43514351
if (((WSREP(thd) && wsrep_emulate_bin_log) || mysql_bin_log.is_open()) &&
43524352
thd->variables.option_bits & OPTION_BIN_LOG)
4353-
return (int) WSREP_FORMAT((enum enum_binlog_format) thd->variables.binlog_format);
4353+
return (int) thd->wsrep_binlog_format();
43544354
else
43554355
return BINLOG_FORMAT_UNSPEC;
43564356
}
@@ -5080,7 +5080,7 @@ int THD::decide_logging_format(TABLE_LIST *tables)
50805080
binlog by filtering rules.
50815081
*/
50825082
if (mysql_bin_log.is_open() && (variables.option_bits & OPTION_BIN_LOG) &&
5083-
!(WSREP_FORMAT((enum enum_binlog_format) variables.binlog_format) == BINLOG_FORMAT_STMT &&
5083+
!(wsrep_binlog_format() == BINLOG_FORMAT_STMT &&
50845084
!binlog_filter->db_ok(db)))
50855085
{
50865086
/*
@@ -5290,7 +5290,7 @@ int THD::decide_logging_format(TABLE_LIST *tables)
52905290
*/
52915291
my_error((error= ER_BINLOG_ROW_INJECTION_AND_STMT_ENGINE), MYF(0));
52925292
}
5293-
else if (WSREP_FORMAT((enum enum_binlog_format) variables.binlog_format) == BINLOG_FORMAT_ROW &&
5293+
else if (wsrep_binlog_format() == BINLOG_FORMAT_ROW &&
52945294
sqlcom_can_generate_row_events(this))
52955295
{
52965296
/*
@@ -5319,7 +5319,7 @@ int THD::decide_logging_format(TABLE_LIST *tables)
53195319
else
53205320
{
53215321
/* binlog_format = STATEMENT */
5322-
if (WSREP_FORMAT((enum enum_binlog_format) variables.binlog_format) == BINLOG_FORMAT_STMT)
5322+
if (wsrep_binlog_format() == BINLOG_FORMAT_STMT)
53235323
{
53245324
if (lex->is_stmt_row_injection())
53255325
{
@@ -5451,7 +5451,7 @@ int THD::decide_logging_format(TABLE_LIST *tables)
54515451
"and binlog_filter->db_ok(db) = %d",
54525452
mysql_bin_log.is_open(),
54535453
(variables.option_bits & OPTION_BIN_LOG),
5454-
(uint) WSREP_FORMAT((enum enum_binlog_format) variables.binlog_format),
5454+
(uint) wsrep_binlog_format(),
54555455
binlog_filter->db_ok(db)));
54565456
#endif
54575457

sql/sql_class.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3286,8 +3286,7 @@ class THD :public Statement,
32863286
tests fail and so force them to propagate the
32873287
lex->binlog_row_based_if_mixed upwards to the caller.
32883288
*/
3289-
if ((WSREP_FORMAT((enum enum_binlog_format) variables.binlog_format) ==
3290-
BINLOG_FORMAT_MIXED) && (in_sub_stmt == 0))
3289+
if ((wsrep_binlog_format() == BINLOG_FORMAT_MIXED) && (in_sub_stmt == 0))
32913290
set_current_stmt_binlog_format_row();
32923291

32933292
DBUG_VOID_RETURN;
@@ -3338,8 +3337,7 @@ class THD :public Statement,
33383337
show_system_thread(system_thread)));
33393338
if (in_sub_stmt == 0)
33403339
{
3341-
if (WSREP_FORMAT((enum enum_binlog_format) variables.binlog_format) ==
3342-
BINLOG_FORMAT_ROW)
3340+
if (wsrep_binlog_format() == BINLOG_FORMAT_ROW)
33433341
set_current_stmt_binlog_format_row();
33443342
else if (temporary_tables == NULL)
33453343
set_current_stmt_binlog_format_stmt();
@@ -3748,6 +3746,11 @@ class THD :public Statement,
37483746
(rgi_slave && rgi_have_temporary_tables()));
37493747
}
37503748

3749+
inline ulong wsrep_binlog_format() const
3750+
{
3751+
return WSREP_FORMAT(variables.binlog_format);
3752+
}
3753+
37513754
#ifdef WITH_WSREP
37523755
const bool wsrep_applier; /* dedicated slave applier thread */
37533756
bool wsrep_applier_closing; /* applier marked to close */

sql/sql_parse.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3132,9 +3132,8 @@ mysql_execute_command(THD *thd)
31323132
raise a warning, as it may cause problems
31333133
(see 'NAME_CONST issues' in 'Binary Logging of Stored Programs')
31343134
*/
3135-
if (thd->query_name_consts &&
3136-
mysql_bin_log.is_open() &&
3137-
WSREP_FORMAT((enum enum_binlog_format) thd->variables.binlog_format) == BINLOG_FORMAT_STMT &&
3135+
if (thd->query_name_consts && mysql_bin_log.is_open() &&
3136+
thd->wsrep_binlog_format() == BINLOG_FORMAT_STMT &&
31383137
!mysql_bin_log.is_query_in_union(thd, thd->query_id))
31393138
{
31403139
List_iterator_fast<Item> it(select_lex->item_list);

sql/wsrep_mysqld.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,11 @@ extern wsrep_seqno_t wsrep_locked_seqno;
169169
#define WSREP_EMULATE_BINLOG(thd) \
170170
(WSREP(thd) && wsrep_emulate_bin_log)
171171

172-
// MySQL logging functions don't seem to understand long long length modifer.
173-
// This is a workaround. It also prefixes all messages with "WSREP"
172+
#define WSREP_FORMAT(my_format) \
173+
((wsrep_forced_binlog_format != BINLOG_FORMAT_UNSPEC) \
174+
? wsrep_forced_binlog_format : (ulong)(my_format))
175+
176+
// prefix all messages with "WSREP"
174177
#define WSREP_LOG(fun, ...) \
175178
do { \
176179
char msg[1024] = {'\0'}; \
@@ -309,6 +312,7 @@ int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len);
309312
#define WSREP_ON (0)
310313
#define WSREP_EMULATE_BINLOG(thd) (0)
311314
#define WSREP_CLIENT(thd) (0)
315+
#define WSREP_FORMAT(my_format) ((ulong)my_format)
312316
#define wsrep_emulate_bin_log (0)
313317
#define wsrep_xid_seqno(X) (0)
314318
#define wsrep_to_isolation (0)

0 commit comments

Comments
 (0)