Commit 6151bde4 authored by Yuchen Pei's avatar Yuchen Pei

cleanup: string sys_var types

Merge sys_var_charptr with sys_var_charptr_base, as well as merge
Sys_var_session_lexstring into Sys_var_lexstring. Also refactored
update methods of sys_var_charptr accordingly.

Because the class is more generic, session_update() calls
sys_var_charptr::session_update() which does not assume a buffer field
associated with THD, but instead call strdup/free, we get rid of
THD::default_master_connection_buff accordingly. This also makes THD
smaller by ~192 bytes, and there can be many thousands of concurrent
THDs.
parent d16817c4
#
# test cleanup of sys_var classes
#
set global init_connect=".................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................";
ERROR HY000: String '......................................................................' is too long for init_connect (should be no longer than 2000)
set global ft_boolean_syntax=".................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................";
ERROR HY000: String '......................................................................' is too long for ft_boolean_syntax (should be no longer than 2000)
#
# end of test mdev_15935
#
--echo #
--echo # test cleanup of sys_var classes
--echo #
--let $long_string=`select repeat('.', 2001)`
--error ER_WRONG_STRING_LENGTH
eval set global init_connect="$long_string";
--error ER_WRONG_STRING_LENGTH
eval set global ft_boolean_syntax="$long_string";
--echo #
--echo # end of test mdev_15935
--echo #
......@@ -1235,10 +1235,7 @@ void THD::init()
avoid temporary tables replication failure.
*/
variables.pseudo_thread_id= thread_id;
variables.default_master_connection.str= default_master_connection_buff;
::strmake(default_master_connection_buff,
global_system_variables.default_master_connection.str,
variables.default_master_connection.length);
mysql_mutex_unlock(&LOCK_global_system_variables);
user_time.val= start_time= start_time_sec_part= 0;
......
......@@ -3750,7 +3750,6 @@ class THD: public THD_count, /* this must be first */
This is used for taging error messages in the log files.
*/
LEX_CSTRING connection_name;
char default_master_connection_buff[MAX_CONNECTION_NAME+1];
uint8 password; /* 0, 1 or 2 */
uint8 failed_com_change_user;
bool slave_thread;
......
......@@ -3279,6 +3279,9 @@ void plugin_thdvar_init(THD *thd)
#ifndef EMBEDDED_LIBRARY
thd->session_tracker.sysvars.deinit(thd);
#endif
my_free((char*) thd->variables.default_master_connection.str);
thd->variables.default_master_connection.str= 0;
thd->variables.default_master_connection.length= 0;
thd->variables= global_system_variables;
......@@ -3301,6 +3304,11 @@ void plugin_thdvar_init(THD *thd)
intern_plugin_unlock(NULL, old_enforced_table_plugin);
mysql_mutex_unlock(&LOCK_plugin);
thd->variables.default_master_connection.str=
my_strndup(key_memory_Sys_var_charptr_value,
global_system_variables.default_master_connection.str,
global_system_variables.default_master_connection.length,
MYF(MY_WME | MY_THREAD_SPECIFIC));
#ifndef EMBEDDED_LIBRARY
thd->session_tracker.sysvars.init(thd);
#endif
......@@ -3372,6 +3380,9 @@ void plugin_thdvar_cleanup(THD *thd)
#ifndef EMBEDDED_LIBRARY
thd->session_tracker.sysvars.deinit(thd);
#endif
my_free((char*) thd->variables.default_master_connection.str);
thd->variables.default_master_connection.str= 0;
thd->variables.default_master_connection.length= 0;
mysql_mutex_lock(&LOCK_plugin);
......
......@@ -1346,12 +1346,11 @@ static bool check_master_connection(sys_var *self, THD *thd, set_var *var)
return false;
}
static Sys_var_session_lexstring Sys_default_master_connection(
static Sys_var_lexstring Sys_default_master_connection(
"default_master_connection",
"Master connection to use for all slave variables and slave commands",
SESSION_ONLY(default_master_connection),
NO_CMD_LINE,
DEFAULT(""), MAX_CONNECTION_NAME, ON_CHECK(check_master_connection));
SESSION_ONLY(default_master_connection), NO_CMD_LINE, DEFAULT(""),
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_master_connection));
#endif
static Sys_var_charptr_fscs Sys_init_file(
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment