Skip to content

Commit c464ec1

Browse files
author
Sven Sandberg
committed
BUG#31795721: ENUMERATION VALUE ENUM_SESSION_TRACK_GTIDS::OFF DEFINED AS A GLOBAL SYMBOL
Background: The C++ enum type enum_session_track_gtids was defined in global scope and had a member named 'OFF'. This resulted in OFF being a global symbol. Problem: The name is too broad and the use case too narrow for it to live in global scope. (In fact, it was used by mistake in one place where another type was expected.) Fix: Prefix the members of this enum type with SESSION_TRACK_GTIDS . RB:25022
1 parent b522413 commit c464ec1

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

sql/rpl_context.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Session_consistency_gtids_ctx::Session_consistency_gtids_ctx()
3838
: m_sid_map(nullptr),
3939
m_gtid_set(nullptr),
4040
m_listener(nullptr),
41-
m_curr_session_track_gtids(OFF) {}
41+
m_curr_session_track_gtids(SESSION_TRACK_GTIDS_OFF) {}
4242

4343
Session_consistency_gtids_ctx::~Session_consistency_gtids_ctx() {
4444
if (m_gtid_set) {
@@ -55,7 +55,8 @@ Session_consistency_gtids_ctx::~Session_consistency_gtids_ctx() {
5555
inline bool Session_consistency_gtids_ctx::shall_collect(const THD *thd) {
5656
return /* Do not track OWN_GTID if session does not own a
5757
(non-anonymous) GTID. */
58-
(thd->owned_gtid.sidno > 0 || m_curr_session_track_gtids == ALL_GTIDS) &&
58+
(thd->owned_gtid.sidno > 0 ||
59+
m_curr_session_track_gtids == SESSION_TRACK_GTIDS_ALL_GTIDS) &&
5960
/* if there is no listener/tracker, then there is no reason to collect */
6061
m_listener != nullptr &&
6162
/* ROLLBACK statements may end up calling trans_commit_stmt */
@@ -71,7 +72,7 @@ bool Session_consistency_gtids_ctx::notify_after_transaction_commit(
7172

7273
if (!shall_collect(thd)) return res;
7374

74-
if (m_curr_session_track_gtids == ALL_GTIDS) {
75+
if (m_curr_session_track_gtids == SESSION_TRACK_GTIDS_ALL_GTIDS) {
7576
/*
7677
If one is configured to read all writes, we always collect
7778
the GTID_EXECUTED.
@@ -97,7 +98,7 @@ bool Session_consistency_gtids_ctx::notify_after_gtid_executed_update(
9798

9899
if (!shall_collect(thd)) return res;
99100

100-
if (m_curr_session_track_gtids == OWN_GTID) {
101+
if (m_curr_session_track_gtids == SESSION_TRACK_GTIDS_OWN_GTID) {
101102
DBUG_ASSERT(global_gtid_mode.get() != Gtid_mode::OFF);
102103
DBUG_ASSERT(thd->owned_gtid.sidno > 0);
103104
const Gtid &gtid = thd->owned_gtid;

sql/session_tracker.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,9 +1577,11 @@ bool Session_gtids_tracker::update(THD *thd) {
15771577
We are updating this using the previous value. No change needed.
15781578
Bailing out.
15791579
*/
1580-
if (m_enabled == (thd->variables.session_track_gtids != OFF)) return false;
1580+
if (m_enabled ==
1581+
(thd->variables.session_track_gtids != SESSION_TRACK_GTIDS_OFF))
1582+
return false;
15811583

1582-
m_enabled = thd->variables.session_track_gtids != OFF &&
1584+
m_enabled = thd->variables.session_track_gtids != SESSION_TRACK_GTIDS_OFF &&
15831585
/* No need to track GTIDs for system threads. */
15841586
thd->system_thread == NON_SYSTEM_THREAD;
15851587
if (m_enabled) {

sql/sys_vars.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,8 +1405,9 @@ static Sys_var_enum Sys_session_track_gtids(
14051405
"included in the response packet sent by the server."
14061406
"(Default: OFF).",
14071407
SESSION_VAR(session_track_gtids), CMD_LINE(REQUIRED_ARG),
1408-
session_track_gtids_names, DEFAULT(OFF), NO_MUTEX_GUARD, NOT_IN_BINLOG,
1409-
ON_CHECK(check_outside_trx), ON_UPDATE(on_session_track_gtids_update));
1408+
session_track_gtids_names, DEFAULT(SESSION_TRACK_GTIDS_OFF), NO_MUTEX_GUARD,
1409+
NOT_IN_BINLOG, ON_CHECK(check_outside_trx),
1410+
ON_UPDATE(on_session_track_gtids_update));
14101411

14111412
static bool binlog_direct_check(sys_var *self, THD *thd, set_var *var) {
14121413
if (check_session_admin(self, thd, var)) return true;
@@ -6348,8 +6349,9 @@ static Sys_var_enum Sys_session_track_transaction_info(
63486349
"characteristics (isolation level, read only/read write, snapshot - "
63496350
"but not any work done / data modified within the transaction).",
63506351
SESSION_VAR(session_track_transaction_info), CMD_LINE(REQUIRED_ARG),
6351-
session_track_transaction_info_names, DEFAULT(OFF), NO_MUTEX_GUARD,
6352-
NOT_IN_BINLOG, ON_CHECK(nullptr), ON_UPDATE(update_session_track_tx_info));
6352+
session_track_transaction_info_names, DEFAULT(TX_TRACK_NONE),
6353+
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(nullptr),
6354+
ON_UPDATE(update_session_track_tx_info));
63536355

63546356
static bool update_session_track_state_change(sys_var *, THD *thd,
63556357
enum_var_type) {

sql/system_variables.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ enum enum_transaction_write_set_hashing_algorithm {
8787
};
8888

8989
// Values for session_track_gtids sysvar
90-
enum enum_session_track_gtids { OFF = 0, OWN_GTID = 1, ALL_GTIDS = 2 };
90+
enum enum_session_track_gtids {
91+
SESSION_TRACK_GTIDS_OFF = 0,
92+
SESSION_TRACK_GTIDS_OWN_GTID = 1,
93+
SESSION_TRACK_GTIDS_ALL_GTIDS = 2
94+
};
9195

9296
/** Values for use_secondary_engine sysvar. */
9397
enum use_secondary_engine {

0 commit comments

Comments
 (0)