diff --git a/mysql-test/suite/sys_vars/r/wsrep_node_name_basic.result b/mysql-test/suite/sys_vars/r/wsrep_node_name_basic.result index 9657e6bf428..763d0612a1b 100644 --- a/mysql-test/suite/sys_vars/r/wsrep_node_name_basic.result +++ b/mysql-test/suite/sys_vars/r/wsrep_node_name_basic.result @@ -4,10 +4,10 @@ call mtr.add_suppression("WSREP: Failed to get provider options"); # save the initial value SET @wsrep_node_name_global_saved = @@global.wsrep_node_name; -# default -SELECT @@global.wsrep_node_name; -@@global.wsrep_node_name - +# default (expect 1) +SELECT COUNT(@@global.wsrep_node_name); +COUNT(@@global.wsrep_node_name) +1 # scope SELECT @@session.wsrep_node_name; @@ -27,21 +27,34 @@ SELECT @@global.wsrep_node_name; @@global.wsrep_node_name hyphenated-node-name SET @@global.wsrep_node_name=default; -SELECT @@global.wsrep_node_name; -@@global.wsrep_node_name - +# default (expect 1) +SELECT COUNT(@@global.wsrep_node_name); +COUNT(@@global.wsrep_node_name) +1 # invalid values SET @@global.wsrep_node_name=NULL; ERROR 42000: Variable 'wsrep_node_name' can't be set to the value of 'NULL' -SELECT @@global.wsrep_node_name; -@@global.wsrep_node_name - +SELECT COUNT(@@global.wsrep_node_name); +COUNT(@@global.wsrep_node_name) +1 SET @@global.wsrep_node_name=1; ERROR 42000: Incorrect argument type to variable 'wsrep_node_name' -SELECT @@global.wsrep_node_name; -@@global.wsrep_node_name - +SELECT COUNT(@@global.wsrep_node_name); +COUNT(@@global.wsrep_node_name) +1 +# +# MDEV-6699 : wsrep_node_name not automaticly set to hostname +# +SET @@global.wsrep_node_name=default; +SELECT @@GLOBAL.wsrep_node_name = VARIABLE_VALUE FROM +INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='hostname'; +@@GLOBAL.wsrep_node_name = VARIABLE_VALUE +1 +SELECT @@GLOBAL.wsrep_node_name = VARIABLE_VALUE FROM +INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='wsrep_node_name'; +@@GLOBAL.wsrep_node_name = VARIABLE_VALUE +1 # restore the initial value SET @@global.wsrep_node_name = @wsrep_node_name_global_saved; diff --git a/mysql-test/suite/sys_vars/t/wsrep_node_name_basic.test b/mysql-test/suite/sys_vars/t/wsrep_node_name_basic.test index 1f3ccc0de2c..7bc9bec8b95 100644 --- a/mysql-test/suite/sys_vars/t/wsrep_node_name_basic.test +++ b/mysql-test/suite/sys_vars/t/wsrep_node_name_basic.test @@ -9,8 +9,8 @@ call mtr.add_suppression("WSREP: Failed to get provider options"); --echo # save the initial value SET @wsrep_node_name_global_saved = @@global.wsrep_node_name; ---echo # default -SELECT @@global.wsrep_node_name; +--echo # default (expect 1) +SELECT COUNT(@@global.wsrep_node_name); --echo --echo # scope @@ -26,16 +26,26 @@ SELECT @@global.wsrep_node_name; SET @@global.wsrep_node_name='hyphenated-node-name'; SELECT @@global.wsrep_node_name; SET @@global.wsrep_node_name=default; -SELECT @@global.wsrep_node_name; +--echo # default (expect 1) +SELECT COUNT(@@global.wsrep_node_name); --echo --echo # invalid values --error ER_WRONG_VALUE_FOR_VAR SET @@global.wsrep_node_name=NULL; -SELECT @@global.wsrep_node_name; +SELECT COUNT(@@global.wsrep_node_name); --error ER_WRONG_TYPE_FOR_VAR SET @@global.wsrep_node_name=1; -SELECT @@global.wsrep_node_name; +SELECT COUNT(@@global.wsrep_node_name); + +--echo # +--echo # MDEV-6699 : wsrep_node_name not automaticly set to hostname +--echo # +SET @@global.wsrep_node_name=default; +SELECT @@GLOBAL.wsrep_node_name = VARIABLE_VALUE FROM +INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='hostname'; +SELECT @@GLOBAL.wsrep_node_name = VARIABLE_VALUE FROM +INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='wsrep_node_name'; --echo --echo # restore the initial value diff --git a/sql/mysqld.cc b/sql/mysqld.cc index ee40df945ed..6c8f79bf37a 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4190,14 +4190,6 @@ static int init_common_variables() else opt_log_basename= glob_hostname; -#ifdef WITH_WSREP - if (wsrep_node_name == 0 || wsrep_node_name[0] == 0) - { - my_free((void *)wsrep_node_name); - wsrep_node_name= my_strdup(glob_hostname, MYF(MY_WME)); - } -#endif /* WITH_WSREP */ - strmake(pidfile_name, opt_log_basename, sizeof(pidfile_name)-5); strmov(fn_ext(pidfile_name),".pid"); // Add proper extension SYSVAR_AUTOSIZE(pidfile_name_ptr, pidfile_name); diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 3b043d92d75..29e167d4664 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -4730,7 +4730,7 @@ static Sys_var_charptr Sys_wsrep_cluster_address ( static Sys_var_charptr Sys_wsrep_node_name ( "wsrep_node_name", "Node name", PREALLOCATED GLOBAL_VAR(wsrep_node_name), CMD_LINE(REQUIRED_ARG), - IN_SYSTEM_CHARSET, DEFAULT(""), NO_MUTEX_GUARD, NOT_IN_BINLOG, + IN_SYSTEM_CHARSET, DEFAULT(glob_hostname), NO_MUTEX_GUARD, NOT_IN_BINLOG, wsrep_node_name_check, wsrep_node_name_update); static Sys_var_charptr Sys_wsrep_node_address (