Skip to content

Commit 675dffb

Browse files
committed
Extend --log_basename allow it to include a path.
--log-basename=/var/log/mariadb
1 parent f33367f commit 675dffb

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

mysql-test/main/mysqld--help.result

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,10 @@ The following specify which files/extra groups are read (specified before remain
466466
the only option you need for specifying log files. Sets
467467
names for --log-bin, --log-bin-index, --relay-log,
468468
--relay-log-index, --general-log-file,
469-
--log-slow-query-file, --log-error-file, and --pid-file
469+
--log-slow-query-file, --log-error-file, and --pid-file.
470+
If log-basename includes a path, the path will apply for
471+
all above variables except pid-file that will use it
472+
without the path
470473
--log-bin[=name] Log update queries in binary format. Optional argument
471474
should be name for binary log. If not given
472475
'datadir'/'log-basename'-bin or 'datadir'/mysql-bin will

sql/mysqld.cc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6666,7 +6666,9 @@ struct my_option my_long_options[]=
66666666
"names at once (in 'datadir') and is normally the only option you need "
66676667
"for specifying log files. Sets names for --log-bin, --log-bin-index, "
66686668
"--relay-log, --relay-log-index, --general-log-file, "
6669-
"--log-slow-query-file, --log-error-file, and --pid-file",
6669+
"--log-slow-query-file, --log-error-file, and --pid-file. "
6670+
"If log-basename includes a path, the path will apply for all above "
6671+
"variables except pid-file that will use it without the path",
66706672
&opt_log_basename, &opt_log_basename, 0, GET_STR, REQUIRED_ARG,
66716673
0, 0, 0, 0, 0, 0},
66726674
{"log-bin", OPT_BIN_LOG,
@@ -8161,10 +8163,12 @@ mysqld_get_one_option(const struct my_option *opt, const char *argument,
81618163
case (int) OPT_LOG_BASENAME:
81628164
{
81638165
if (opt_log_basename[0] == 0 || strchr(opt_log_basename, FN_EXTCHAR) ||
8164-
strchr(opt_log_basename,FN_LIBCHAR) ||
8166+
!my_basename(opt_log_basename)[0] ||
81658167
!is_filename_allowed(opt_log_basename, strlen(opt_log_basename), FALSE))
81668168
{
8167-
sql_print_error("Wrong argument for --log-basename. It can't be empty or contain '.' or '" FN_DIRSEP "'. It must be valid filename.");
8169+
sql_print_error("Wrong argument for --log-basename. It can't be empty, "
8170+
"contain '.' or be a directory name'. "
8171+
"It must be valid filename.");
81688172
return 1;
81698173
}
81708174
if (log_error_file_ptr != disabled_my_option)
@@ -8198,7 +8202,8 @@ mysqld_get_one_option(const struct my_option *opt, const char *argument,
81988202
{
81998203
SYSVAR_AUTOSIZE(pidfile_name_ptr, pidfile_name);
82008204
/* PID file */
8201-
strmake(pidfile_name, argument, sizeof(pidfile_name)-5);
8205+
strmake(pidfile_name, my_basename(opt_log_basename),
8206+
sizeof(pidfile_name)-5);
82028207
strmov(fn_ext(pidfile_name),".pid");
82038208
}
82048209
break;

0 commit comments

Comments
 (0)