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)
This commit is contained in:
Magne Mahre 2009-10-12 15:35:30 +02:00
parent 0e852eba7c
commit 10390cec03
7 changed files with 38 additions and 5 deletions

View File

@ -0,0 +1,3 @@
SELECT INSTR(@@general_log_file, 'MYSQLTEST_VARDIR/run');;
INSTR(@@general_log_file, 'MYSQLTEST_VARDIR/run')
0

View File

@ -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

View File

@ -0,0 +1 @@
--pid-file=$MYSQLTEST_VARDIR/run/mysqld.1.pid --log=

View File

@ -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');

View File

@ -110,9 +110,16 @@ sql_print_message_func sql_print_message_handlers[3] =
};
/**
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));
}

View File

@ -1934,6 +1934,7 @@ extern MYSQL_PLUGIN_IMPORT uint reg_ext_length;
#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;

View File

@ -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 char *conf_file_name, int argc,
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
/*