[Commits] ea34355: postmerge fixes

Oleksandr Byelkin sanja at mariadb.com
Tue May 24 18:13:52 EEST 2016


revision-id: ea34355586f50dd82e3c358f899b169230016981 (mariadb-10.2.0-46-gea34355)
parent(s): 4a3c87a72ccae6dca10e2128ee5f12c191c682e4
committer: Oleksandr Byelkin
timestamp: 2016-05-24 17:13:52 +0200
message:

postmerge fixes

---
 .../r/session_track_system_variables_basic.result  |  17 +-
 .../t/session_track_system_variables_basic.test    |   2 +-
 sql/mysqld.cc                                      |   1 -
 sql/session_tracker.cc                             |  39 ++-
 sql/sql_class.h                                    |   2 +
 sql/sys_vars.cc                                    |   7 +-
 sql/sys_vars.ic                                    | 371 +++++++--------------
 7 files changed, 166 insertions(+), 273 deletions(-)

diff --git a/mysql-test/suite/sys_vars/r/session_track_system_variables_basic.result b/mysql-test/suite/sys_vars/r/session_track_system_variables_basic.result
index e94cf58..9250962 100644
--- a/mysql-test/suite/sys_vars/r/session_track_system_variables_basic.result
+++ b/mysql-test/suite/sys_vars/r/session_track_system_variables_basic.result
@@ -44,6 +44,7 @@ SELECT @@session.session_track_system_variables;
 autocommit
 
 # Variables' values in a new session.
+connect  con1,"127.0.0.1",root,,test,$MASTER_MYPORT,;
 # Global - expect "autocommit"
 SELECT @@global.session_track_system_variables;
 @@global.session_track_system_variables
@@ -55,6 +56,7 @@ SELECT @@session.session_track_system_variables;
 autocommit
 
 # Switching to the default connection.
+connection default;
 SELECT @@global.session_track_system_variables;
 @@global.session_track_system_variables
 autocommit
@@ -74,6 +76,7 @@ SELECT @@session.session_track_system_variables;
 autocommit,character_set_client,character_set_connection,character_set_results,time_zone
 
 # Variables' values in a new session (con2).
+connect  con2,"127.0.0.1",root,,test,$MASTER_MYPORT,;
 SELECT @@global.session_track_system_variables;
 @@global.session_track_system_variables
 autocommit,character_set_client,character_set_connection,character_set_results,time_zone
@@ -91,6 +94,7 @@ SELECT @@session.session_track_system_variables;
 sql_mode
 
 # Variables' values in a new session (con3).
+connect  con3,"127.0.0.1",root,,test,$MASTER_MYPORT,;
 # Altering global should not affect session.
 SET @@global.session_track_system_variables = 'sql_mode';
 SELECT @@global.session_track_system_variables;
@@ -101,32 +105,29 @@ SELECT @@session.session_track_system_variables;
 autocommit,character_set_client,character_set_connection,character_set_results,time_zone
 
 # Switching to the default connection.
+connection default;
 # Testing NULL
 SET @@global.session_track_system_variables = NULL;
 SET @@session.session_track_system_variables = NULL;
 # Global - expect "" instead of NULL
 SELECT @@global.session_track_system_variables;
 @@global.session_track_system_variables
-
+NULL
 # Session - expect "" instead of NULL
 SELECT @@session.session_track_system_variables;
 @@session.session_track_system_variables
 
-# testing with duplicate entries (must fail).
+# testing with duplicate entries.
 SET @@global.session_track_system_variables= "time_zone";
 SET @@session.session_track_system_variables= "time_zone";
 SET @@global.session_track_system_variables= "sql_mode,sql_mode";
-ERROR HY000: Duplicate entry 'sql_mode'.
 SET @@session.session_track_system_variables= "sql_mode,sql_mode";
-ERROR HY000: Duplicate entry 'sql_mode'.
-# Global - must remain unchanged, 'time_zone'
 SELECT @@global.session_track_system_variables;
 @@global.session_track_system_variables
-time_zone
-# Session - must remain unchanged, 'time_zone'
+sql_mode,sql_mode
 SELECT @@session.session_track_system_variables;
 @@session.session_track_system_variables
-time_zone
+sql_mode
 
 # Restoring the original values.
 SET @@global.session_track_system_variables = @global_saved_tmp;
