mirror of
https://github.com/MariaDB/server.git
synced 2025-09-02 09:41:40 +03:00
Merge pilot.blaudden:/home/msvensson/mysql/mysql-5.0
into pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint
This commit is contained in:
133
sql/mysqld.cc
133
sql/mysqld.cc
@@ -319,9 +319,14 @@ static char *my_bind_addr_str;
|
||||
static char *default_collation_name;
|
||||
static char compiled_default_collation_name[]= MYSQL_DEFAULT_COLLATION_NAME;
|
||||
static char mysql_data_home_buff[2];
|
||||
static struct passwd *user_info;
|
||||
static I_List<THD> thread_cache;
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
static struct passwd *user_info;
|
||||
static pthread_t select_thread;
|
||||
static uint thr_kill_signal;
|
||||
#endif
|
||||
|
||||
static pthread_cond_t COND_thread_cache, COND_flush_thread_cache;
|
||||
|
||||
#ifdef HAVE_BERKELEY_DB
|
||||
@@ -350,6 +355,8 @@ my_bool opt_safe_user_create = 0, opt_no_mix_types = 0;
|
||||
my_bool opt_show_slave_auth_info, opt_sql_bin_update = 0;
|
||||
my_bool opt_log_slave_updates= 0;
|
||||
my_bool opt_innodb;
|
||||
bool slave_warning_issued = false;
|
||||
|
||||
#ifdef HAVE_NDBCLUSTER_DB
|
||||
const char *opt_ndbcluster_connectstring= 0;
|
||||
const char *opt_ndb_connectstring= 0;
|
||||
@@ -396,7 +403,7 @@ ulong slave_net_timeout, slave_trans_retries;
|
||||
ulong thread_cache_size=0, binlog_cache_size=0, max_binlog_cache_size=0;
|
||||
ulong query_cache_size=0;
|
||||
ulong refresh_version, flush_version; /* Increments on each reload */
|
||||
query_id_t query_id;
|
||||
query_id_t global_query_id;
|
||||
ulong aborted_threads, aborted_connects;
|
||||
ulong delayed_insert_timeout, delayed_insert_limit, delayed_queue_size;
|
||||
ulong delayed_insert_threads, delayed_insert_writes, delayed_rows_in_use;
|
||||
@@ -428,7 +435,7 @@ ulong rpl_recovery_rank=0;
|
||||
|
||||
double log_10[32]; /* 10 potences */
|
||||
double log_01[32];
|
||||
time_t start_time;
|
||||
time_t server_start_time;
|
||||
|
||||
char mysql_home[FN_REFLEN], pidfile_name[FN_REFLEN], system_time_zone[30];
|
||||
char *default_tz_name;
|
||||
@@ -519,7 +526,6 @@ rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave;
|
||||
pthread_cond_t COND_refresh,COND_thread_count, COND_global_read_lock;
|
||||
pthread_t signal_thread;
|
||||
pthread_attr_t connection_attrib;
|
||||
static uint thr_kill_signal;
|
||||
|
||||
File_parser_dummy_hook file_parser_dummy_hook;
|
||||
|
||||
@@ -547,7 +553,6 @@ static char **defaults_argv;
|
||||
static char *opt_bin_logname;
|
||||
|
||||
static my_socket unix_sock,ip_sock;
|
||||
static pthread_t select_thread;
|
||||
struct rand_struct sql_rand; // used by sql_class.cc:THD::THD()
|
||||
|
||||
/* OS specific variables */
|
||||
@@ -630,7 +635,6 @@ struct st_VioSSLFd *ssl_acceptor_fd;
|
||||
|
||||
/* Function declarations */
|
||||
|
||||
static void start_signal_handler(void);
|
||||
pthread_handler_t signal_hand(void *arg);
|
||||
static void mysql_init_variables(void);
|
||||
static void get_options(int argc,char **argv);
|
||||
@@ -641,7 +645,6 @@ static void fix_paths(void);
|
||||
pthread_handler_t handle_connections_sockets(void *arg);
|
||||
pthread_handler_t kill_server_thread(void *arg);
|
||||
static void bootstrap(FILE *file);
|
||||
static void close_server_sock();
|
||||
static bool read_init_file(char *file_name);
|
||||
#ifdef __NT__
|
||||
pthread_handler_t handle_connections_namedpipes(void *arg);
|
||||
@@ -652,10 +655,16 @@ pthread_handler_t handle_connections_shared_memory(void *arg);
|
||||
pthread_handler_t handle_slave(void *arg);
|
||||
static ulong find_bit_type(const char *x, TYPELIB *bit_lib);
|
||||
static void clean_up(bool print_message);
|
||||
static int test_if_case_insensitive(const char *dir_name);
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
static void start_signal_handler(void);
|
||||
static void close_server_sock();
|
||||
static void clean_up_mutexes(void);
|
||||
static void wait_for_signal_thread_to_end(void);
|
||||
static int test_if_case_insensitive(const char *dir_name);
|
||||
static void create_pid_file();
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
/****************************************************************************
|
||||
@@ -844,7 +853,6 @@ static void close_connections(void)
|
||||
DBUG_PRINT("quit",("close_connections thread"));
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
#endif /*EMBEDDED_LIBRARY*/
|
||||
|
||||
|
||||
static void close_server_sock()
|
||||
@@ -887,12 +895,14 @@ static void close_server_sock()
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /*EMBEDDED_LIBRARY*/
|
||||
|
||||
|
||||
void kill_mysql(void)
|
||||
{
|
||||
DBUG_ENTER("kill_mysql");
|
||||
|
||||
#ifdef SIGNALS_DONT_BREAK_READ
|
||||
#if defined(SIGNALS_DONT_BREAK_READ) && !defined(EMBEDDED_LIBRARY)
|
||||
abort_loop=1; // Break connection loops
|
||||
close_server_sock(); // Force accept to wake up
|
||||
#endif
|
||||
@@ -972,7 +982,7 @@ static void __cdecl kill_server(int sig_ptr)
|
||||
kill_in_progress=TRUE;
|
||||
abort_loop=1; // This should be set
|
||||
if (sig != 0) // 0 is not a valid signal number
|
||||
my_sigset(sig,SIG_IGN);
|
||||
my_sigset(sig, SIG_IGN); /* purify inspected */
|
||||
if (sig == MYSQL_KILL_SIGNAL || sig == 0)
|
||||
sql_print_information(ER(ER_NORMAL_SHUTDOWN),my_progname);
|
||||
else
|
||||
@@ -1194,6 +1204,8 @@ void clean_up(bool print_message)
|
||||
} /* clean_up */
|
||||
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
|
||||
/*
|
||||
This is mainly needed when running with purify, but it's still nice to
|
||||
know that all child threads have died when mysqld exits
|
||||
@@ -1262,6 +1274,9 @@ static void clean_up_mutexes()
|
||||
(void) pthread_cond_destroy(&COND_manager);
|
||||
}
|
||||
|
||||
#endif /*EMBEDDED_LIBRARY*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
** Init IP and UNIX socket
|
||||
****************************************************************************/
|
||||
@@ -1296,7 +1311,7 @@ static void set_ports()
|
||||
static struct passwd *check_user(const char *user)
|
||||
{
|
||||
#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
|
||||
struct passwd *user_info;
|
||||
struct passwd *tmp_user_info;
|
||||
uid_t user_id= geteuid();
|
||||
|
||||
// Don't bother if we aren't superuser
|
||||
@@ -1304,12 +1319,14 @@ static struct passwd *check_user(const char *user)
|
||||
{
|
||||
if (user)
|
||||
{
|
||||
// Don't give a warning, if real user is same as given with --user
|
||||
user_info= getpwnam(user);
|
||||
if ((!user_info || user_id != user_info->pw_uid) &&
|
||||
/* Don't give a warning, if real user is same as given with --user */
|
||||
/* purecov: begin tested */
|
||||
tmp_user_info= getpwnam(user);
|
||||
if ((!tmp_user_info || user_id != tmp_user_info->pw_uid) &&
|
||||
global_system_variables.log_warnings)
|
||||
sql_print_warning(
|
||||
"One can only use the --user switch if running as root\n");
|
||||
/* purecov: end */
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -1322,23 +1339,25 @@ static struct passwd *check_user(const char *user)
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
/* purecov: begin tested */
|
||||
if (!strcmp(user,"root"))
|
||||
return NULL; // Avoid problem with dynamic libraries
|
||||
|
||||
if (!(user_info= getpwnam(user)))
|
||||
if (!(tmp_user_info= getpwnam(user)))
|
||||
{
|
||||
// Allow a numeric uid to be used
|
||||
const char *pos;
|
||||
for (pos= user; my_isdigit(mysqld_charset,*pos); pos++) ;
|
||||
if (*pos) // Not numeric id
|
||||
goto err;
|
||||
if (!(user_info= getpwuid(atoi(user))))
|
||||
if (!(tmp_user_info= getpwuid(atoi(user))))
|
||||
goto err;
|
||||
else
|
||||
return user_info;
|
||||
return tmp_user_info;
|
||||
}
|
||||
else
|
||||
return user_info;
|
||||
return tmp_user_info;
|
||||
/* purecov: end */
|
||||
|
||||
err:
|
||||
sql_print_error("Fatal error: Can't change to run as user '%s' ; Please check that the user exists!\n",user);
|
||||
@@ -1347,10 +1366,11 @@ err:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void set_user(const char *user, struct passwd *user_info)
|
||||
static void set_user(const char *user, struct passwd *user_info_arg)
|
||||
{
|
||||
/* purecov: begin tested */
|
||||
#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
|
||||
DBUG_ASSERT(user_info != 0);
|
||||
DBUG_ASSERT(user_info_arg != 0);
|
||||
#ifdef HAVE_INITGROUPS
|
||||
/*
|
||||
We can get a SIGSEGV when calling initgroups() on some systems when NSS
|
||||
@@ -1359,33 +1379,34 @@ static void set_user(const char *user, struct passwd *user_info)
|
||||
output a specific message to help the user resolve this problem.
|
||||
*/
|
||||
calling_initgroups= TRUE;
|
||||
initgroups((char*) user, user_info->pw_gid);
|
||||
initgroups((char*) user, user_info_arg->pw_gid);
|
||||
calling_initgroups= FALSE;
|
||||
#endif
|
||||
if (setgid(user_info->pw_gid) == -1)
|
||||
if (setgid(user_info_arg->pw_gid) == -1)
|
||||
{
|
||||
sql_perror("setgid");
|
||||
unireg_abort(1);
|
||||
}
|
||||
if (setuid(user_info->pw_uid) == -1)
|
||||
if (setuid(user_info_arg->pw_uid) == -1)
|
||||
{
|
||||
sql_perror("setuid");
|
||||
unireg_abort(1);
|
||||
}
|
||||
#endif
|
||||
/* purecov: end */
|
||||
}
|
||||
|
||||
|
||||
static void set_effective_user(struct passwd *user_info)
|
||||
static void set_effective_user(struct passwd *user_info_arg)
|
||||
{
|
||||
#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
|
||||
DBUG_ASSERT(user_info != 0);
|
||||
if (setregid((gid_t)-1, user_info->pw_gid) == -1)
|
||||
DBUG_ASSERT(user_info_arg != 0);
|
||||
if (setregid((gid_t)-1, user_info_arg->pw_gid) == -1)
|
||||
{
|
||||
sql_perror("setregid");
|
||||
unireg_abort(1);
|
||||
}
|
||||
if (setreuid((uid_t)-1, user_info->pw_uid) == -1)
|
||||
if (setreuid((uid_t)-1, user_info_arg->pw_uid) == -1)
|
||||
{
|
||||
sql_perror("setreuid");
|
||||
unireg_abort(1);
|
||||
@@ -1732,6 +1753,7 @@ extern "C" sig_handler abort_thread(int sig __attribute__((unused)))
|
||||
the signal thread is ready before continuing
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#if defined(__WIN__) || defined(OS2)
|
||||
static void init_signals(void)
|
||||
{
|
||||
@@ -1972,6 +1994,7 @@ static void init_signals(void)
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void start_signal_handler(void)
|
||||
{
|
||||
// Save vm id of this process
|
||||
@@ -2023,6 +2046,7 @@ static void init_signals(void)
|
||||
signal_thread = pthread_self();
|
||||
}
|
||||
|
||||
|
||||
static void start_signal_handler(void)
|
||||
{}
|
||||
|
||||
@@ -2154,6 +2178,8 @@ bugs.\n");
|
||||
#define SA_NODEFER 0
|
||||
#endif
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
|
||||
static void init_signals(void)
|
||||
{
|
||||
sigset_t set;
|
||||
@@ -2232,7 +2258,6 @@ static void init_signals(void)
|
||||
}
|
||||
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
static void start_signal_handler(void)
|
||||
{
|
||||
int error;
|
||||
@@ -2396,11 +2421,11 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
|
||||
}
|
||||
return(0); /* purecov: deadcode */
|
||||
}
|
||||
#endif /*!EMBEDDED_LIBRARY*/
|
||||
|
||||
static void check_data_home(const char *path)
|
||||
{}
|
||||
|
||||
#endif /*!EMBEDDED_LIBRARY*/
|
||||
#endif /* __WIN__*/
|
||||
|
||||
|
||||
@@ -2463,6 +2488,7 @@ static int my_message_sql(uint error, const char *str, myf MyFlags)
|
||||
}
|
||||
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
static void *my_str_malloc_mysqld(size_t size)
|
||||
{
|
||||
return my_malloc(size, MYF(MY_FAE));
|
||||
@@ -2473,6 +2499,7 @@ static void my_str_free_mysqld(void *ptr)
|
||||
{
|
||||
my_free((gptr)ptr, MYF(MY_FAE));
|
||||
}
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
|
||||
|
||||
#ifdef __WIN__
|
||||
@@ -2605,7 +2632,7 @@ static int init_common_variables(const char *conf_file_name, int argc,
|
||||
tzset(); // Set tzname
|
||||
|
||||
max_system_variables.pseudo_thread_id= (ulong)~0;
|
||||
start_time=time((time_t*) 0);
|
||||
server_start_time= time((time_t*) 0);
|
||||
if (init_thread_environment())
|
||||
return 1;
|
||||
mysql_init_variables();
|
||||
@@ -2621,7 +2648,7 @@ static int init_common_variables(const char *conf_file_name, int argc,
|
||||
#ifdef HAVE_TZNAME
|
||||
{
|
||||
struct tm tm_tmp;
|
||||
localtime_r(&start_time,&tm_tmp);
|
||||
localtime_r(&server_start_time,&tm_tmp);
|
||||
strmake(system_time_zone, tzname[tm_tmp.tm_isdst != 0 ? 1 : 0],
|
||||
sizeof(system_time_zone)-1);
|
||||
|
||||
@@ -3004,6 +3031,8 @@ static void openssl_lock(int mode, openssl_lock_t *lock, const char *file,
|
||||
#endif /* HAVE_OPENSSL */
|
||||
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
|
||||
static void init_ssl()
|
||||
{
|
||||
#ifdef HAVE_OPENSSL
|
||||
@@ -3029,6 +3058,7 @@ static void init_ssl()
|
||||
#endif /* HAVE_OPENSSL */
|
||||
}
|
||||
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
|
||||
static int init_server_components()
|
||||
{
|
||||
@@ -3040,7 +3070,7 @@ static int init_server_components()
|
||||
query_cache_set_min_res_unit(query_cache_min_res_unit);
|
||||
query_cache_init();
|
||||
query_cache_resize(query_cache_size);
|
||||
randominit(&sql_rand,(ulong) start_time,(ulong) start_time/2);
|
||||
randominit(&sql_rand,(ulong) server_start_time,(ulong) server_start_time/2);
|
||||
reset_floating_point_exceptions();
|
||||
init_thr_lock();
|
||||
#ifdef HAVE_REPLICATION
|
||||
@@ -3210,7 +3240,7 @@ server.");
|
||||
(TC_LOG *) &tc_log_mmap) :
|
||||
(TC_LOG *) &tc_log_dummy);
|
||||
|
||||
if (tc_log->open(opt_bin_logname))
|
||||
if (tc_log->open(opt_bin_log ? opt_bin_logname : opt_tc_log_file))
|
||||
{
|
||||
sql_print_error("Can't init tc log");
|
||||
unireg_abort(1);
|
||||
@@ -3228,7 +3258,7 @@ server.");
|
||||
#ifdef HAVE_REPLICATION
|
||||
if (opt_bin_log && expire_logs_days)
|
||||
{
|
||||
long purge_time= time(0) - expire_logs_days*24*60*60;
|
||||
long purge_time= (long) (time(0) - expire_logs_days*24*60*60);
|
||||
if (purge_time >= 0)
|
||||
mysql_bin_log.purge_logs_before_date(purge_time);
|
||||
}
|
||||
@@ -3269,6 +3299,7 @@ server.");
|
||||
}
|
||||
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
static void create_maintenance_thread()
|
||||
{
|
||||
if (
|
||||
@@ -3286,7 +3317,6 @@ static void create_maintenance_thread()
|
||||
|
||||
static void create_shutdown_thread()
|
||||
{
|
||||
#if !defined(EMBEDDED_LIBRARY)
|
||||
#ifdef __WIN__
|
||||
hEventShutdown=CreateEvent(0, FALSE, FALSE, shutdown_event_name);
|
||||
pthread_t hThread;
|
||||
@@ -3302,9 +3332,9 @@ static void create_shutdown_thread()
|
||||
if (pthread_create(&hThread,&connection_attrib,handle_shutdown,0))
|
||||
sql_print_warning("Can't create thread to handle shutdown requests");
|
||||
#endif
|
||||
#endif // EMBEDDED_LIBRARY
|
||||
}
|
||||
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
|
||||
#if defined(__NT__) || defined(HAVE_SMEM)
|
||||
static void handle_connections_methods()
|
||||
@@ -6478,7 +6508,7 @@ static void mysql_init_variables(void)
|
||||
protocol_version= PROTOCOL_VERSION;
|
||||
what_to_log= ~ (1L << (uint) COM_TIME);
|
||||
refresh_version= flush_version= 1L; /* Increments on each reload */
|
||||
query_id= thread_id= 1L;
|
||||
global_query_id= thread_id= 1L;
|
||||
strmov(server_version, MYSQL_SERVER_VERSION);
|
||||
myisam_recover_options_str= sql_mode_str= "OFF";
|
||||
myisam_stats_method_str= "nulls_unequal";
|
||||
@@ -6954,6 +6984,29 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
case (int) OPT_STANDALONE: /* Dummy option for NT */
|
||||
break;
|
||||
#endif
|
||||
/*
|
||||
The following change issues a deprecation warning if the slave
|
||||
configuration is specified either in the my.cnf file or on
|
||||
the command-line. See BUG#21490.
|
||||
*/
|
||||
case OPT_MASTER_HOST:
|
||||
case OPT_MASTER_USER:
|
||||
case OPT_MASTER_PASSWORD:
|
||||
case OPT_MASTER_PORT:
|
||||
case OPT_MASTER_CONNECT_RETRY:
|
||||
case OPT_MASTER_SSL:
|
||||
case OPT_MASTER_SSL_KEY:
|
||||
case OPT_MASTER_SSL_CERT:
|
||||
case OPT_MASTER_SSL_CAPATH:
|
||||
case OPT_MASTER_SSL_CIPHER:
|
||||
case OPT_MASTER_SSL_CA:
|
||||
if (!slave_warning_issued) //only show the warning once
|
||||
{
|
||||
slave_warning_issued = true;
|
||||
WARN_DEPRECATED(NULL, "5.2", "for replication startup options",
|
||||
"'CHANGE MASTER'");
|
||||
}
|
||||
break;
|
||||
case OPT_CONSOLE:
|
||||
if (opt_console)
|
||||
opt_error_log= 0; // Force logs to stdout
|
||||
@@ -7579,6 +7632,8 @@ static int test_if_case_insensitive(const char *dir_name)
|
||||
|
||||
/* Create file to store pid number */
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
|
||||
static void create_pid_file()
|
||||
{
|
||||
File file;
|
||||
@@ -7598,7 +7653,7 @@ static void create_pid_file()
|
||||
sql_perror("Can't start server: can't create PID file");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
|
||||
/* Clear most status variables */
|
||||
void refresh_status(THD *thd)
|
||||
|
Reference in New Issue
Block a user