Commit 629b9cf8 authored by unknown's avatar unknown

Bug#20166 mysql-test-run.pl does not test system privilege tables creation

 - Part 2, add @@hostname system variable


mysql-test/r/variables.result:
  Add testcase for @@hostname
mysql-test/t/variables.test:
  Add testcase for @@hostname
sql/log.cc:
  Use pidfile_name as base when generating the default log name
sql/mysqld.cc:
  Init "glob_hostname" to that of hostname, fallback to "localhost"
  if 'gethostname' should fail.
  Init "pidfile_name" to hostname.pid and fallback to "mysql.pid" if
  'gethostname' should fail
sql/set_var.cc:
  Add new system variable "hostname"
parent aafe189a
......@@ -752,6 +752,14 @@ select @@&;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '&' at line 1
select @@@;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@' at line 1
select @@hostname;
@@hostname
#
set @@hostname= "anothername";
ERROR HY000: Variable 'hostname' is a read only variable
show variables like 'hostname';
Variable_name Value
hostname #
End of 5.0 tests
set global binlog_cache_size =@my_binlog_cache_size;
set global connect_timeout =@my_connect_timeout;
......
......@@ -639,6 +639,17 @@ select @@&;
--error ER_PARSE_ERROR
select @@@;
#
# Bug#20166 mysql-test-run.pl does not test system privilege tables creation
#
# Don't actually output, since it depends on the system
--replace_column 1 #
select @@hostname;
--error 1238
set @@hostname= "anothername";
--replace_column 2 #
show variables like 'hostname';
--echo End of 5.0 tests
# This is at the very after the versioned tests, since it involves doing
......
......@@ -452,7 +452,7 @@ const char *MYSQL_LOG::generate_name(const char *log_name,
TODO: The following should be using fn_format(); We just need to
first change fn_format() to cut the file name if it's too long.
*/
strmake(buff,glob_hostname,FN_REFLEN-5);
strmake(buff, pidfile_name,FN_REFLEN-5);
strmov(fn_ext(buff),suffix);
return (const char *)buff;
}
......
......@@ -2636,9 +2636,15 @@ static int init_common_variables(const char *conf_file_name, int argc,
mysql_slow_log.init_pthread_objects();
mysql_bin_log.init_pthread_objects();
if (gethostname(glob_hostname,sizeof(glob_hostname)-4) < 0)
strmov(glob_hostname,"mysql");
strmake(pidfile_name, glob_hostname, sizeof(pidfile_name)-5);
if (gethostname(glob_hostname,sizeof(glob_hostname)) < 0)
{
strmake(glob_hostname, STRING_WITH_LEN("localhost"));
sql_print_warning("gethostname failed, using '%s' as hostname",
glob_hostname);
strmake(pidfile_name, STRING_WITH_LEN("mysql"));
}
else
strmake(pidfile_name, glob_hostname, sizeof(pidfile_name)-5);
strmov(fn_ext(pidfile_name),".pid"); // Add proper extension
load_defaults(conf_file_name, groups, &argc, &argv);
......@@ -3087,7 +3093,7 @@ server.");
if (opt_error_log)
{
if (!log_error_file_ptr[0])
fn_format(log_error_file, glob_hostname, mysql_data_home, ".err",
fn_format(log_error_file, pidfile_name, mysql_data_home, ".err",
MY_REPLACE_EXT); /* replace '.<domain>' by '.err', bug#4997 */
else
fn_format(log_error_file, log_error_file_ptr, mysql_data_home, ".err",
......
......@@ -590,6 +590,10 @@ sys_var_readonly sys_have_innodb("have_innodb", OPT_GLOBAL,
/* Global read-only variable describing server license */
sys_var_const_str sys_license("license", STRINGIFY_ARG(LICENSE));
/* Global read-only variable containing hostname */
sys_var_const_str sys_hostname("hostname", glob_hostname);
/*
List of all variables for initialisation and storage in hash
......@@ -642,6 +646,7 @@ sys_var *sys_variables[]=
&sys_foreign_key_checks,
&sys_group_concat_max_len,
&sys_have_innodb,
&sys_hostname,
&sys_identity,
&sys_init_connect,
&sys_init_slave,
......@@ -874,6 +879,7 @@ struct show_var_st init_vars[]= {
{"have_raid", (char*) &have_raid, SHOW_HAVE},
{"have_rtree_keys", (char*) &have_rtree_keys, SHOW_HAVE},
{"have_symlink", (char*) &have_symlink, SHOW_HAVE},
{sys_hostname.name, (char*) &sys_hostname, SHOW_SYS},
{"init_connect", (char*) &sys_init_connect, SHOW_SYS},
{"init_file", (char*) &opt_init_file, SHOW_CHAR_PTR},
{"init_slave", (char*) &sys_init_slave, SHOW_SYS},
......
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