diff --git a/mysql-test/suite/sys_vars/t/session_track_system_variables_basic.test b/mysql-test/suite/sys_vars/t/session_track_system_variables_basic.test
index 10f4805..0be2bf2 100644
--- a/mysql-test/suite/sys_vars/t/session_track_system_variables_basic.test
+++ b/mysql-test/suite/sys_vars/t/session_track_system_variables_basic.test
@@ -97,7 +97,7 @@ SELECT @@global.session_track_system_variables;
 --echo # Session - expect "" instead of NULL
 SELECT @@session.session_track_system_variables;
 
---echo # testing with duplicate entries (must fail).
+--echo # testing with duplicate entries.
 # Lets first set it to some valid value.
 SET @@global.session_track_system_variables= "time_zone";
 SET @@session.session_track_system_variables= "time_zone";
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 4d6ae41..e3aba86 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -698,7 +698,6 @@ struct system_variables global_system_variables;
   TODO: something should be done to get rid of following variables
 */
 const char *current_dbug_option="";
-const char *current_session_track_system_variables="";
 
 struct system_variables max_system_variables;
 struct system_status_var global_status_var;
diff --git a/sql/session_tracker.cc b/sql/session_tracker.cc
index 3b4d491..db54939 100644
--- a/sql/session_tracker.cc
+++ b/sql/session_tracker.cc
@@ -73,6 +73,7 @@ class Session_sysvars_tracker : public State_tracker
     HASH m_registered_sysvars;
     /** Size of buffer for string representation */
     size_t buffer_length;
+    myf m_mem_flag;
     /**
       If TRUE then we want to check all session variable.
     */
@@ -82,7 +83,9 @@ class Session_sysvars_tracker : public State_tracker
       my_hash_init(&m_registered_sysvars,
                    &my_charset_bin,
 		   4, 0, 0, (my_hash_get_key) sysvars_get_key,
-		   my_free, MYF(HASH_UNIQUE | HASH_THREAD_SPECIFIC));
+		   my_free, MYF(HASH_UNIQUE |
+                                ((m_mem_flag & MY_THREAD_SPECIFIC) ?
+                                 HASH_THREAD_SPECIFIC : 0)));
     }
     void free_hash()
     {
@@ -102,6 +105,7 @@ class Session_sysvars_tracker : public State_tracker
     vars_list() :
       buffer_length(0)
     {
+      m_mem_flag= current_thd ? MY_THREAD_SPECIFIC : 0;
       init();
     }
 
@@ -127,7 +131,7 @@ class Session_sysvars_tracker : public State_tracker
       {
 	if (track_all)
 	{
-	  insert(node, svar);
+	  insert(node, svar, m_mem_flag);
 	  return search(svar);
 	}
       }
@@ -138,9 +142,9 @@ class Session_sysvars_tracker : public State_tracker
     {
       return my_hash_element(&m_registered_sysvars, idx);
     }
-    bool insert(sysvar_node_st *node, const sys_var *svar);
+    bool insert(sysvar_node_st *node, const sys_var *svar, myf mem_flag);
     void reset();
-    bool copy(vars_list* from, THD *thd);
+    void copy(vars_list* from, THD *thd);
     bool parse_var_list(THD *thd, LEX_STRING var_list, bool throw_error,
                         const CHARSET_INFO *char_set, bool session_created);
     bool construct_var_list(char *buf, size_t buf_len);
@@ -180,7 +184,8 @@ class Session_sysvars_tracker : public State_tracker
     for session_track_system_variables during the server
     startup.
   */
-  static bool server_init_check(const CHARSET_INFO *char_set, LEX_STRING var_list)
+  static bool server_init_check(const CHARSET_INFO *char_set,
+                                LEX_STRING var_list)
   {
     vars_list dummy;
     bool result;
@@ -289,7 +294,7 @@ void Session_sysvars_tracker::vars_list::reset()
   @retval false nothing to track
 */
 
-bool Session_sysvars_tracker::vars_list::copy(vars_list* from, THD *thd)
+void Session_sysvars_tracker::vars_list::copy(vars_list* from, THD *thd)
 {
   reset();
   track_all= from->track_all;
@@ -297,7 +302,6 @@ bool Session_sysvars_tracker::vars_list::copy(vars_list* from, THD *thd)
   buffer_length= from->buffer_length;
   m_registered_sysvars= from->m_registered_sysvars;
   from->init();
-  return (m_registered_sysvars.records)? true : track_all;
 }
 
 /**
@@ -311,12 +315,13 @@ bool Session_sysvars_tracker::vars_list::copy(vars_list* from, THD *thd)
 */
 
 bool Session_sysvars_tracker::vars_list::insert(sysvar_node_st *node,
-                                                const sys_var *svar)
+                                                const sys_var *svar,
+                                                myf mem_flag)
 {
   if (!node)
   {
     if (!(node= (sysvar_node_st *) my_malloc(sizeof(sysvar_node_st),
-                                             MYF(MY_WME | MY_THREAD_SPECIFIC))))
+                                             MYF(MY_WME | mem_flag))))
     {
       reset();
       return true;
@@ -418,7 +423,7 @@ bool Session_sysvars_tracker::vars_list::parse_var_list(THD *thd,
 
     if ((svar= find_sys_var_ex(thd, var.str, var.length, throw_error, true)))
     {
-      if (insert(NULL, svar) == TRUE)
+      if (insert(NULL, svar, m_mem_flag) == TRUE)
         goto error;
     }
     else if (throw_error && session_created && thd)
@@ -580,7 +585,8 @@ bool Session_sysvars_tracker::enable(THD *thd)
     return true;
   }
   mysql_mutex_unlock(&LOCK_plugin);
-  m_enabled= orig_list->copy(tool_list, thd);
+  orig_list->copy(tool_list, thd);
+  m_enabled= true;
 
   return false;
 }
