diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2019-06-20 18:02:40 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2019-09-24 15:49:35 +0400 |
commit | f5c3ad1913f60b02a283c5ba3ff53f6259b3f1a3 (patch) | |
tree | f3e1a86359eeb93c0d4bab1cad78fe09dded5b7e /sql/session_tracker.h | |
parent | ad77e3ac0930a68e61378790a232f1056f0a8e7c (diff) | |
download | mariadb-git-f5c3ad1913f60b02a283c5ba3ff53f6259b3f1a3.tar.gz |
MDEV-16470 - Session user variables tracker
Based on contribution by Dapeng Huang.
Diffstat (limited to 'sql/session_tracker.h')
-rw-r--r-- | sql/session_tracker.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/sql/session_tracker.h b/sql/session_tracker.h index 269b1bd2359..b91e588a34e 100644 --- a/sql/session_tracker.h +++ b/sql/session_tracker.h @@ -19,12 +19,14 @@ #include "m_string.h" #include "thr_lock.h" +#include "sql_hset.h" #ifndef EMBEDDED_LIBRARY /* forward declarations */ class THD; class set_var; class String; +class user_var_entry; enum enum_session_tracker @@ -33,6 +35,7 @@ enum enum_session_tracker CURRENT_SCHEMA_TRACKER, /* Current schema */ SESSION_STATE_CHANGE_TRACKER, TRANSACTION_INFO_TRACKER, /* Transaction state */ + USER_VARIABLES_TRACKER, SESSION_TRACKER_END /* must be the last */ }; @@ -388,6 +391,35 @@ private: /** + User_variables_tracker + + This is a tracker class that enables & manages the tracking of user variables. +*/ + +class User_variables_tracker: public State_tracker +{ + Hash_set<const user_var_entry> m_changed_user_variables; +public: + User_variables_tracker(): + m_changed_user_variables(&my_charset_bin, 0, 0, + sizeof(const user_var_entry*), 0, 0, + HASH_UNIQUE | (mysqld_server_initialized ? + HASH_THREAD_SPECIFIC : 0)) {} + bool update(THD *thd, set_var *var); + bool store(THD *thd, String *buf); + void mark_as_changed(THD *thd, const user_var_entry *var) + { + if (is_enabled()) + { + m_changed_user_variables.insert(var); + set_changed(thd); + } + } + void deinit() { m_changed_user_variables.~Hash_set(); } +}; + + +/** Session_tracker This class holds an object each for all tracker classes and provides @@ -415,6 +447,7 @@ public: Session_state_change_tracker state_change; Transaction_state_tracker transaction_info; Session_sysvars_tracker sysvars; + User_variables_tracker user_variables; Session_tracker() { @@ -422,6 +455,7 @@ public: m_trackers[CURRENT_SCHEMA_TRACKER]= ¤t_schema; m_trackers[SESSION_STATE_CHANGE_TRACKER]= &state_change; m_trackers[TRANSACTION_INFO_TRACKER]= &transaction_info; + m_trackers[USER_VARIABLES_TRACKER]= &user_variables; } void enable(THD *thd) |