Commit 7de98f2f authored by Michael Widenius's avatar Michael Widenius

Added --log-basename to mysqld to allow one to set the prefix for all logs with one command

Changed test suite to use --log-basename (to get the code tested)
Added --sync-sys=1 to test suite to speed it up.
Better error messages if something goes wrong with mysql_install_db


mysql-test/Makefile.am:
  Removed not existing directory
mysql-test/lib/My/ConfigFactory.pm:
  Use log-basename
  We had to also set 'log_error' as some test was explicitely using the old name
  Added 'sync-sys=1' to speed up test suite
mysql-test/r/variables-notembedded.result:
  Updated test results (variable relay_log is now set)
mysql-test/suite/binlog/t/binlog_delete_and_flush_index-master.opt:
  Force specific names for some log files.
mysql-test/suite/binlog/t/binlog_index-master.opt:
  Force specific names for some log files.
mysql-test/suite/binlog/t/binlog_stm_unsafe_warning-master.opt:
  Force specific names for some log files.
mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test:
  Better error message if something goes wrong
mysql-test/suite/rpl/r/rpl_flushlog_loop.result:
  Updated results
mysql-test/suite/rpl/rpl_1slave_base.cnf:
  Use --log-basename
scripts/mysql_install_db.sh:
  More information to --help
  Write url to knowledge base if something goes wrong
  Fail at once if we can't create a database directory (no reason to continue and write a screenful of not related text)
scripts/mysqld_safe.sh:
  Also allow one to use --data for --datadir (common shortening)
  Added support for --log-basename
  Fail at once if we can't create a log directory
  Fixed bug where we used a pid file name without '.pid' extension
sql/log.cc:
  Create a log file name trough my_once_alloc()  (To get it automaticly freed at exit)
sql/mysql_priv.h:
  Added new prototype
sql/mysqld.cc:
  Added support for --log-basename
  Better help for a lot of log-filename related variables.
sql/rpl_rli.cc:
  Write information that one can use --log-basename
sql/set_var.cc:
  Add log_basename as a readonly variable