@@ -630,7 +636,7 @@ inline bool Session_sysvars_tracker::check_str(THD *thd, LEX_STRING val)
 
 bool Session_sysvars_tracker::update(THD *thd)
 {
-  m_enabled= orig_list->copy(tool_list, thd);
+  orig_list->copy(tool_list, thd);
   return false;
 }
 
@@ -776,8 +782,12 @@ static Session_sysvars_tracker* sysvar_tracker(THD *thd)
 
 bool sysvartrack_validate_value(THD *thd, const char *str, size_t len)
 {
-  LEX_STRING tmp= {(char *)str, len};
-  return sysvar_tracker(thd)->check_str(thd, tmp);
+  if (sysvar_tracker(thd)->is_enabled())
+  {
+    LEX_STRING tmp= {(char *)str, len};
+    return sysvar_tracker(thd)->check_str(thd, tmp);
+  }
+  return FALSE;
 }
 bool sysvartrack_update(THD *thd)
 {
@@ -1015,7 +1025,6 @@ bool Session_tracker::server_boot_verify(const CHARSET_INFO *char_set)
   server_tracker= new (std::nothrow) Session_sysvars_tracker();
   result= server_tracker->server_init_check(char_set,
                                             tmp.save_result.string_value);
-  my_free(tmp.save_result.string_value.str);
   delete server_tracker;
   return result;
 }
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 26b7eda..bd289fd 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -684,6 +684,8 @@ typedef struct system_variables
 
   my_bool session_track_schema;
   my_bool session_track_state_change;
+
+  char *session_track_system_variables;
 } SV;
 
 /**
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 55486eb..9e58643 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -5372,13 +5372,10 @@ const LEX_CSTRING SESSION_TRACK_SYSTEM_VARIABLES_NAME=
 static Sys_var_sesvartrack Sys_track_session_sys_vars(
        SESSION_TRACK_SYSTEM_VARIABLES_NAME.str,
        "Track changes in registered system variables.",
-       sys_var::SESSION,
-       CMD_LINE(REQUIRED_ARG),
+       CMD_LINE(REQUIRED_ARG), IN_SYSTEM_CHARSET,
        DEFAULT("autocommit,character_set_client,character_set_connection,"
                "character_set_results,time_zone"),
-       NO_MUTEX_GUARD,
-       NOT_IN_BINLOG,
-       ON_CHECK(0), ON_UPDATE(0));
+       NO_MUTEX_GUARD);
 
 static bool update_session_track_schema(sys_var *self, THD *thd,
                                         enum_var_type type)
diff --git a/sql/sys_vars.ic b/sql/sys_vars.ic
index dd3bec3..11683da 100644
--- a/sql/sys_vars.ic
+++ b/sql/sys_vars.ic
@@ -437,10 +437,10 @@ class Sys_var_mybool: public Sys_var_typelib
   does not destroy individual members of SV, there's no way to free
   allocated string variables for every thread.
 */
