Commit 7679f5f6 authored by Nawaz Nazeer Ahamed's avatar Nawaz Nazeer Ahamed

Merge branch 'mysql-5.5.52-release' into mysql-5.5.53-release

parents 0c6eac64 754e7eff
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -83,6 +83,7 @@ typedef struct my_aio_result { ...@@ -83,6 +83,7 @@ typedef struct my_aio_result {
#define MY_RESOLVE_LINK 128 /* my_realpath(); Only resolve links */ #define MY_RESOLVE_LINK 128 /* my_realpath(); Only resolve links */
#define MY_HOLD_ORIGINAL_MODES 128 /* my_copy() holds to file modes */ #define MY_HOLD_ORIGINAL_MODES 128 /* my_copy() holds to file modes */
#define MY_REDEL_MAKE_BACKUP 256 #define MY_REDEL_MAKE_BACKUP 256
#define MY_REDEL_NO_COPY_STAT 512 /* my_redel() doesn't call my_copystat() */
#define MY_SEEK_NOT_DONE 32 /* my_lock may have to do a seek */ #define MY_SEEK_NOT_DONE 32 /* my_lock may have to do a seek */
#define MY_DONT_WAIT 64 /* my_lock() don't wait if can't lock */ #define MY_DONT_WAIT 64 /* my_lock() don't wait if can't lock */
#define MY_ZEROFILL 32 /* my_malloc(), fill array with zero */ #define MY_ZEROFILL 32 /* my_malloc(), fill array with zero */
......
/* /*
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -426,12 +426,13 @@ int chk_size(MI_CHECK *param, MI_INFO *info); ...@@ -426,12 +426,13 @@ int chk_size(MI_CHECK *param, MI_INFO *info);
int chk_key(MI_CHECK *param, MI_INFO *info); int chk_key(MI_CHECK *param, MI_INFO *info);
int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend); int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend);
int mi_repair(MI_CHECK *param, register MI_INFO *info, int mi_repair(MI_CHECK *param, register MI_INFO *info,
char * name, int rep_quick); char * name, int rep_quick, my_bool no_copy_stat);
int mi_sort_index(MI_CHECK *param, register MI_INFO *info, char * name); int mi_sort_index(MI_CHECK *param, register MI_INFO *info, char * name,
my_bool no_copy_stat);
int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
const char * name, int rep_quick); const char * name, int rep_quick, my_bool no_copy_stat);
int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
const char * name, int rep_quick); const char * name, int rep_quick, my_bool no_copy_stat);
int change_to_newfile(const char * filename, const char * old_ext, int change_to_newfile(const char * filename, const char * old_ext,
const char * new_ext, myf myflags); const char * new_ext, myf myflags);
int lock_file(MI_CHECK *param, File file, my_off_t start, int lock_type, int lock_file(MI_CHECK *param, File file, my_off_t start, int lock_type,
......
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -35,6 +35,9 @@ struct utimbuf { ...@@ -35,6 +35,9 @@ struct utimbuf {
if MY_REDEL_MAKE_COPY is given, then the orginal file if MY_REDEL_MAKE_COPY is given, then the orginal file
is renamed to org_name-'current_time'.BAK is renamed to org_name-'current_time'.BAK
if MY_REDEL_NO_COPY_STAT is given, stats are not copied
from org_name to tmp_name.
*/ */
#define REDEL_EXT ".BAK" #define REDEL_EXT ".BAK"
...@@ -46,8 +49,11 @@ int my_redel(const char *org_name, const char *tmp_name, myf MyFlags) ...@@ -46,8 +49,11 @@ int my_redel(const char *org_name, const char *tmp_name, myf MyFlags)
DBUG_PRINT("my",("org_name: '%s' tmp_name: '%s' MyFlags: %d", DBUG_PRINT("my",("org_name: '%s' tmp_name: '%s' MyFlags: %d",
org_name,tmp_name,MyFlags)); org_name,tmp_name,MyFlags));
if (my_copystat(org_name,tmp_name,MyFlags) < 0) if (!(MyFlags & MY_REDEL_NO_COPY_STAT))
goto end; {
if (my_copystat(org_name,tmp_name,MyFlags) < 0)
goto end;
}
if (MyFlags & MY_REDEL_MAKE_BACKUP) if (MyFlags & MY_REDEL_MAKE_BACKUP)
{ {
char name_buff[FN_REFLEN+20]; char name_buff[FN_REFLEN+20];
......
...@@ -102,7 +102,7 @@ start(){ ...@@ -102,7 +102,7 @@ start(){
# alarms, per bug #547485 # alarms, per bug #547485
$exec --datadir="$datadir" --socket="$socketfile" \ $exec --datadir="$datadir" --socket="$socketfile" \
--pid-file="$mypidfile" \ --pid-file="$mypidfile" \
--basedir=/usr --user=mysql >/dev/null 2>&1 & --basedir=/usr --user=mysql >/dev/null &
safe_pid=$! safe_pid=$!
# Spin for a maximum of N seconds waiting for the server to come up; # Spin for a maximum of N seconds waiting for the server to come up;
# exit the loop immediately if mysqld_safe process disappears. # exit the loop immediately if mysqld_safe process disappears.
......
...@@ -137,7 +137,7 @@ start () { ...@@ -137,7 +137,7 @@ start () {
rc_failed 6 ; rc_status -v ; rc_exit rc_failed 6 ; rc_status -v ; rc_exit
fi fi
$PROG --basedir=/usr --datadir="$datadir" --pid-file="$pidfile" >/dev/null 2>&1 & $PROG --basedir=/usr --datadir="$datadir" --pid-file="$pidfile" >/dev/null &
if pinger $! ; then if pinger $! ; then
echo -n "Starting service MySQL:" echo -n "Starting service MySQL:"
touch $lockfile touch $lockfile
......
...@@ -208,8 +208,17 @@ parse_arguments() { ...@@ -208,8 +208,17 @@ parse_arguments() {
--core-file-size=*) core_file_size="$val" ;; --core-file-size=*) core_file_size="$val" ;;
--ledir=*) ledir="$val" ;; --ledir=*) ledir="$val" ;;
--malloc-lib=*) set_malloc_lib "$val" ;; --malloc-lib=*) set_malloc_lib "$val" ;;
--mysqld=*) MYSQLD="$val" ;; --mysqld=*)
if [ -z "$pick_args" ]; then
log_error "--mysqld option can only be used as command line option, found in config file"
exit 1
fi
MYSQLD="$val" ;;
--mysqld-version=*) --mysqld-version=*)
if [ -z "$pick_args" ]; then
log_error "--mysqld-version option can only be used as command line option, found in config file"
exit 1
fi
if test -n "$val" if test -n "$val"
then then
MYSQLD="mysqld-$val" MYSQLD="mysqld-$val"
...@@ -297,38 +306,22 @@ mysqld_ld_preload_text() { ...@@ -297,38 +306,22 @@ mysqld_ld_preload_text() {
echo "$text" echo "$text"
} }
mysql_config=
get_mysql_config() {
if [ -z "$mysql_config" ]; then
mysql_config=`echo "$0" | sed 's,/[^/][^/]*$,/mysql_config,'`
if [ ! -x "$mysql_config" ]; then
log_error "Can not run mysql_config $@ from '$mysql_config'"
exit 1
fi
fi
"$mysql_config" "$@"
}
# set_malloc_lib LIB # set_malloc_lib LIB
# - If LIB is empty, do nothing and return # - If LIB is empty, do nothing and return
# - If LIB is 'tcmalloc', look for tcmalloc shared library in /usr/lib # - If LIB is 'tcmalloc', look for tcmalloc shared library in $malloc_dirs.
# then pkglibdir. tcmalloc is part of the Google perftools project. # tcmalloc is part of the Google perftools project.
# - If LIB is an absolute path, assume it is a malloc shared library # - If LIB is an absolute path, assume it is a malloc shared library
# #
# Put LIB in mysqld_ld_preload, which will be added to LD_PRELOAD when # Put LIB in mysqld_ld_preload, which will be added to LD_PRELOAD when
# running mysqld. See ld.so for details. # running mysqld. See ld.so for details.
set_malloc_lib() { set_malloc_lib() {
# This list is kept intentionally simple.
malloc_dirs="/usr/lib /usr/lib64 /usr/lib/i386-linux-gnu /usr/lib/x86_64-linux-gnu"
malloc_lib="$1" malloc_lib="$1"
if [ "$malloc_lib" = tcmalloc ]; then if [ "$malloc_lib" = tcmalloc ]; then
pkglibdir=`get_mysql_config --variable=pkglibdir`
malloc_lib= malloc_lib=
# This list is kept intentionally simple. Simply set --malloc-lib for libdir in `echo $malloc_dirs`; do
# to a full path if another location is desired.
for libdir in /usr/lib "$pkglibdir" "$pkglibdir/mysql"; do
for flavor in _minimal '' _and_profiler _debug; do for flavor in _minimal '' _and_profiler _debug; do
tmp="$libdir/libtcmalloc$flavor.so" tmp="$libdir/libtcmalloc$flavor.so"
#log_notice "DEBUG: Checking for malloc lib '$tmp'" #log_notice "DEBUG: Checking for malloc lib '$tmp'"
...@@ -339,7 +332,7 @@ set_malloc_lib() { ...@@ -339,7 +332,7 @@ set_malloc_lib() {
done done
if [ -z "$malloc_lib" ]; then if [ -z "$malloc_lib" ]; then
log_error "no shared library for --malloc-lib=tcmalloc found in /usr/lib or $pkglibdir" log_error "no shared library for --malloc-lib=tcmalloc found in $malloc_dirs"
exit 1 exit 1
fi fi
fi fi
...@@ -350,9 +343,21 @@ set_malloc_lib() { ...@@ -350,9 +343,21 @@ set_malloc_lib() {
case "$malloc_lib" in case "$malloc_lib" in
/*) /*)
if [ ! -r "$malloc_lib" ]; then if [ ! -r "$malloc_lib" ]; then
log_error "--malloc-lib '$malloc_lib' can not be read and will not be used" log_error "--malloc-lib can not be read and will not be used"
exit 1 exit 1
fi fi
# Restrict to a the list in $malloc_dirs above
case "`dirname "$malloc_lib"`" in
/usr/lib) ;;
/usr/lib64) ;;
/usr/lib/i386-linux-gnu) ;;
/usr/lib/x86_64-linux-gnu) ;;
*)
log_error "--malloc-lib must be located in one of the directories: $malloc_dirs"
exit 1
;;
esac
;; ;;
*) *)
log_error "--malloc-lib must be an absolute path or 'tcmalloc'; " \ log_error "--malloc-lib must be an absolute path or 'tcmalloc'; " \
...@@ -569,7 +574,7 @@ then ...@@ -569,7 +574,7 @@ then
log_notice "Logging to '$err_log'." log_notice "Logging to '$err_log'."
logging=file logging=file
if [ ! -f "$err_log" ]; then # if error log already exists, if [ ! -f "$err_log" -a ! -h "$err_log" ]; then # if error log already exists,
touch "$err_log" # we just append. otherwise, touch "$err_log" # we just append. otherwise,
chmod "$fmode" "$err_log" # fix the permissions here! chmod "$fmode" "$err_log" # fix the permissions here!
fi fi
...@@ -594,7 +599,7 @@ then ...@@ -594,7 +599,7 @@ then
USER_OPTION="--user=$user" USER_OPTION="--user=$user"
fi fi
# Change the err log to the right user, if it is in use # Change the err log to the right user, if it is in use
if [ $want_syslog -eq 0 ]; then if [ $want_syslog -eq 0 -a ! -h "$err_log" ]; then
touch "$err_log" touch "$err_log"
chown $user "$err_log" chown $user "$err_log"
fi fi
...@@ -614,9 +619,11 @@ safe_mysql_unix_port=${mysql_unix_port:-${MYSQL_UNIX_PORT:-@MYSQL_UNIX_ADDR@}} ...@@ -614,9 +619,11 @@ safe_mysql_unix_port=${mysql_unix_port:-${MYSQL_UNIX_PORT:-@MYSQL_UNIX_ADDR@}}
mysql_unix_port_dir=`dirname $safe_mysql_unix_port` mysql_unix_port_dir=`dirname $safe_mysql_unix_port`
if [ ! -d $mysql_unix_port_dir ] if [ ! -d $mysql_unix_port_dir ]
then then
mkdir $mysql_unix_port_dir if [ ! -h $mysql_unix_port_dir ]; then
chown $user $mysql_unix_port_dir mkdir $mysql_unix_port_dir
chmod 755 $mysql_unix_port_dir chown $user $mysql_unix_port_dir
chmod 755 $mysql_unix_port_dir
fi
fi fi
# If the user doesn't specify a binary, we assume name "mysqld" # If the user doesn't specify a binary, we assume name "mysqld"
...@@ -728,7 +735,9 @@ then ...@@ -728,7 +735,9 @@ then
exit 1 exit 1
fi fi
fi fi
rm -f "$pid_file" if [ ! -h "$pid_file" ]; then
rm -f "$pid_file"
fi
if test -f "$pid_file" if test -f "$pid_file"
then then
log_error "Fatal error: Can't remove the pid file: log_error "Fatal error: Can't remove the pid file:
...@@ -779,13 +788,19 @@ have_sleep=1 ...@@ -779,13 +788,19 @@ have_sleep=1
while true while true
do do
rm -f $safe_mysql_unix_port "$pid_file" # Some extra safety # Some extra safety
if [ ! -h "$safe_mysql_unix_port" ]; then
rm -f "$safe_mysql_unix_port"
fi
if [ ! -h "$pid_file" ]; then
rm -f "$pid_file"
fi
start_time=`date +%M%S` start_time=`date +%M%S`
eval_log_error "$cmd" eval_log_error "$cmd"
if [ $want_syslog -eq 0 -a ! -f "$err_log" ]; then if [ $want_syslog -eq 0 -a ! -f "$err_log" -a ! -h "$err_log" ]; then
touch "$err_log" # hypothetical: log was renamed but not touch "$err_log" # hypothetical: log was renamed but not
chown $user "$err_log" # flushed yet. we'd recreate it with chown $user "$err_log" # flushed yet. we'd recreate it with
chmod "$fmode" "$err_log" # wrong owner next time we log, so set chmod "$fmode" "$err_log" # wrong owner next time we log, so set
......
...@@ -2293,6 +2293,77 @@ bool MYSQL_LOG::init_and_set_log_file_name(const char *log_name, ...@@ -2293,6 +2293,77 @@ bool MYSQL_LOG::init_and_set_log_file_name(const char *log_name,
} }
bool is_valid_log_name(const char *name, size_t len)
{
if (len > 3)
{
const char *tail= name + len - 4;
if (my_strcasecmp(system_charset_info, tail, ".ini") == 0 ||
my_strcasecmp(system_charset_info, tail, ".cnf") == 0)
{
return false;
}
}
return true;
}
/**
Get the real log file name, and possibly reopen file.
Use realpath() to get the path with symbolic links
expanded. Then, close the file, and reopen the real path using the
O_NOFOLLOW flag. This will reject following symbolic links.
@param file File descriptor.
@param log_file_key Key for P_S instrumentation.
@param open_flags Flags to use for opening the file.
@param opened_file_name Name of the open fd.
@retval file descriptor to open file with 'real_file_name', or '-1'
in case of errors.
*/
#ifndef _WIN32
static File mysql_file_real_name_reopen(File file,
#ifdef HAVE_PSI_INTERFACE
PSI_file_key log_file_key,
#endif
int open_flags,
const char *opened_file_name)
{
DBUG_ASSERT(file);
DBUG_ASSERT(opened_file_name);
/* Buffer for realpath must have capacity for PATH_MAX. */
char real_file_name[PATH_MAX];
/* Get realpath, validate, open realpath with O_NOFOLLOW. */
if (realpath(opened_file_name, real_file_name) == NULL)
{
(void) mysql_file_close(file, MYF(0));
return -1;
}
if (mysql_file_close(file, MYF(0)))
return -1;
if (strlen(real_file_name) > FN_REFLEN)
return -1;
if (!is_valid_log_name(real_file_name, strlen(real_file_name)))
{
sql_print_error("Invalid log file name after expanding symlinks: '%s'",
real_file_name);
return -1;
}
return mysql_file_open(log_file_key, real_file_name,
open_flags | O_NOFOLLOW,
MYF(MY_WME | ME_WAITTANG));
}
#endif // _WIN32
/* /*
Open a (new) log file. Open a (new) log file.
...@@ -2358,8 +2429,22 @@ bool MYSQL_LOG::open( ...@@ -2358,8 +2429,22 @@ bool MYSQL_LOG::open(
if ((file= mysql_file_open(log_file_key, if ((file= mysql_file_open(log_file_key,
log_file_name, open_flags, log_file_name, open_flags,
MYF(MY_WME | ME_WAITTANG))) < 0 || MYF(MY_WME | ME_WAITTANG))) < 0)
init_io_cache(&log_file, file, IO_SIZE, io_cache_type, goto err;
#ifndef _WIN32
/* Reopen and validate path. */
if ((log_type_arg == LOG_UNKNOWN || log_type_arg == LOG_NORMAL) &&
(file= mysql_file_real_name_reopen(file,
#ifdef HAVE_PSI_INTERFACE
log_file_key,
#endif
open_flags,
log_file_name)) < 0)
goto err;
#endif // _WIN32
if (init_io_cache(&log_file, file, IO_SIZE, io_cache_type,
mysql_file_tell(file, MYF(MY_WME)), 0, mysql_file_tell(file, MYF(MY_WME)), 0,
MYF(MY_WME | MY_NABP | MYF(MY_WME | MY_NABP |
((log_type == LOG_BIN) ? MY_WAIT_IF_FULL : 0)))) ((log_type == LOG_BIN) ? MY_WAIT_IF_FULL : 0))))
......
...@@ -717,6 +717,16 @@ File open_binlog(IO_CACHE *log, const char *log_file_name, ...@@ -717,6 +717,16 @@ File open_binlog(IO_CACHE *log, const char *log_file_name,
char *make_log_name(char *buff, const char *name, const char* log_ext); char *make_log_name(char *buff, const char *name, const char* log_ext);
/**
Check given log name against certain blacklisted names/extensions.
@param name Log name to check
@param len Length of log name
@returns true if name is valid, false otherwise.
*/
bool is_valid_log_name(const char *name, size_t len);
extern MYSQL_PLUGIN_IMPORT MYSQL_BIN_LOG mysql_bin_log; extern MYSQL_PLUGIN_IMPORT MYSQL_BIN_LOG mysql_bin_log;
extern LOGGER logger; extern LOGGER logger;
......
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights
reserved. reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
...@@ -3512,6 +3512,22 @@ static int init_common_variables() ...@@ -3512,6 +3512,22 @@ static int init_common_variables()
"--log-slow-queries option, log tables are used. " "--log-slow-queries option, log tables are used. "
"To enable logging to files use the --log-output=file option."); "To enable logging to files use the --log-output=file option.");
if (opt_logname &&
!is_valid_log_name(opt_logname, strlen(opt_logname)))
{
sql_print_error("Invalid value for --general_log_file: %s",
opt_logname);
return 1;
}
if (opt_slow_logname &&
!is_valid_log_name(opt_slow_logname, strlen(opt_slow_logname)))
{
sql_print_error("Invalid value for --slow_query_log_file: %s",
opt_slow_logname);
return 1;
}
#define FIX_LOG_VAR(VAR, ALT) \ #define FIX_LOG_VAR(VAR, ALT) \
if (!VAR || !*VAR) \ if (!VAR || !*VAR) \
{ \ { \
......
/* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. /* Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -2810,6 +2810,14 @@ static bool check_log_path(sys_var *self, THD *thd, set_var *var) ...@@ -2810,6 +2810,14 @@ static bool check_log_path(sys_var *self, THD *thd, set_var *var)
if (!var->save_result.string_value.str) if (!var->save_result.string_value.str)
return true; return true;
if (!is_valid_log_name(var->save_result.string_value.str,
var->save_result.string_value.length))
{
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0),
self->name.str, var->save_result.string_value.str);
return true;
}
if (var->save_result.string_value.length > FN_REFLEN) if (var->save_result.string_value.length > FN_REFLEN)
{ // path is too long { // path is too long
my_error(ER_PATH_LENGTH, MYF(0), self->name.str); my_error(ER_PATH_LENGTH, MYF(0), self->name.str);
...@@ -2856,7 +2864,7 @@ static bool check_log_path(sys_var *self, THD *thd, set_var *var) ...@@ -2856,7 +2864,7 @@ static bool check_log_path(sys_var *self, THD *thd, set_var *var)
return false; return false;
} }
static bool fix_log(char** logname, const char* default_logname, static bool fix_log(char** logname, const char* default_logname,
const char*ext, bool enabled, void (*reopen)(char*)) const char*ext, bool enabled, bool (*reopen)(char*))
{ {
if (!*logname) // SET ... = DEFAULT if (!*logname) // SET ... = DEFAULT
{ {
...@@ -2868,16 +2876,17 @@ static bool fix_log(char** logname, const char* default_logname, ...@@ -2868,16 +2876,17 @@ static bool fix_log(char** logname, const char* default_logname,
} }
logger.lock_exclusive(); logger.lock_exclusive();
mysql_mutex_unlock(&LOCK_global_system_variables); mysql_mutex_unlock(&LOCK_global_system_variables);
bool error= false;
if (enabled) if (enabled)
reopen(*logname); error= reopen(*logname);
logger.unlock(); logger.unlock();
mysql_mutex_lock(&LOCK_global_system_variables); mysql_mutex_lock(&LOCK_global_system_variables);
return false; return error;
} }
static void reopen_general_log(char* name) static bool reopen_general_log(char* name)
{ {
logger.get_log_file_handler()->close(0); logger.get_log_file_handler()->close(0);
logger.get_log_file_handler()->open_query_log(name); return logger.get_log_file_handler()->open_query_log(name);
} }
static bool fix_general_log_file(sys_var *self, THD *thd, enum_var_type type) static bool fix_general_log_file(sys_var *self, THD *thd, enum_var_type type)
{ {
...@@ -2890,10 +2899,10 @@ static Sys_var_charptr Sys_general_log_path( ...@@ -2890,10 +2899,10 @@ static Sys_var_charptr Sys_general_log_path(
IN_FS_CHARSET, DEFAULT(0), NO_MUTEX_GUARD, NOT_IN_BINLOG, IN_FS_CHARSET, DEFAULT(0), NO_MUTEX_GUARD, NOT_IN_BINLOG,
ON_CHECK(check_log_path), ON_UPDATE(fix_general_log_file)); ON_CHECK(check_log_path), ON_UPDATE(fix_general_log_file));
static void reopen_slow_log(char* name) static bool reopen_slow_log(char* name)
{ {
logger.get_slow_log_file_handler()->close(0); logger.get_slow_log_file_handler()->close(0);
logger.get_slow_log_file_handler()->open_slow_log(name); return logger.get_slow_log_file_handler()->open_slow_log(name);
} }
static bool fix_slow_log_file(sys_var *self, THD *thd, enum_var_type type) static bool fix_slow_log_file(sys_var *self, THD *thd, enum_var_type type)
{ {
......
/* /*
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -1091,24 +1091,36 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool do_optimize) ...@@ -1091,24 +1091,36 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool do_optimize)
/* TODO: respect myisam_repair_threads variable */ /* TODO: respect myisam_repair_threads variable */
my_snprintf(buf, 40, "Repair with %d threads", my_count_bits(key_map)); my_snprintf(buf, 40, "Repair with %d threads", my_count_bits(key_map));
thd_proc_info(thd, buf); thd_proc_info(thd, buf);
/*
The new file is created with the right stats, so we can skip
copying file stats from old to new.
*/
error = mi_repair_parallel(&param, file, fixed_name, error = mi_repair_parallel(&param, file, fixed_name,
param.testflag & T_QUICK); param.testflag & T_QUICK, TRUE);
thd_proc_info(thd, "Repair done"); // to reset proc_info, as thd_proc_info(thd, "Repair done"); // to reset proc_info, as
// it was pointing to local buffer // it was pointing to local buffer
} }
else else
{ {
thd_proc_info(thd, "Repair by sorting"); thd_proc_info(thd, "Repair by sorting");
/*
The new file is created with the right stats, so we can skip
copying file stats from old to new.
*/
error = mi_repair_by_sort(&param, file, fixed_name, error = mi_repair_by_sort(&param, file, fixed_name,
param.testflag & T_QUICK); param.testflag & T_QUICK, TRUE);
} }
} }
else else
{ {
thd_proc_info(thd, "Repair with keycache"); thd_proc_info(thd, "Repair with keycache");
param.testflag &= ~T_REP_BY_SORT; param.testflag &= ~T_REP_BY_SORT;
/*
The new file is created with the right stats, so we can skip
copying file stats from old to new.
*/
error= mi_repair(&param, file, fixed_name, error= mi_repair(&param, file, fixed_name,
param.testflag & T_QUICK); param.testflag & T_QUICK, TRUE);
} }
#ifdef HAVE_MMAP #ifdef HAVE_MMAP
if (remap) if (remap)
...@@ -1124,7 +1136,11 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool do_optimize) ...@@ -1124,7 +1136,11 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool do_optimize)
{ {
optimize_done=1; optimize_done=1;
thd_proc_info(thd, "Sorting index"); thd_proc_info(thd, "Sorting index");
error=mi_sort_index(&param,file,fixed_name); /*
The new file is created with the right stats, so we can skip
copying file stats from old to new.
*/
error=mi_sort_index(&param,file,fixed_name, TRUE);
} }
if (!statistics_done && (local_testflag & T_STATISTICS)) if (!statistics_done && (local_testflag & T_STATISTICS))
{ {
......
/* /*
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -1512,7 +1512,7 @@ static int mi_drop_all_indexes(MI_CHECK *param, MI_INFO *info, my_bool force) ...@@ -1512,7 +1512,7 @@ static int mi_drop_all_indexes(MI_CHECK *param, MI_INFO *info, my_bool force)
/* Save new datafile-name in temp_filename */ /* Save new datafile-name in temp_filename */
int mi_repair(MI_CHECK *param, register MI_INFO *info, int mi_repair(MI_CHECK *param, register MI_INFO *info,
char * name, int rep_quick) char * name, int rep_quick, my_bool no_copy_stat)
{ {
int error,got_error; int error,got_error;
ha_rows start_records,new_header_length; ha_rows start_records,new_header_length;
...@@ -1726,6 +1726,11 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, ...@@ -1726,6 +1726,11 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
/* Replace the actual file with the temporary file */ /* Replace the actual file with the temporary file */
if (new_file >= 0) if (new_file >= 0)
{ {
myf flags= 0;
if (param->testflag & T_BACKUP_DATA)
flags |= MY_REDEL_MAKE_BACKUP;
if (no_copy_stat)
flags |= MY_REDEL_NO_COPY_STAT;
mysql_file_close(new_file, MYF(0)); mysql_file_close(new_file, MYF(0));
info->dfile=new_file= -1; info->dfile=new_file= -1;
/* /*
...@@ -1744,8 +1749,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, ...@@ -1744,8 +1749,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
info->s->file_map= NULL; info->s->file_map= NULL;
} }
if (change_to_newfile(share->data_file_name, MI_NAME_DEXT, DATA_TMP_EXT, if (change_to_newfile(share->data_file_name, MI_NAME_DEXT, DATA_TMP_EXT,
(param->testflag & T_BACKUP_DATA ? flags) ||
MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) ||
mi_open_datafile(info,share,name,-1)) mi_open_datafile(info,share,name,-1))
got_error=1; got_error=1;
...@@ -1933,7 +1937,8 @@ int flush_blocks(MI_CHECK *param, KEY_CACHE *key_cache, File file) ...@@ -1933,7 +1937,8 @@ int flush_blocks(MI_CHECK *param, KEY_CACHE *key_cache, File file)
/* Sort index for more efficent reads */ /* Sort index for more efficent reads */
int mi_sort_index(MI_CHECK *param, register MI_INFO *info, char * name) int mi_sort_index(MI_CHECK *param, register MI_INFO *info, char * name,
my_bool no_copy_stat)
{ {
reg2 uint key; reg2 uint key;
reg1 MI_KEYDEF *keyinfo; reg1 MI_KEYDEF *keyinfo;
...@@ -2004,7 +2009,7 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, char * name) ...@@ -2004,7 +2009,7 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, char * name)
share->kfile = -1; share->kfile = -1;
(void) mysql_file_close(new_file, MYF(MY_WME)); (void) mysql_file_close(new_file, MYF(MY_WME));
if (change_to_newfile(share->index_file_name, MI_NAME_IEXT, INDEX_TMP_EXT, if (change_to_newfile(share->index_file_name, MI_NAME_IEXT, INDEX_TMP_EXT,
MYF(0)) || no_copy_stat ? MYF(MY_REDEL_NO_COPY_STAT) : MYF(0)) ||
mi_open_keyfile(share)) mi_open_keyfile(share))
goto err2; goto err2;
info->lock_type= F_UNLCK; /* Force mi_readinfo to lock */ info->lock_type= F_UNLCK; /* Force mi_readinfo to lock */
...@@ -2209,6 +2214,8 @@ int filecopy(MI_CHECK *param, File to,File from,my_off_t start, ...@@ -2209,6 +2214,8 @@ int filecopy(MI_CHECK *param, File to,File from,my_off_t start,
info MyISAM handler to repair info MyISAM handler to repair
name Name of table (for warnings) name Name of table (for warnings)
rep_quick set to <> 0 if we should not change data file rep_quick set to <> 0 if we should not change data file
no_copy_stat Don't copy file stats from old to new file,
assume that new file was created with correct stats
RESULT RESULT
0 ok 0 ok
...@@ -2216,7 +2223,7 @@ int filecopy(MI_CHECK *param, File to,File from,my_off_t start, ...@@ -2216,7 +2223,7 @@ int filecopy(MI_CHECK *param, File to,File from,my_off_t start,
*/ */
int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
const char * name, int rep_quick) const char * name, int rep_quick, my_bool no_copy_stat)
{ {
int got_error; int got_error;
uint i; uint i;
...@@ -2543,11 +2550,15 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, ...@@ -2543,11 +2550,15 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
/* Replace the actual file with the temporary file */ /* Replace the actual file with the temporary file */
if (new_file >= 0) if (new_file >= 0)
{ {
myf flags= 0;
if (param->testflag & T_BACKUP_DATA)
flags |= MY_REDEL_MAKE_BACKUP;
if (no_copy_stat)
flags |= MY_REDEL_NO_COPY_STAT;
mysql_file_close(new_file, MYF(0)); mysql_file_close(new_file, MYF(0));
info->dfile=new_file= -1; info->dfile=new_file= -1;
if (change_to_newfile(share->data_file_name,MI_NAME_DEXT, DATA_TMP_EXT, if (change_to_newfile(share->data_file_name,MI_NAME_DEXT, DATA_TMP_EXT,
(param->testflag & T_BACKUP_DATA ? flags) ||
MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) ||
mi_open_datafile(info,share,name,-1)) mi_open_datafile(info,share,name,-1))
got_error=1; got_error=1;
} }
...@@ -2595,6 +2606,8 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, ...@@ -2595,6 +2606,8 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
info MyISAM handler to repair info MyISAM handler to repair
name Name of table (for warnings) name Name of table (for warnings)
rep_quick set to <> 0 if we should not change data file rep_quick set to <> 0 if we should not change data file
no_copy_stat Don't copy file stats from old to new file,
assume that new file was created with correct stats
DESCRIPTION DESCRIPTION
Same as mi_repair_by_sort but do it multithreaded Same as mi_repair_by_sort but do it multithreaded
...@@ -2629,7 +2642,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, ...@@ -2629,7 +2642,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
*/ */
int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
const char * name, int rep_quick) const char * name, int rep_quick, my_bool no_copy_stat)
{ {
int got_error; int got_error;
uint i,key, total_key_length, istep; uint i,key, total_key_length, istep;
...@@ -3076,11 +3089,15 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, ...@@ -3076,11 +3089,15 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
/* Replace the actual file with the temporary file */ /* Replace the actual file with the temporary file */
if (new_file >= 0) if (new_file >= 0)
{ {
myf flags= 0;
if (param->testflag & T_BACKUP_DATA)
flags |= MY_REDEL_MAKE_BACKUP;
if (no_copy_stat)
flags |= MY_REDEL_NO_COPY_STAT;
mysql_file_close(new_file, MYF(0)); mysql_file_close(new_file, MYF(0));
info->dfile=new_file= -1; info->dfile=new_file= -1;
if (change_to_newfile(share->data_file_name, MI_NAME_DEXT, DATA_TMP_EXT, if (change_to_newfile(share->data_file_name, MI_NAME_DEXT, DATA_TMP_EXT,
(param->testflag & T_BACKUP_DATA ? flags) ||
MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) ||
mi_open_datafile(info,share,name,-1)) mi_open_datafile(info,share,name,-1))
got_error=1; got_error=1;
} }
......
/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -993,14 +993,18 @@ static int myisamchk(MI_CHECK *param, char * filename) ...@@ -993,14 +993,18 @@ static int myisamchk(MI_CHECK *param, char * filename)
info->s->state.key_map, info->s->state.key_map,
param->force_sort)) param->force_sort))
{ {
/*
The new file might not be created with the right stats depending
on how myisamchk is run, so we must copy file stats from old to new.
*/
if (param->testflag & T_REP_BY_SORT) if (param->testflag & T_REP_BY_SORT)
error=mi_repair_by_sort(param,info,filename,rep_quick); error= mi_repair_by_sort(param, info, filename, rep_quick, FALSE);
else else
error=mi_repair_parallel(param,info,filename,rep_quick); error= mi_repair_parallel(param, info, filename, rep_quick, FALSE);
state_updated=1; state_updated=1;
} }
else if (param->testflag & T_REP_ANY) else if (param->testflag & T_REP_ANY)
error=mi_repair(param, info,filename,rep_quick); error= mi_repair(param, info, filename, rep_quick, FALSE);
} }
if (!error && param->testflag & T_SORT_RECORDS) if (!error && param->testflag & T_SORT_RECORDS)
{ {
...@@ -1040,12 +1044,12 @@ static int myisamchk(MI_CHECK *param, char * filename) ...@@ -1040,12 +1044,12 @@ static int myisamchk(MI_CHECK *param, char * filename)
{ {
if (param->verbose) if (param->verbose)
puts("Table had a compressed index; We must now recreate the index"); puts("Table had a compressed index; We must now recreate the index");
error=mi_repair_by_sort(param,info,filename,1); error= mi_repair_by_sort(param, info, filename, 1, FALSE);
} }
} }
} }
if (!error && param->testflag & T_SORT_INDEX) if (!error && param->testflag & T_SORT_INDEX)
error=mi_sort_index(param,info,filename); error= mi_sort_index(param, info, filename, FALSE);
if (!error) if (!error)
share->state.changed&= ~(STATE_CHANGED | STATE_CRASHED | share->state.changed&= ~(STATE_CHANGED | STATE_CRASHED |
STATE_CRASHED_ON_REPAIR); STATE_CRASHED_ON_REPAIR);
......
...@@ -280,7 +280,7 @@ case "$mode" in ...@@ -280,7 +280,7 @@ case "$mode" in
then then
# Give extra arguments to mysqld with the my.cnf file. This script # Give extra arguments to mysqld with the my.cnf file. This script
# may be overwritten at next upgrade. # may be overwritten at next upgrade.
$bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 & $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null &
wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$? wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$?
# Make lock for RedHat / SuSE # Make lock for RedHat / SuSE
......
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