diff options
-rw-r--r-- | mysql-test/r/log_state_bug33693.result | 3 | ||||
-rw-r--r-- | mysql-test/t/log_state.test | 3 | ||||
-rw-r--r-- | mysql-test/t/log_state_bug33693-master.opt | 1 | ||||
-rw-r--r-- | mysql-test/t/log_state_bug33693.test | 18 | ||||
-rw-r--r-- | sql/log.cc | 9 | ||||
-rw-r--r-- | sql/mysql_priv.h | 1 | ||||
-rw-r--r-- | sql/mysqld.cc | 8 |
7 files changed, 38 insertions, 5 deletions
diff --git a/mysql-test/r/log_state_bug33693.result b/mysql-test/r/log_state_bug33693.result new file mode 100644 index 00000000000..abf20fc7aa7 --- /dev/null +++ b/mysql-test/r/log_state_bug33693.result @@ -0,0 +1,3 @@ +SELECT INSTR(@@general_log_file, 'MYSQLTEST_VARDIR/run');; +INSTR(@@general_log_file, 'MYSQLTEST_VARDIR/run') +0 diff --git a/mysql-test/t/log_state.test b/mysql-test/t/log_state.test index e40dd1e3491..a867b5b0885 100644 --- a/mysql-test/t/log_state.test +++ b/mysql-test/t/log_state.test @@ -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 diff --git a/mysql-test/t/log_state_bug33693-master.opt b/mysql-test/t/log_state_bug33693-master.opt new file mode 100644 index 00000000000..9f4ae1a0c8f --- /dev/null +++ b/mysql-test/t/log_state_bug33693-master.opt @@ -0,0 +1 @@ +--pid-file=$MYSQLTEST_VARDIR/run/mysqld.1.pid --log= diff --git a/mysql-test/t/log_state_bug33693.test b/mysql-test/t/log_state_bug33693.test new file mode 100644 index 00000000000..d67b28fc3e9 --- /dev/null +++ b/mysql-test/t/log_state_bug33693.test @@ -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'); diff --git a/sql/log.cc b/sql/log.cc index ed208a84ffc..988747c3b0b 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -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)); } diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 64616e08228..8af0dc524b3 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -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; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 78faaccf881..580842c944e 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -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 /* |