-class Sys_var_charptr: public sys_var
+class Sys_var_charptr_base: public sys_var
 {
 public:
-  Sys_var_charptr(const char *name_arg,
+  Sys_var_charptr_base(const char *name_arg,
           const char *comment, int flag_args, ptrdiff_t off, size_t size,
           CMD_LINE getopt,
           enum charset_enum is_os_charset_arg,
@@ -462,8 +462,6 @@ class Sys_var_charptr: public sys_var
     */
     option.var_type|= (flags & ALLOCATED) ? GET_STR_ALLOC : GET_STR;
     global_var(const char*)= def_val;
-    SYSVAR_ASSERT(scope() == GLOBAL);
-    SYSVAR_ASSERT(size == sizeof(char *));
   }
   void cleanup()
   {
@@ -502,11 +500,7 @@ class Sys_var_charptr: public sys_var
   }
   bool do_check(THD *thd, set_var *var)
   { return do_string_check(thd, var, charset(thd)); }
-  bool session_update(THD *thd, set_var *var)
-  {
-    DBUG_ASSERT(FALSE);
-    return true;
-  }
+  bool session_update(THD *thd, set_var *var)= 0;
   bool global_update(THD *thd, set_var *var)
   {
     char *new_val, *ptr= var->save_result.string_value.str;
@@ -525,8 +519,7 @@ class Sys_var_charptr: public sys_var
     global_var(char*)= new_val;
     return false;
   }
-  void session_save_default(THD *thd, set_var *var)
-  { DBUG_ASSERT(FALSE); }
+  void session_save_default(THD *thd, set_var *var)= 0;
   void global_save_default(THD *thd, set_var *var)
   {
     char *ptr= (char*)(intptr)option.def_value;
@@ -535,6 +528,93 @@ class Sys_var_charptr: public sys_var
   }
 };
 
+class Sys_var_charptr: public Sys_var_charptr_base
+{
+public:
+  Sys_var_charptr(const char *name_arg,
+          const char *comment, int flag_args, ptrdiff_t off, size_t size,
+          CMD_LINE getopt,
+          enum charset_enum is_os_charset_arg,
+          const char *def_val, PolyLock *lock=0,
+          enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG,
+          on_check_function on_check_func=0,
+          on_update_function on_update_func=0,
+          const char *substitute=0) :
+    Sys_var_charptr_base(name_arg, comment, flag_args, off, size, getopt,
+                         is_os_charset_arg, def_val, lock, binlog_status_arg,
+                         on_check_func, on_update_func, substitute)
+  {
+    SYSVAR_ASSERT(scope() == GLOBAL);
+    SYSVAR_ASSERT(size == sizeof(char *));
+  }
+
+  bool session_update(THD *thd, set_var *var)
+  {
+    DBUG_ASSERT(FALSE);
+    return true;
+  }
+  void session_save_default(THD *thd, set_var *var)
+  { DBUG_ASSERT(FALSE); }
+};
+
+class Sys_var_sesvartrack: public Sys_var_charptr_base
+{
+public:
+  Sys_var_sesvartrack(const char *name_arg,
+                      const char *comment,
+                      CMD_LINE getopt,
+                      enum charset_enum is_os_charset_arg,
+                      const char *def_val, PolyLock *lock) :
+    Sys_var_charptr_base(name_arg, comment,
+                         SESSION_VAR(session_track_system_variables),
+                         getopt, is_os_charset_arg, def_val, lock,
+                         VARIABLE_NOT_IN_BINLOG, 0, 0, 0)
+    {}
+  bool do_check(THD *thd, set_var *var)
+  {
+     if (Sys_var_charptr_base::do_check(thd, var) ||
+         sysvartrack_validate_value(thd, var->save_result.string_value.str,
+                                    var->save_result.string_value.length))
+       return TRUE;
+     return FALSE;
+  }
+  bool session_update(THD *thd, set_var *var)
+  {
+    return sysvartrack_update(thd);
+  }
+  void session_save_default(THD *thd, set_var *var)
+  {
+     var->save_result.string_value.str= global_var(char*);
+     var->save_result.string_value.length=
+       strlen(var->save_result.string_value.str);
+     /* parse and feel list with default values */
+     if (thd)
+     {
+       bool res=
+         sysvartrack_validate_value(thd,
+                                    var->save_result.string_value.str,
+                                    var->save_result.string_value.length);
+       DBUG_ASSERT(res == 0);
+     }
+  }
+  uchar *session_value_ptr(THD *thd, const LEX_STRING *base)
+  {
+    DBUG_ASSERT(thd != NULL);
+    size_t len= sysvartrack_value_len(thd);
+    char *res= 0;
+    char *buf= (char *)my_safe_alloca(len);
+    if (buf && !sysvartrack_value_construct(thd, buf, len))
+    {
+      size_t len= strlen(buf) + 1;
+      res= (char*) thd->alloc(len + sizeof(char *));
+      if (res)
+        memcpy((*((char**) res)= res + sizeof(char *)), buf, len);
+      my_safe_afree(buf, len);
+    }
+    return (uchar *)res;
+  }
+};
+
 
 class Sys_var_proxy_user: public sys_var
 {
@@ -750,281 +830,86 @@ class Sys_var_session_lexstring: public sys_var
   }
 };
 
