summaryrefslogtreecommitdiff
path: root/sql/session_tracker.h
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2019-03-18 17:13:00 +0400
committerSergey Vojtovich <svoj@mariadb.org>2019-05-03 16:36:48 +0400
commit47bd06d55ec211bc4d05d616a0833629504c7edf (patch)
tree3c7b6cf75bace272be211e8354da3bbb081a5eb7 /sql/session_tracker.h
parent01e8f3c52b349a0374c04f0765a625b5ac03a652 (diff)
downloadmariadb-git-47bd06d55ec211bc4d05d616a0833629504c7edf.tar.gz
Static current schema and state change trackers
Saves 2 new/delete per connection. Part of MDEV-14984 - regression in connect performance
Diffstat (limited to 'sql/session_tracker.h')
-rw-r--r--sql/session_tracker.h69
1 files changed, 57 insertions, 12 deletions
diff --git a/sql/session_tracker.h b/sql/session_tracker.h
index 8265e638f1b..ec6d21bd344 100644
--- a/sql/session_tracker.h
+++ b/sql/session_tracker.h
@@ -88,8 +88,18 @@ public:
void reset_changed() { m_changed= false; }
- /** Called in the constructor of THD*/
- virtual bool enable(THD *thd) { return update(thd, 0); }
+ /**
+ Called by THD::init() when new connection is being created
+
+ We may inherit m_changed from previous connection served by this THD if
+ connection was broken or client didn't have session tracking capability.
+ Thus we have to reset it here.
+ */
+ virtual bool enable(THD *thd)
+ {
+ reset_changed();
+ return update(thd, 0);
+ }
/** To be invoked when the tracker's system variable is updated (ON_UPDATE).*/
virtual bool update(THD *thd, set_var *var)= 0;
@@ -101,12 +111,50 @@ public:
virtual void mark_as_changed(THD *thd, LEX_CSTRING *name);
};
+
bool sysvartrack_validate_value(THD *thd, const char *str, size_t len);
bool sysvartrack_global_update(THD *thd, char *str, size_t len);
uchar *sysvartrack_session_value_ptr(THD *thd, const LEX_CSTRING *base);
/**
+ Current_schema_tracker,
+
+ This is a tracker class that enables & manages the tracking of current
+ schema for a particular connection.
+*/
+
+class Current_schema_tracker: public State_tracker
+{
+public:
+ bool update(THD *thd, set_var *var);
+ bool store(THD *thd, String *buf);
+};
+
+
+/*
+ Session_state_change_tracker
+
+ This is a boolean tracker class that will monitor any change that contributes
+ to a session state change.
+ Attributes that contribute to session state change include:
+ - Successful change to System variables
+ - User defined variables assignments
+ - temporary tables created, altered or deleted
+ - prepared statements added or removed
+ - change in current database
+ - change of current role
+*/
+
+class Session_state_change_tracker: public State_tracker
+{
+public:
+ bool update(THD *thd, set_var *var);
+ bool store(THD *thd, String *buf);
+};
+
+
+/**
Session_tracker
This class holds an object each for all tracker classes and provides
@@ -130,22 +178,19 @@ class Session_tracker
}
public:
+ Current_schema_tracker current_schema;
+ Session_state_change_tracker state_change;
Session_tracker();
- ~Session_tracker()
- {
- deinit();
- }
+ ~Session_tracker() { deinit(); }
/* trick to make happy memory accounting system */
void deinit()
{
- for (int i= 0; i < SESSION_TRACKER_END; i++)
- {
- if (m_trackers[i])
- delete m_trackers[i];
- m_trackers[i]= NULL;
- }
+ delete m_trackers[SESSION_SYSVARS_TRACKER];
+ m_trackers[SESSION_SYSVARS_TRACKER]= 0;
+ delete m_trackers[TRANSACTION_INFO_TRACKER];
+ m_trackers[TRANSACTION_INFO_TRACKER]= 0;
}
void enable(THD *thd);