parent 0fae0335
......@@ -86,7 +86,7 @@ TEST_DIRS = t r include std_data std_data/parts collections \
suite/federated \
suite/pbxt/t suite/pbxt/r suite/pbxt \
suite/vcol suite/vcol/t suite/vcol/r suite/vcol/inc \
suite/oqgraph suite/oqgraph/t suite/oqgraph/r suite/oqgraph/include \
suite/oqgraph suite/oqgraph/t suite/oqgraph/r \
suite/percona suite/sphinx \
suite/funcs_1 suite/funcs_1/bitdata \
suite/funcs_1/include suite/funcs_1/lib suite/funcs_1/r \
......
......@@ -200,6 +200,7 @@ my @mysqld_rules=
(
{ 'basedir' => sub { return shift->{ARGS}->{basedir}; } },
{ 'tmpdir' => \&fix_tmpdir },
{ 'log-basename' => sub { return "mysqld" } },
{ 'character-sets-dir' => \&fix_charset_dir },
{ 'language' => \&fix_language },
{ 'datadir' => \&fix_datadir },
......@@ -208,6 +209,7 @@ my @mysqld_rules=
{ 'port' => \&fix_port },
{ '#extra-port' => \&fix_port },
{ 'socket' => \&fix_socket },
{ 'log-error' => \&fix_log_error },
{ '#log-error' => \&fix_log_error },
{ 'general-log' => sub { return 1; } },
{ 'general-log-file' => \&fix_log },
......@@ -216,6 +218,7 @@ my @mysqld_rules=
{ '#user' => sub { return shift->{ARGS}->{user} || ""; } },
{ '#password' => sub { return shift->{ARGS}->{password} || ""; } },
{ 'server-id' => \&fix_server_id, },
{ 'sync-sys' => sub { return 1; } },
# By default, prevent the started mysqld to access files outside of vardir
{ 'secure-file-priv' => sub { return shift->{ARGS}->{vardir}; } },
{ 'ssl-ca' => \&fix_ssl_ca },
......
......@@ -33,12 +33,12 @@ ERROR HY000: Variable 'log_slave_updates' is a read only variable
#
SHOW VARIABLES like 'relay_log';
Variable_name Value
relay_log
relay_log mysqld-relay-bin
SELECT @@session.relay_log;
ERROR HY000: Variable 'relay_log' is a GLOBAL variable
SELECT @@global.relay_log;
@@global.relay_log
NULL
mysqld-relay-bin
SET @@session.relay_log= 'x';
ERROR HY000: Variable 'relay_log' is a read only variable
SET @@global.relay_log= 'x';
......@@ -46,12 +46,12 @@ ERROR HY000: Variable 'relay_log' is a read only variable
#
SHOW VARIABLES like 'relay_log_index';
Variable_name Value
relay_log_index
relay_log_index mysqld-relay-bin.index
SELECT @@session.relay_log_index;
ERROR HY000: Variable 'relay_log_index' is a GLOBAL variable
SELECT @@global.relay_log_index;
@@global.relay_log_index
NULL
mysqld-relay-bin.index
SET @@session.relay_log_index= 'x';
ERROR HY000: Variable 'relay_log_index' is a read only variable
SET @@global.relay_log_index= 'x';
......
--log-bin=master-bin --log-bin-index=master-bin
--force-restart --skip-stack-trace --test-expect-abort --log-warnings=0
--force-restart --skip-stack-trace --test-expect-abort --log-warnings=0 --log-bin=master-bin --log-bin-index=master-bin
--binlog-ignore-db=b42851 --log-error
--binlog-ignore-db=b42851 --log-error --log-bin=master-bin --log-bin-index=master-bin
......@@ -101,6 +101,7 @@ if(!`select LENGTH('$log_error_')`)
# does not know the location of its .err log, use default location
let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.1.err;
}
# Assign env variable LOG_ERROR
let LOG_ERROR=$log_error_;
......@@ -109,8 +110,9 @@ let LOG_ERROR=$log_error_;
perl;
use strict;
use Cwd;
my $log_error= $ENV{'LOG_ERROR'} or die "LOG_ERROR not set";
open(FILE, "$log_error") or die("Unable to open $log_error: $!\n");
open(FILE, "$log_error") or die("Unable to open '$log_error' from directory " . cwd() . "\n");
my $count = () = grep(/Bug#46265/g,<FILE>);
print "Occurrences: $count\n";
close(FILE);
......
......@@ -2,7 +2,7 @@ include/rpl_init.inc [topology=1->2->1]
show variables like 'relay_log%';
Variable_name Value
relay_log master-relay-bin
relay_log_index
relay_log_index master-relay-bin.index
relay_log_info_file relay-log.info
relay_log_purge ON
relay_log_space_limit 0
......
......@@ -6,8 +6,9 @@
# Run the master.sh script before starting this process
#!run-master-sh
log-bin= master-bin
relay-log= master-relay-bin
log-basename= master
# log-bin= master-bin
# relay-log= master-relay-bin
[mysqld.2]
# Run the slave.sh script before starting this process
......@@ -17,7 +18,8 @@ relay-log= master-relay-bin
# starting the mysqld
#!use-slave-opt
relay-log= slave-relay-bin
log-basename= slave
# relay-log= slave-relay-bin
init-rpl-role= slave
log-slave-updates
......
......@@ -50,6 +50,8 @@ Usage: $0 [OPTIONS]
use hostnames will use IP addresses.
--ldata=path The path to the MariaDB data directory. Same as
--datadir.
--no-defaults Don't read any configuration files (my.cnf).
--defaults-file=path Read only this configuration file.
--rpm For internal use. This option is used by RPM files
during the MariaDB installation process.
--skip-name-resolve Use IP addresses rather than hostnames when creating
......@@ -79,6 +81,13 @@ s_echo()
fi
}
link_to_help()
{
echo
echo "The latest information about mysql_install_db is available at"
echo "http://kb.askmonty.org/v/installing-system-tables-mysql_install_db."
}
parse_arg()
{
echo "$1" | sed -e 's/^[^=]*=//'
......@@ -194,7 +203,7 @@ cannot_find_file()
echo "If you are using a binary release, you must either be at the top"
echo "level of the extracted archive, or pass the --basedir option"
echo "pointing to that location."
echo
link_to_help
}
# Ok, let's go. We first need to parse arguments which are required by
......@@ -213,6 +222,7 @@ parse_arguments PICK-ARGS-FROM-ARGV "$@"
if test -n "$srcdir" && test -n "$basedir"
then
echo "ERROR: Specify either --basedir or --srcdir, not both."
link_to_help
exit 1
fi
if test -n "$srcdir"
......@@ -335,6 +345,7 @@ then
echo "hostname."
echo "If you want to solve this at a later stage, restart this script"
echo "with the --force option"
link_to_help
exit 1
fi
echo "WARNING: The host '$hostname' could not be looked up with resolveip."
......@@ -356,7 +367,12 @@ for dir in $ldata $ldata/mysql $ldata/test
do
if test ! -d $dir
then
mkdir -p $dir
if ! `mkdir -p $dir`
then
echo "Fatal error Can't create database directory '$dir'"
link_to_help
exit 1
fi
chmod 700 $dir
fi
if test -w / -a ! -z "$user"
......@@ -389,7 +405,7 @@ mysqld_install_cmd_line="$mysqld_bootstrap $defaults $mysqld_opt --bootstrap \
--net_buffer_length=16K"
# Create the system and help tables by passing them to "mysqld --bootstrap"
s_echo "Installing MariaDB/MySQL system tables..."
s_echo "Installing MariaDB/MySQL system tables in '$ldata' ..."
if { echo "use mysql;"; cat $create_system_tables $fill_system_tables; } | eval "$filter_cmd_line" | $mysqld_install_cmd_line > /dev/null
then
s_echo "OK"
......@@ -410,9 +426,7 @@ else
echo
echo "Try 'mysqld --help' if you have problems with paths. Using"
echo "--general-log gives you a log in $ldata that may be helpful."
echo
echo "The latest information about mysql_install_db is available at"
echo "http://kb.askmonty.org/v/installing-system-tables-mysql_install_db."
link_to_help
echo "MariaDB is hosted on launchpad; You can find the latest source and"
echo "email lists at http://launchpad.net/maria"
echo
......@@ -454,13 +468,13 @@ then
echo "databases and anonymous user created by default. This is"
echo "strongly recommended for production servers."
echo
echo "See the MySQL manual for more instructions."
echo "See the MariaDB knowledge or the MySQL manual for more instructions."
if test "$in_rpm" -eq 0
then
echo
echo "You can start the MariaDB daemon with:"
echo "cd $basedir ; $bindir/mysqld_safe &"
echo "cd $basedir ; $bindir/mysqld_safe --datadir=$ldata"
echo
echo "You can test the MariaDB daemon with mysql-test-run.pl"
echo "cd $basedir/mysql-test ; perl mysql-test-run.pl"
......
......@@ -159,9 +159,13 @@ parse_arguments() {
case "$arg" in
# these get passed explicitly to mysqld
--basedir=*) MY_BASEDIR_VERSION="$val" ;;
--datadir=*) DATADIR="$val" ;;
--datadir=*|--data=*) DATADIR="$val" ;;
--pid-file=*) pid_file="$val" ;;
--user=*) user="$val"; SET_USER=1 ;;
--log-basename=*|--hostname=*|--loose-log-basename=*)
pid_file="$val.pid";
err_log="$val.err";
;;
# these might have been set in a [mysqld_safe] section of my.cnf
# they are added to mysqld command line to override settings from my.cnf
......@@ -411,7 +415,11 @@ safe_mysql_unix_port=${mysql_unix_port:-${MYSQL_UNIX_PORT:-@MYSQL_UNIX_ADDR@}}
mysql_unix_port_dir=`dirname $safe_mysql_unix_port`
if [ ! -d $mysql_unix_port_dir ]
then
mkdir $mysql_unix_port_dir
if ! `mkdir -p $mysql_unix_port_dir`
then
echo "Fatal error Can't create database directory '$mysql_unix_port'"
exit 1
fi
chown $user $mysql_unix_port_dir
chmod 755 $mysql_unix_port_dir
fi
......@@ -434,14 +442,14 @@ fi
if test -z "$pid_file"
then
pid_file="$DATADIR/`@HOSTNAME@`.pid"
else
case "$pid_file" in
/* ) ;;
* ) pid_file="$DATADIR/$pid_file" ;;
esac
pid_file="`@HOSTNAME@`.pid"
fi
# MariaDB wants pid file without datadir
append_arg_to_args "--pid-file=$pid_file"
case "$pid_file" in
/* ) ;;
* ) pid_file="$DATADIR/$pid_file" ;;
esac
if test -n "$mysql_unix_port"
then
......
......@@ -112,6 +112,27 @@ char *make_default_log_name(char *buff,const char* log_ext)
MYF(MY_UNPACK_FILENAME|MY_REPLACE_EXT));
}
/*
Create a filename from a base with a given suffix.
The name is allocated trough my_once_alloc(), so one should only
use this for startup options that can all be freed at once.
*/
char *make_once_alloced_filename(const char *basename, const char *ext)
{
char buff[FN_REFLEN+10], *end, *res;
size_t length;
strmake(buff, basename, sizeof(buff)-10);
end= strmov(fn_ext(buff), ext);
length= (size_t) (end - buff) + 1;
if ((res= (char*) my_once_alloc(length, MYF(MY_WME))))
memcpy(res, buff, length);
return res;
}
/*
Helper class to hold a mutex for the duration of the
block.
......
......@@ -1625,6 +1625,7 @@ void remove_db_from_cache(const char *db);
void flush_tables();
bool is_equal(const LEX_STRING *a, const LEX_STRING *b);
char *make_default_log_name(char *buff,const char* log_ext);
char *make_once_alloced_filename(const char *basename, const char *ext);
#ifdef WITH_PARTITION_STORAGE_ENGINE
uint fast_alter_partition_table(THD *thd, TABLE *table,
......@@ -1966,7 +1967,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 log_error_file[FN_REFLEN], *opt_tc_log_file;
extern char log_error_file[FN_REFLEN], *opt_tc_log_file, *opt_log_basename;
extern ulonglong log_10_int[20];
extern ulonglong keybuff_size;
extern ulonglong thd_startup_options;
......
/* Copyright (C) 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
2010 Oracle and/or its affiliates
2009-2010 Monty Program Ab
2009-2011 Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -626,7 +626,7 @@ time_t server_start_time, flush_status_time;
char mysql_home[FN_REFLEN], pidfile_name[FN_REFLEN], system_time_zone[30];
char *default_tz_name;
char log_error_file[FN_REFLEN], glob_hostname[FN_REFLEN];
char log_error_file[FN_REFLEN], glob_hostname[FN_REFLEN], *opt_log_basename;
char mysql_real_data_home[FN_REFLEN],
language[FN_REFLEN], reg_ext[FN_EXTLEN], mysql_charsets_dir[FN_REFLEN],
*opt_init_file, *opt_tc_log_file,
......@@ -1407,8 +1407,6 @@ void clean_up(bool print_message)
#ifdef HAVE_REPLICATION
my_free(slave_load_tmpdir,MYF(MY_ALLOW_ZERO_PTR));
#endif
x_free(opt_bin_logname);
x_free(opt_relay_logname);
x_free(opt_secure_file_priv);
bitmap_free(&temp_pool);
free_max_user_conn();
......@@ -3447,15 +3445,21 @@ static int init_common_variables(const char *conf_file_name, int argc,
*/
mysql_bin_log.init_pthread_objects();
{
/*
Get hostname of computer (used by 'show variables') and as default
basename for the pid file if --log-basename is not given.
*/
const char *basename= glob_hostname;
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"));
basename= "mysql";
}
strmake(pidfile_name, basename, sizeof(pidfile_name)-5);
}
else
strmake(pidfile_name, glob_hostname, sizeof(pidfile_name)-5);
strmov(fn_ext(pidfile_name),".pid"); // Add proper extension
/*
......@@ -4060,7 +4064,7 @@ version 5.0 and above. It is replaced by the binary log.");
if (opt_update_logname)
{
/* as opt_bin_log==0, no need to free opt_bin_logname */
if (!(opt_bin_logname= my_strdup(opt_update_logname, MYF(MY_WME))))
if (!(opt_bin_logname= my_once_strdup(opt_update_logname, MYF(MY_WME))))
{
sql_print_error("Out of memory");
return EXIT_OUT_OF_MEMORY;
......@@ -4160,8 +4164,7 @@ a file name for --log-bin-index option", opt_binlog_index_name);
}
if (ln == buf)
{
my_free(opt_bin_logname, MYF(MY_ALLOW_ZERO_PTR));
opt_bin_logname=my_strdup(buf, MYF(0));
opt_bin_logname= my_once_strdup(buf, MYF(MY_WME));
}
if (mysql_bin_log.open_index_file(opt_binlog_index_name, ln, TRUE))
{
......@@ -5993,7 +5996,7 @@ enum options_mysqld
OPT_PROFILING,
OPT_KEEP_FILES_ON_CREATE,
OPT_GENERAL_LOG,
OPT_SLOW_LOG,
OPT_SLOW_LOG, OPT_LOG_BASENAME,
OPT_THREAD_HANDLING,
OPT_INNODB_ROLLBACK_ON_TIMEOUT,
OPT_SECURE_FILE_PRIV,
......@@ -6260,8 +6263,8 @@ struct my_option my_long_options[] =
&opt_debugging, &opt_debugging,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"general_log", OPT_GENERAL_LOG,
"Enable/disable general log.", &opt_log,
&opt_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
"Enable/disable general log. Filename can be specified with --general-log-file or --log-basename. Is 'hostname.err' by default.",
&opt_log, &opt_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
#ifdef HAVE_LARGE_PAGES
{"large-pages", OPT_ENABLE_LARGE_PAGES, "Enable support for large pages. "
"Disable with --skip-large-pages.", &opt_large_pages, &opt_large_pages,
......@@ -6301,16 +6304,32 @@ each time the SQL thread starts.",
"--general_log/--general_log_file instead).", &opt_logname,
&opt_logname, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"general_log_file", OPT_GENERAL_LOG_FILE,
"Log connections and queries to given file.", &opt_logname,
&opt_logname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
"Log connections and queries to given file. Defaults to "
"'datadir'/'log-basename'.log or 'datadir'/'hostname'.log if not "
"specified.",
&opt_logname, &opt_logname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"log-basename", OPT_LOG_BASENAME,
"Basename for all log files and the .pid file. This sets all log file "
"names at once (in 'datadir') and is normally the only option you need "
"for specifying log files. This is especially recommend to be set if you "
"are using replication as it ensures that your log file names are not "
"depending on your host name. Sets names for --log-bin, --log-bin-index, "
"--relay-log, --relay-log-index, --general-log-file, "
"--log-slow-query-log-file, --log-error-file and --pid-file",
&opt_log_basename, &opt_log_basename, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
{"log-bin", OPT_BIN_LOG,
"Log update queries in binary format. Optional (but strongly recommended "
"to avoid replication problems if server's hostname changes) argument "
"should be the chosen location for the binary log files.",
&opt_bin_logname, &opt_bin_logname, 0, GET_STR_ALLOC,
"Log update queries in binary format. Optional argument should be name for "
"binary log. If not given "
"datadir/'log-basename'-bin or 'datadir'/mysql-bin will be used (the later if "
"--log-basename is not specified). We strongly recommend you to use either "
"--log-basename or specify a filename to ensure that replication doesn't "
"stop if the real hostname of the computer changes'.",
&opt_bin_logname, &opt_bin_logname, 0, GET_STR,
OPT_ARG, 0, 0, 0, 0, 0, 0},
{"log-bin-index", OPT_BIN_LOG_INDEX,
"File that holds the names for last binary log files.",
"File that holds the names for last binary log files. If not specified, "
"defaults to 'datadir/log-basename'-bin.index or 'datadir/mysql-bin.index'",
&opt_binlog_index_name, &opt_binlog_index_name, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#ifndef TO_BE_REMOVED_IN_5_1_OR_6_0
......@@ -6339,7 +6358,10 @@ each time the SQL thread starts.",
"break, so you can safely set this to 1."
,&trust_function_creators, &trust_function_creators, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"log-error", OPT_ERROR_LOG_FILE, "Error log file.",
{"log-error", OPT_ERROR_LOG_FILE,
"Log errors to file (instead of stdout). If file name is not specified "
"then 'datadir'/'log-basename'.err or the pid-file path with extension "
".err is used.",
&log_error_file_ptr, &log_error_file_ptr, 0, GET_STR,
OPT_ARG, 0, 0, 0, 0, 0, 0},
{"log-isam", OPT_ISAM_LOG, "Log all MyISAM changes to file.",
......@@ -6377,15 +6399,20 @@ each time the SQL thread starts.",
&opt_log_slow_slave_statements,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"log-slow-queries", OPT_SLOW_QUERY_LOG,
"Log slow queries to a table or log file. Defaults logging to table "
"mysql.slow_log or hostname-slow.log if --log-output=file is used. "
"Must be enabled to activate other slow log options. "
"(deprecated option, use --slow_query_log/--slow_query_log_file instead)",
"Enable logging of slow queries (longer than --log-slow-time) to log file "
"or table. Optional argument is file name for slow log. If not given, "
"'log-basename'-slow.log will be used. Use --log-output=TABLE if you want "
"to have the log in the table 'mysql.slow_log'",
&opt_slow_logname, &opt_slow_logname, 0, GET_STR, OPT_ARG,
0, 0, 0, 0, 0, 0},
{"slow_query_log_file", OPT_SLOW_QUERY_LOG_FILE,
"Log slow queries to given log file. Defaults logging to hostname-slow.log. "
"Must be enabled to activate other slow log options.",
"Specify name for slow query log. Defaults to 'log-basename'-slow.log if "
"not given",
&opt_slow_logname, &opt_slow_logname, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"log-slow-file", OPT_SLOW_QUERY_LOG_FILE,
"Specify name for slow query log. Defaults to 'log-basename'-slow.log if "
"not given",
&opt_slow_logname, &opt_slow_logname, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"log-tc", OPT_LOG_TC,
......@@ -6404,7 +6431,8 @@ each time the SQL thread starts.",
"log and this option just turns on --log-bin instead.",
&opt_update_logname, &opt_update_logname, 0, GET_STR,
OPT_ARG, 0, 0, 0, 0, 0, 0},
{"log-warnings", 'W', "Log some not critical warnings to the log file.",
{"log-warnings", 'W', "Log some not critical warnings to the general log "
"file.",
&global_system_variables.log_warnings,
&max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG, 1, 0, 0,
0, 0, 0},
......@@ -6427,7 +6455,8 @@ each time the SQL thread starts.",
0, 0, 0, 0},
{"master-info-file", OPT_MASTER_INFO_FILE,
"The location and name of the file that remembers the master and where "
"the I/O replication thread is in the master's binlogs.",
"the I/O replication thread is in the master's binlogs. Defaults to "
"master.info. Is not affected by --log-basename.",
&master_info_file, &master_info_file, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"master-password", OPT_MASTER_PASSWORD,
......@@ -6629,7 +6658,9 @@ each time the SQL thread starts.",
"per each user+host vs. per account).",
&opt_old_style_user_limits, &opt_old_style_user_limits,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"pid-file", OPT_PID_FILE, "Pid file used by safe_mysqld.",
{"pid-file", OPT_PID_FILE,
"Pid file used by safe_mysqld. If not set, defaults to "
"'datadir'/'log-basename'.pid or 'datadir'/'hostname'.pid'.",
&pidfile_name_ptr, &pidfile_name_ptr, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Port number to use for connection or 0 for default to, in "
......@@ -6651,17 +6682,19 @@ each time the SQL thread starts.",
0, GET_ULONG, REQUIRED_ARG, 15, 0, 100, 0, 0, 0},
#endif
{"relay-log", OPT_RELAY_LOG,
"The location and name to use for relay logs.",
"The location and name to use for relay logs. If not specified "
"'datadir'/'log-basename' will be used.",
&opt_relay_logname, &opt_relay_logname, 0,
GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"relay-log-index", OPT_RELAY_LOG_INDEX,
"The location and name to use for the file that keeps a list of the last \
relay logs.",
"The location and name to use for the file that keeps a list of the last "
"relay logs. If not specified 'datadir'/'log-basename' will be used.",
&opt_relaylog_index_name, &opt_relaylog_index_name, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"relay-log-info-file", OPT_RELAY_LOG_INFO_FILE,
"The location and name of the file that remembers where the SQL replication \
thread is in the relay logs.",
"The location and name of the file that remembers where the SQL "
"replication thread is in the relay logs. Defaults to relay-log.info. "
"Is not affected by '--log-basename'.",
&relay_log_info_file, &relay_log_info_file, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"replicate-do-db", OPT_REPLICATE_DO_DB,
......@@ -6841,7 +6874,8 @@ thread is in the relay logs.",
&slave_exec_mode_str, &slave_exec_mode_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"slow-query-log", OPT_SLOW_LOG,
"Enable/disable slow query log.", &opt_slow_log,
"Enable/disable slow query log. See also '--log-slow-queries'",
&opt_slow_log,
&opt_slow_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"socket", OPT_SOCKET, "Socket file to use for connection.",
&mysqld_unix_port, &mysqld_unix_port, 0, GET_STR,
......@@ -7099,19 +7133,16 @@ thread is in the relay logs.",
"Choose how verbose the messages to your slow log will be. Multiple flags "
"allowed in a comma-separated string. [query_plan, innodb]",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{"log-slow-file", OPT_SLOW_QUERY_LOG_FILE,
"Log slow queries to given log file. Defaults logging to hostname-slow.log",
&opt_slow_logname, &opt_slow_logname, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"long_query_time", OPT_LONG_QUERY_TIME,
"Log all queries that have taken more than long_query_time seconds to "
"execute. The argument will be treated as a decimal value with "
"microsecond precision.",
{"log-slow-time", OPT_LONG_QUERY_TIME,
"Log all queries that have taken more than log-slow-time seconds to "
"execute to file. The argument will be treated as a decimal value with "
"microsecond precission. Same as --log-query-time.",
&long_query_time, &long_query_time, 0, GET_DOUBLE,
REQUIRED_ARG, 10, 0, LONG_TIMEOUT, 0, 0, 0},
{"log-slow-time", OPT_LONG_QUERY_TIME,
"Log all queries that have taken more than long_query_time seconds to execute to file. "
"The argument will be treated as a decimal value with microsecond precission.",
{"long_query_time", OPT_LONG_QUERY_TIME,
"Log all queries that have taken more than long-query-time seconds to "
"execute to file. The argument will be treated as a decimal value with "
"microsecond precission. Same as --log-slow-time.",
&long_query_time, &long_query_time, 0, GET_DOUBLE,
REQUIRED_ARG, 10, 0, LONG_TIMEOUT, 0, 0, 0},
{"lower_case_table_names", OPT_LOWER_CASE_TABLE_NAMES,
......@@ -8214,6 +8245,7 @@ static int mysql_init_variables(void)
opt_skip_name_resolve= 0;
opt_ignore_builtin_innodb= 0;
opt_logname= opt_update_logname= opt_binlog_index_name= opt_slow_logname= 0;
opt_log_basename= 0;
opt_tc_log_file= (char *)"tc.log"; // no hostname in tc_log file name !
opt_secure_auth= 0;
opt_secure_file_priv= 0;
......@@ -8622,6 +8654,42 @@ mysqld_get_one_option(int optid,
case (int) OPT_BIN_LOG:
opt_bin_log= test(argument != disabled_my_option);
break;
case (int) OPT_LOG_BASENAME:
{
if (opt_log_basename[0] == 0 || strchr(opt_log_basename, FN_EXTCHAR) ||
strchr(opt_log_basename,FN_LIBCHAR))
{
sql_print_error("Wrong argument for --log-basename. It can't be empty or contain '.' or '" FN_DIRSEP "'");
return 1;
}
log_error_file_ptr= argument;
/*
The following file named needs explicite extensions (should be fixed in
future by having the creating code do this).
*/
opt_logname= make_once_alloced_filename(argument, ".log");
opt_slow_logname= make_once_alloced_filename(argument, "-slow.log");
opt_bin_logname= make_once_alloced_filename(argument, "-bin");
opt_binlog_index_name= make_once_alloced_filename(argument, "-bin.index");
opt_relay_logname= make_once_alloced_filename(argument, "-relay-bin");
opt_relaylog_index_name=make_once_alloced_filename(argument,
"-relay-bin.index");
pidfile_name_ptr= pidfile_name;
strmake(pidfile_name, argument, sizeof(pidfile_name)-5);
strmov(fn_ext(pidfile_name),".pid");
/* The following is depricated so don't set it by default */
if (opt_update_logname)
opt_update_logname= argument;
/* check for errors */
if (!opt_bin_logname || !opt_relaylog_index_name || ! opt_logname ||
! opt_slow_logname)
return 1; // out of memory error
break;
}
case (int) OPT_ERROR_LOG_FILE:
opt_error_log= 1;
break;
......@@ -8738,7 +8806,6 @@ mysqld_get_one_option(int optid,
}
#endif /* HAVE_REPLICATION */
case (int) OPT_SLOW_QUERY_LOG:
WARN_DEPRECATED(NULL, "7.0", "--log_slow_queries", "'--slow_query_log'/'--log-slow-file'");
opt_slow_log= 1;
break;
case OPT_LOG_OUTPUT:
......
......@@ -170,7 +170,8 @@ a file name for --relay-log-index option", opt_relaylog_index_name);
" so replication "
"may break when this MySQL server acts as a "
"slave and has his hostname changed!! Please "
"use '--relay-log=%s' to avoid this problem.", ln);
"use '--log-basename=%' or '--relay-log=%s' to avoid "
"this problem.", ln);
name_warning_sent= 1;
}
/*
......
......@@ -895,6 +895,8 @@ static sys_var_thd_set sys_log_slow_verbosity(&vars,
/* Global read-only variable containing hostname */
static sys_var_const_str sys_hostname(&vars, "hostname", glob_hostname);
static sys_var_const_str_ptr sys_log_basename(&vars, "log_basename",
&opt_log_basename);
#ifndef EMBEDDED_LIBRARY
static sys_var_const_str_ptr sys_repl_report_host(&vars, "report_host", &report_host);
......
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