+
+#ifndef DBUG_OFF
 /**
-  Session Variable with global default and external storage
+  @@session.debug_dbug and @@global.debug_dbug variables.
+
+  @@dbug variable differs from other variables in one aspect:
+  if its value is not assigned in the session, it "points" to the global
+  value, and so when the global value is changed, the change
+  immediately takes effect in the session.
+
+  This semantics is intentional, to be able to debug one session from
+  another.
 */
-class Sys_var_extstor;
-typedef bool (Sys_var_extstor::*constructor)(THD *thd, char *val,
-                                             const size_t len);
-class Sys_var_extstor: public sys_var
+class Sys_var_dbug: public sys_var
 {
 public:
-  Sys_var_extstor(const char *name_arg,
-                  const char *comment,
-                  int flag_args,
-                  ptrdiff_t off,
-                  CMD_LINE getopt,
-                  const char *def_val,
-                  PolyLock *lock=0,
-                  enum binlog_status_enum binlog_status_arg=
-                    VARIABLE_NOT_IN_BINLOG,
-                  on_check_function on_check_func=0,
-                  on_update_function on_update_func=0,
-                  const char *substitute=0)
+  Sys_var_dbug(const char *name_arg,
+               const char *comment, int flag_args,
+               CMD_LINE getopt,
+               const char *def_val, PolyLock *lock=0,
+               enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG,
+               on_check_function on_check_func=0,
+               on_update_function on_update_func=0,
+               const char *substitute=0)
     : sys_var(&all_sys_vars, name_arg, comment, flag_args,
-              off,
-              getopt.id,
+              (char*)&current_dbug_option-(char*)&global_system_variables, getopt.id,
               getopt.arg_type, SHOW_CHAR, (intptr)def_val,
               lock, binlog_status_arg, on_check_func, on_update_func,
               substitute)
   { option.var_type|= GET_STR; }
-  /* new interface */
-  virtual bool validate_value(THD *thd, const char *str, const size_t len)= 0;
-  virtual bool update_extstor_default(THD *thd)= 0;
-  virtual bool update_extstor(THD *thd, const char *str, const size_t len)= 0;
-  virtual bool update_extstor_global(THD *thd, const char *str,
-                                   const size_t len)= 0;
-  virtual size_t value_len(THD *thd)= 0;
-  virtual bool value_construct(THD *thd, char *val, const size_t len)= 0;
-  virtual size_t defvalue_len(THD *thd)= 0;
-  virtual bool defvalue_construct(THD *thd, char *val, const size_t len)= 0;
-
-private:
-  LEX_STRING make_value(THD *thd, size_t len, constructor constr)
-  {
-    DBUG_ENTER("Sys_var_extstor::make_value");
-    LEX_STRING res= {0,0};
-    char *buf= (char *)my_safe_alloca(len);
-    if (buf)
-    {
-      (this->*constr)(thd, buf, len);
-      res.length= strlen(buf);
-      DBUG_PRINT("info", ("res %u '%s'", (uint)res.length, buf));
-      if (thd) 
-        res.str= (char*) thd->memdup(buf, res.length + 1);
-      else
-        res.str= (char*) my_memdup(buf, res.length + 1, MYF(MY_WME));
-      my_safe_afree(buf, len);
-    }
-    DBUG_RETURN(res);
-  }
-
-public:
-
-  /* usual sys var */
   bool do_check(THD *thd, set_var *var)
   {
     char buff[STRING_BUFFER_USUAL_SIZE];
     String str(buff, sizeof(buff), system_charset_info), *res;
-    char *resstr;
-    size_t len;
 
     if (!(res=var->value->val_str(&str)))
-    {
-      resstr= const_cast<char*>("");
-      len= 0;
-    }
+      var->save_result.string_value.str= const_cast<char*>("");
     else
-    {
-      resstr= thd->strmake(res->ptr(), res->length());
-      len= res->length();
-    }
-
-    if (validate_value(thd, resstr, len))
-      return true;
-    var->save_result.string_value.str= resstr;
-    var->save_result.string_value.length= len;
-
+      var->save_result.string_value.str= thd->strmake(res->ptr(), res->length());
     return false;
   }
   bool session_update(THD *thd, set_var *var)
   {
     const char *val= var->save_result.string_value.str;
-    const size_t len= var->save_result.string_value.length;
     if (!var->value)
-      return update_extstor_default(thd);
+      DBUG_POP();
     else
-      return update_extstor(thd, val, len);
+      DBUG_SET(val);
+    return false;
   }
   bool global_update(THD *thd, set_var *var)
   {
-    return update_extstor_global(thd, var->save_result.string_value.str,
-                                 var->save_result.string_value.length);
+    const char *val= var->save_result.string_value.str;
+    DBUG_SET_INITIAL(val);
+    return false;
   }
   void session_save_default(THD *thd, set_var *var)
-  {
-    DBUG_ASSERT(thd != NULL);
-    var->save_result.string_value=
-      make_value(thd, defvalue_len(thd),
-                 &Sys_var_extstor::defvalue_construct);
-  }
+  { }
   void global_save_default(THD *thd, set_var *var)
   {
     char *ptr= (char*)(intptr)option.def_value;
     var->save_result.string_value.str= ptr;
-    var->save_result.string_value.length= strlen(ptr);
   }
   uchar *session_value_ptr(THD *thd, const LEX_STRING *base)
   {
-    DBUG_ASSERT(thd != NULL);
-    LEX_STRING res= make_value(thd, value_len(thd),
-                               &Sys_var_extstor::value_construct);
-    return (uchar *)res.str;
+    char buf[256];
+    DBUG_EXPLAIN(buf, sizeof(buf));
+    return (uchar*) thd->strdup(buf);
   }
   uchar *global_value_ptr(THD *thd, const LEX_STRING *base)
   {
-    LEX_STRING res= make_value(NULL, defvalue_len(NULL),
-                               &Sys_var_extstor::defvalue_construct);
-    return (uchar *)res.str;
+    char buf[256];
+    DBUG_EXPLAIN_INITIAL(buf, sizeof(buf));
+    return (uchar*) thd->strdup(buf);
   }
   uchar *default_value_ptr(THD *thd)
-  {
-    return (uchar *)(intptr)option.def_value;
-  }
-};
-
-#ifndef DBUG_OFF
-/**
-  @@session.debug_dbug and @@global.debug_dbug variables.
-
-  @@dbug variable differs from other variables in one aspect:
-  if its value is not assigned in the session, it "points" to the global
-  value, and so when the global value is changed, the change
-  immediately takes effect in the session.
-
-  This semantics is intentional, to be able to debug one session from
-  another.
-*/
-class Sys_var_dbug: public Sys_var_extstor
-{
-public:
-  Sys_var_dbug(const char *name_arg,
-               const char *comment, int flag_args,
-               CMD_LINE getopt,
-               const char *def_val, PolyLock *lock=0,
-               enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG,
-               on_check_function on_check_func=0,
-               on_update_function on_update_func=0,
-               const char *substitute=0)
-    : Sys_var_extstor(name_arg, comment, flag_args,
-                      ((char*)&current_dbug_option -
-                       (char*)&global_system_variables),
-                      getopt, def_val, lock, binlog_status_arg,
-                      on_check_func, on_update_func, substitute)
-  {}
-  virtual bool validate_value(THD *thd __attribute__((unused)),
-                              const char *str __attribute__((unused)),
-                              size_t len __attribute__((unused)))
-  { return false; }
-  virtual bool update_extstor_default(THD *thd __attribute__((unused)))
-  { DBUG_POP(); return false; }
-  virtual bool update_extstor(THD *thd __attribute__((unused)),
-                              const char *str,
-                              size_t len __attribute__((unused)))
-  { DBUG_SET(str); return false; }
-  virtual bool update_extstor_global(THD *thd __attribute__((unused)),
-                                     const char *str,
-                                     size_t len __attribute__((unused)))
-  { DBUG_SET_INITIAL(str); return false; }
-  virtual size_t value_len(THD *thd __attribute__((unused)))
-  { return 256; }
-  virtual bool value_construct(THD *thd __attribute__((unused)),
-                               char *val, size_t len)
-  { DBUG_EXPLAIN(val, len); return false; }
-  virtual size_t defvalue_len(THD *)
-  { return 256; }
-  virtual bool defvalue_construct(THD *thd __attribute__((unused)),
-                                  char *val, size_t len)
-  { DBUG_EXPLAIN_INITIAL(val, len); return false; }
+  { return (uchar*)""; }
 };
 #endif
 
