1#ifndef SESSION_TRACKER_INCLUDED
2#define SESSION_TRACKER_INCLUDED
56#define SESSION_TRACKER_END TRACK_TRANSACTION_STATE
58#define TX_TRACKER_GET(a) \
59 Transaction_state_tracker *a = \
60 (Transaction_state_tracker *)thd->session_tracker.get_tracker( \
61 TRANSACTION_INFO_TRACKER)
Definition: session_tracker.h:186
bool update(THD *thd) override
Enable/disable the tracker based on @session_track_state_change value.
Definition: session_tracker.cc:1442
void reset()
Reset the m_changed flag for next statement.
Definition: session_tracker.cc:1502
Session_state_change_tracker()
Constructor.
Definition: session_tracker.cc:1416
bool enable(THD *thd) override
Initiate the value of m_enabled based on @session_track_state_change value.
Definition: session_tracker.cc:1429
bool store(THD *, String &buf) override
Store the 1byte boolean flag in the specified buffer.
Definition: session_tracker.cc:1457
bool is_state_changed()
find if there is a session state change
Definition: session_tracker.cc:1512
bool check(THD *, set_var *) override
To be invoked when the tracker's system variable is checked (ON_CHECK).
Definition: session_tracker.h:193
void mark_as_changed(THD *thd, LEX_CSTRING tracked_item_name) override
Mark the tracker as changed and associated session attributes accordingly.
Definition: session_tracker.cc:1484
Definition: session_tracker.h:129
void deinit()
Definition: session_tracker.h:166
bool changed_any()
Checks if m_changed flag is set for any of the tracker objects.
Definition: session_tracker.cc:1622
State_tracker * get_tracker(enum_session_tracker tracker) const
Returns the pointer to the tracker object for the specified tracker.
Definition: session_tracker.cc:1592
Session_tracker & operator=(Session_tracker const &)=delete
void claim_memory_ownership(bool claim)
Definition: session_tracker.cc:1550
bool enabled_any()
Checks if m_enabled flag is set for any of the tracker objects.
Definition: session_tracker.cc:1606
bool server_boot_verify(const CHARSET_INFO *char_set, LEX_STRING var_list)
Method called during the server startup to verify the contents of @session_track_system_variables.
Definition: session_tracker.cc:1574
void enable(THD *thd)
Enables the tracker objects.
Definition: session_tracker.cc:1560
Session_tracker(Session_tracker const &)=delete
void init(const CHARSET_INFO *char_set)
Initialize Session_tracker objects and enable them based on the tracker_xxx variables' value that the...
Definition: session_tracker.cc:1536
Session_tracker()=default
Constructor.
void store(THD *thd, String &main_buf)
Stores the session state change information of all changes session state type entities into the speci...
Definition: session_tracker.cc:1637
~Session_tracker()=default
Destructor.
State_tracker * m_trackers[SESSION_TRACKER_END+1]
Definition: session_tracker.h:131
Definition: session_tracker.h:83
bool m_changed
Has the session state type changed ?
Definition: session_tracker.h:89
virtual bool check(THD *thd, set_var *var)=0
To be invoked when the tracker's system variable is checked (ON_CHECK).
State_tracker()
Constructor.
Definition: session_tracker.h:93
virtual bool enable(THD *thd)=0
Called in the constructor of THD.
virtual bool update(THD *thd)=0
To be invoked when the tracker's system variable is updated (ON_UPDATE).
virtual void claim_memory_ownership(bool claim)
Definition: session_tracker.h:118
bool m_enabled
Is tracking enabled for a particular session state type ?
Definition: session_tracker.h:86
bool is_enabled() const
Getters.
Definition: session_tracker.h:99
bool is_changed() const
Definition: session_tracker.h:101
virtual void mark_as_changed(THD *thd, LEX_CSTRING name)=0
Mark the entity as changed.
virtual ~State_tracker()=default
Destructor.
virtual bool store(THD *thd, String &buf)=0
Store changed data into the given buffer.
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:167
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Definition: session_tracker.h:255
uint get_trx_state() const
Get (possibly still incomplete) state.
Definition: session_tracker.h:279
bool check(THD *, set_var *) override
To be invoked when the tracker's system variable is checked (ON_CHECK).
Definition: session_tracker.h:260
Transaction_state_tracker()
Constructor.
Definition: session_tracker.cc:911
enum_tx_state calc_trx_state(thr_lock_type l, bool has_trx)
Helper function: turn table info into table access flag.
Definition: session_tracker.cc:1252
uint tx_reported_state
Definition: session_tracker.h:292
void add_trx_state(THD *thd, uint add)
Add flags pertaining to the current statement or transaction.
Definition: session_tracker.cc:1304
bool enable(THD *thd) override
Called in the constructor of THD.
Definition: session_tracker.h:259
void reset()
Reset the m_changed flag for next statement.
Definition: session_tracker.cc:1235
void end_trx(THD *thd)
Register the end of an (implicit or explicit) transaction.
Definition: session_tracker.cc:1270
enum enum_tx_isol_level tx_isol_level
isolation level
Definition: session_tracker.h:298
void set_read_flags(THD *thd, enum enum_tx_read_flags flags)
Change transaction characteristics.
Definition: session_tracker.cc:1385
enum enum_tx_read_flags tx_read_flags
r/w or r/o set? session default?
Definition: session_tracker.h:295
uint tx_changed
any trackable changes caused by this statement?
Definition: session_tracker.h:289
void clear_trx_state(THD *thd, uint clear)
Change transaction state.
Definition: session_tracker.cc:1289
void set_isol_level(THD *thd, enum enum_tx_isol_level level)
Set isolation level pertaining to the next transaction.
Definition: session_tracker.cc:1402
bool update(THD *thd) override
Enable/disable the tracker based on @session_track_transaction_info's value.
Definition: session_tracker.cc:929
uint tx_curr_state
transaction state
Definition: session_tracker.h:292
bool store(THD *thd, String &buf) override
Store the transaction state (and, optionally, characteristics) as length-encoded string in the specif...
Definition: session_tracker.cc:963
void mark_as_changed(THD *thd, LEX_CSTRING tracked_item_name) override
Mark the tracker as changed.
Definition: session_tracker.cc:1227
enum_tx_changed
Definition: session_tracker.h:282
@ TX_CHG_CHISTICS
characteristics have changed from previous stmt
Definition: session_tracker.h:285
@ TX_CHG_NONE
no changes from previous stmt
Definition: session_tracker.h:283
@ TX_CHG_STATE
state has changed from previous stmt
Definition: session_tracker.h:284
void add_trx_state_from_thd(THD *thd)
Add "unsafe statement" flag if applicable.
Definition: session_tracker.cc:1374
void update_change_flags(THD *thd)
Definition: session_tracker.h:302
set_var_base descendant for assignments to the system variables.
Definition: set_var.h:983
static int flags[50]
Definition: hp_test1.cc:40
Definition: buf0block_hint.cc:30
static mysql_service_status_t clear(reference_caching_channel channel) noexcept
Definition: component.cc:146
static mysql_service_status_t add(reference_caching_channel channel, const char *implementation_name) noexcept
Definition: component.cc:127
#define SESSION_TRACKER_END
Definition: session_tracker.h:56
enum_session_tracker
Definition: session_tracker.h:39
@ SESSION_GTIDS_TRACKER
Definition: session_tracker.h:43
@ SESSION_STATE_CHANGE_TRACKER
Definition: session_tracker.h:42
@ CURRENT_SCHEMA_TRACKER
Definition: session_tracker.h:41
@ TRACK_TRANSACTION_STATE
Definition: session_tracker.h:53
@ TRANSACTION_INFO_TRACKER
Definition: session_tracker.h:44
@ SESSION_SYSVARS_TRACKER
Definition: session_tracker.h:40
enum_tx_isol_level
Transaction isolation level.
Definition: session_tracker.h:238
@ TX_ISOL_INHERIT
not explicitly set, inherit session.tx_isolation
Definition: session_tracker.h:239
@ TX_ISOL_UNCOMMITTED
Definition: session_tracker.h:240
@ TX_ISOL_COMMITTED
Definition: session_tracker.h:241
@ TX_ISOL_REPEATABLE
Definition: session_tracker.h:242
@ TX_ISOL_SERIALIZABLE
Definition: session_tracker.h:243
enum_session_track_transaction_info
Transaction tracking level.
Definition: session_tracker.h:249
@ TX_TRACK_STATE
track transaction status
Definition: session_tracker.h:251
@ TX_TRACK_CHISTICS
track status and characteristics
Definition: session_tracker.h:252
@ TX_TRACK_NONE
do not send tracker items on transaction info
Definition: session_tracker.h:250
enum_tx_read_flags
Transaction access mode.
Definition: session_tracker.h:229
@ TX_READ_INHERIT
not explicitly set, inherit session.tx_read_only
Definition: session_tracker.h:230
@ TX_READ_ONLY
START TRANSACTION READ ONLY, or tx_read_only=1.
Definition: session_tracker.h:231
@ TX_READ_WRITE
START TRANSACTION READ WRITE, or tx_read_only=0.
Definition: session_tracker.h:232
enum_tx_state
Transaction state (no transaction, transaction active, work attached, etc.)
Definition: session_tracker.h:210
@ TX_READ_UNSAFE
non-transaction reads were done
Definition: session_tracker.h:215
@ TX_STMT_DML
a DML statement (known before data is accessed)
Definition: session_tracker.h:222
@ TX_STMT_DDL
a DDL statement
Definition: session_tracker.h:223
@ TX_EMPTY
"none of the below"
Definition: session_tracker.h:211
@ TX_EXPLICIT
an explicit transaction is active
Definition: session_tracker.h:212
@ TX_WRITE_UNSAFE
non-transactional writes were done
Definition: session_tracker.h:217
@ TX_WRITE_TRX
transactional writes were done
Definition: session_tracker.h:216
@ TX_LOCKED_TABLES
LOCK TABLES is active.
Definition: session_tracker.h:221
@ TX_WITH_SNAPSHOT
WITH CONSISTENT SNAPSHOT was used.
Definition: session_tracker.h:220
@ TX_IMPLICIT
an implicit transaction is active
Definition: session_tracker.h:213
@ TX_RESULT_SET
result-set was sent
Definition: session_tracker.h:219
@ TX_STMT_UNSAFE
"unsafe" (non-deterministic like UUID()) stmts
Definition: session_tracker.h:218
@ TX_READ_TRX
transactional reads were done
Definition: session_tracker.h:214
case opt name
Definition: sslopt-case.h:29
Definition: m_ctype.h:421
Definition: mysql_lex_string.h:40
Definition: mysql_lex_string.h:35
thr_lock_type
Definition: thr_lock.h:51