#At file:///data/z/mysql-next-mr-runtime/ based on revid:jon.hauglid@stripped
2911 Magne Mahre 2009-10-12
Bug #33693 general log name and location depend on PID file,
not on predefined values
The default name of the PID file was constructed, as documented,
based on the hostname. This name was subsequently used as the
base for the general log file name. If the name of the PID
file was overridden in the configuration, and no explicit name
was set for the general log file, the path location for the
PID file was used also for the general log file.
A new variable, 'default_logfile_name', has been introduced. This name
is constructed based on the hostname, and is then used to
construct both the PID file and the general log file.
The general log file will now, unless explicitly set, be
located in the server data directory (as documentated in
the server docs)
@ mysql-test/t/log_state.test
run/mysqld.log was created as a consequence of this bug.
After the fix it is no longer created, and will thus not
be deleted.
added:
mysql-test/r/log_state_bug33693.result
mysql-test/t/log_state_bug33693-master.opt
mysql-test/t/log_state_bug33693.test
modified:
mysql-test/t/log_state.test
sql/log.cc
sql/mysql_priv.h
sql/mysqld.cc
=== added file 'mysql-test/r/log_state_bug33693.result'
--- a/mysql-test/r/log_state_bug33693.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/log_state_bug33693.result 2009-10-12 13:35:30 +0000
@@ -0,0 +1,3 @@
+SELECT INSTR(@@general_log_file, 'MYSQLTEST_VARDIR/run');;
+INSTR(@@general_log_file, 'MYSQLTEST_VARDIR/run')
+0
=== modified file 'mysql-test/t/log_state.test'
--- a/mysql-test/t/log_state.test 2009-01-23 12:22:05 +0000
+++ b/mysql-test/t/log_state.test 2009-10-12 13:35:30 +0000
@@ -390,7 +390,6 @@ if(!$fixed_bug38124)
--enable_query_log
}
-# Remove the log files that was created in the "default location"
+# Remove the log file that was created in the "default location"
# i.e var/run
---remove_file $MYSQLTEST_VARDIR/run/mysqld.log
--remove_file $MYSQLTEST_VARDIR/tmp/log.master
=== added file 'mysql-test/t/log_state_bug33693-master.opt'
--- a/mysql-test/t/log_state_bug33693-master.opt 1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/log_state_bug33693-master.opt 2009-10-12 13:35:30 +0000
@@ -0,0 +1 @@
+--pid-file=$MYSQLTEST_VARDIR/run/mysqld.1.pid --log=
=== added file 'mysql-test/t/log_state_bug33693.test'
--- a/mysql-test/t/log_state_bug33693.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/log_state_bug33693.test 2009-10-12 13:35:30 +0000
@@ -0,0 +1,18 @@
+### t/log_state_bug33693.test
+#
+# Regression test for bug #33693
+# "general log name and location depend on PID
+# file, not on predefined values"
+#
+# The server is started with a hard-coded
+# PID file in the $MYSQLTEST_VARDIR/run
+# directory, and an unspecified general log
+# file name.
+#
+# The correct result should show the log file to
+# rest in the database directory. Unfixed, the
+# log file will be in the same directory as the
+# PID.
+
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--eval SELECT INSTR(@@general_log_file, '$MYSQLTEST_VARDIR/run');
=== modified file 'sql/log.cc'
--- a/sql/log.cc 2009-09-30 20:10:22 +0000
+++ b/sql/log.cc 2009-10-12 13:35:30 +0000
@@ -110,9 +110,16 @@ sql_print_message_func sql_print_message
};
+/**
+ Create the name of the default general log file
+
+ @param[IN] buff Location for building new string.
+ @param[IN] log_ext The extension for the file (e.g .log)
+ @returns Pointer to a new string containing the name
+*/
char *make_default_log_name(char *buff,const char* log_ext)
{
- strmake(buff, pidfile_name, FN_REFLEN-5);
+ strmake(buff, default_logfile_name, FN_REFLEN-5);
return fn_format(buff, buff, mysql_data_home, log_ext,
MYF(MY_UNPACK_FILENAME|MY_REPLACE_EXT));
}
=== modified file 'sql/mysql_priv.h'
--- a/sql/mysql_priv.h 2009-10-09 13:59:25 +0000
+++ b/sql/mysql_priv.h 2009-10-12 13:35:30 +0000
@@ -1934,6 +1934,7 @@ extern MYSQL_PLUGIN_IMPORT uint reg_ext_
#ifdef MYSQL_SERVER
extern char glob_hostname[FN_REFLEN], mysql_home[FN_REFLEN];
extern char pidfile_name[FN_REFLEN], system_time_zone[30], *opt_init_file;
+extern char default_logfile_name[FN_REFLEN];
extern char log_error_file[FN_REFLEN], *opt_tc_log_file;
extern ulonglong log_10_int[20];
extern ulonglong keybuff_size;
=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc 2009-10-09 13:59:25 +0000
+++ b/sql/mysqld.cc 2009-10-12 13:35:30 +0000
@@ -572,6 +572,7 @@ const char *log_output_str= "FILE";
time_t server_start_time, flush_status_time;
char mysql_home[FN_REFLEN], pidfile_name[FN_REFLEN], system_time_zone[30];
+char default_logfile_name[FN_REFLEN];
char *default_tz_name;
char log_error_file[FN_REFLEN], glob_hostname[FN_REFLEN];
char mysql_real_data_home[FN_REFLEN],
@@ -3168,10 +3169,13 @@ static int init_common_variables(const c
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"));
+ strmake(default_logfile_name, STRING_WITH_LEN("mysql"));
}
else
- strmake(pidfile_name, glob_hostname, sizeof(pidfile_name)-5);
+ strmake(default_logfile_name, glob_hostname,
+ sizeof(default_logfile_name)-5);
+
+ strmake(pidfile_name, default_logfile_name, sizeof(pidfile_name)-5);
strmov(fn_ext(pidfile_name),".pid"); // Add proper extension
/*
Attachment: [text/bzr-bundle] bzr/magne.mahre@sun.com-20091012133530-1rrq0nuyv6uverck.bundle
| Thread |
|---|
| • bzr commit into mysql-5.5.0-next-mr-runtime branch (magne.mahre:2911)Bug#33693 | Magne Mahre | 12 Oct |