-class Sys_var_sesvartrack: public Sys_var_extstor
-{
-  LEX_STRING global_val;
-public:
-  Sys_var_sesvartrack(const char *name_arg,
-                      const char *comment, int flag_args,
-                      CMD_LINE getopt,
-                      const char *def_val, PolyLock *lock=0,
-                      enum binlog_status_enum
-                        binlog_status_arg=VARIABLE_NOT_IN_BINLOG,
-                      on_check_function on_check_func=0,
-                      on_update_function on_update_func=0,
-                      const char *substitute=0)
-    : Sys_var_extstor(name_arg, comment, flag_args,
-                      ((char*)&current_session_track_system_variables -
-                       (char*)&global_system_variables),
-                      getopt, def_val, lock, binlog_status_arg,
-                      on_check_func, on_update_func, substitute)
-  {
-    global_val.str= NULL;
-    global_val.length= 0;
-    update_extstor_global(NULL, def_val, strlen(def_val));
-  }
-  virtual bool validate_value(THD *thd,
-                              const char *str,
-                              size_t len)
-  { return sysvartrack_validate_value(thd, str, len); }
-  virtual bool update_extstor_default(THD *thd)
-  { return update_extstor(thd, global_val.str, global_val.length); }
-  virtual bool update_extstor(THD *thd,
-                              const char *str __attribute__((unused)),
-                              size_t len __attribute__((unused)))
-  { return sysvartrack_update(thd); }
-  virtual bool update_extstor_global(THD *thd,
-                                     const char *str,
-                                     size_t len)
-  {
-    if (thd)
-    {
-      /*
-        Do not validate during constructing:
-        1) Default value is correct
-        2) boot value will be validated later
-      */
-      if (validate_value(thd, str, len))
-        return true;
-    }
-    if (global_val.str)
-      my_free(global_val.str);
-    if (str)
-    {
-      char *new_str= (char *)my_memdup(str, len + 1, MYF(MY_WME));
-      if (!new_str)
-        return true;
-      global_val.str= new_str;
-      global_val.length= len;
-    }
-    else
-    {
-      global_val.str= NULL;
-      global_val.length= 0;
-    }
-    return false;
-  }
-  virtual size_t value_len(THD *thd)
-  { return sysvartrack_value_len(thd); }
-  virtual bool value_construct(THD *thd, char *val, size_t len)
-  { return sysvartrack_value_construct(thd, val, len); }
-  virtual size_t defvalue_len(THD *)
-  { return global_val.length + 1; }
-  virtual bool defvalue_construct(THD *thd __attribute__((unused)),
-                                  char *val, size_t len)
-  { memcpy(val, global_val.str, global_val.length + 1); return false; }
-
-  void cleanup()
-  {
-    if (global_val.str)
-    {
-      my_free(global_val.str);
-      global_val.str= NULL;
-      global_val.length= 0;
-    }
-
-  }
-};
-
 #define KEYCACHE_VAR(X) GLOBAL_VAR(dflt_key_cache_var.X)
 #define keycache_var_ptr(KC, OFF) (((uchar*)(KC))+(OFF))
 #define keycache_var(KC, OFF) (*(ulonglong*)keycache_var_ptr(KC, OFF))


More information about the commits mailing list