mirror of
https://github.com/MariaDB/server.git
synced 2025-09-02 09:41:40 +03:00
Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/my/mysql-5.0 client/mysql.cc: Auto merged client/mysql_upgrade.c: Auto merged client/mysqltest.c: Auto merged extra/yassl/include/yassl_imp.hpp: Auto merged extra/yassl/include/yassl_int.hpp: Auto merged extra/yassl/taocrypt/include/algebra.hpp: Auto merged extra/yassl/taocrypt/include/des.hpp: Auto merged extra/yassl/taocrypt/include/modes.hpp: Auto merged extra/yassl/taocrypt/src/aes.cpp: Auto merged extra/yassl/taocrypt/src/algebra.cpp: Auto merged extra/yassl/taocrypt/test/test.cpp: Auto merged include/my_sys.h: Auto merged libmysql/libmysql.c: Auto merged libmysqld/lib_sql.cc: Auto merged myisam/mi_open.c: Auto merged myisam/myisampack.c: Auto merged mysql-test/r/mysqltest.result: Auto merged mysql-test/t/mysqltest.test: Auto merged ndb/src/common/util/File.cpp: Auto merged ndb/src/common/util/socket_io.cpp: Auto merged ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp: Auto merged ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Auto merged ndb/src/kernel/blocks/dbdih/Dbdih.hpp: Auto merged ndb/src/kernel/blocks/dblqh/Dblqh.hpp: Auto merged ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: Auto merged ndb/src/kernel/blocks/dbtc/Dbtc.hpp: Auto merged ndb/src/kernel/blocks/dbtup/Dbtup.hpp: Auto merged ndb/src/mgmsrv/Services.cpp: Auto merged ndb/tools/ndb_config.cpp: Auto merged sql/field.cc: Auto merged sql/field.h: Auto merged sql/ha_ndbcluster.cc: Auto merged sql/handler.cc: Auto merged sql/item.cc: Auto merged sql/item.h: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_func.cc: Auto merged sql/item_strfunc.cc: Auto merged sql/item_subselect.h: Auto merged sql/item_sum.cc: Auto merged sql/item_timefunc.cc: Auto merged sql/mysql_priv.h: Auto merged sql/mysqld.cc: Auto merged sql/opt_range.cc: Auto merged sql/set_var.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_load.cc: Auto merged sql-common/my_time.c: Auto merged sql/sql_string.h: Auto merged sql/sql_table.cc: Auto merged sql/sql_trigger.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/table.cc: Auto merged strings/strtod.c: Auto merged tests/mysql_client_test.c: Auto merged extra/yassl/taocrypt/include/rsa.hpp: manual merge mysql-test/t/mysql.test: manual merge sql/sql_parse.cc: manual merge
This commit is contained in:
100
sql/mysqld.cc
100
sql/mysqld.cc
@@ -322,9 +322,13 @@ 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;
|
||||
#endif
|
||||
|
||||
static pthread_cond_t COND_thread_cache, COND_flush_thread_cache;
|
||||
|
||||
#ifdef HAVE_BERKELEY_DB
|
||||
@@ -398,7 +402,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;
|
||||
@@ -429,7 +433,7 @@ ulong expire_logs_days = 0;
|
||||
ulong rpl_recovery_rank=0;
|
||||
|
||||
double log_10[32]; /* 10 potences */
|
||||
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;
|
||||
@@ -544,7 +548,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 */
|
||||
@@ -627,7 +630,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);
|
||||
@@ -638,7 +640,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);
|
||||
@@ -649,10 +650,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
|
||||
/****************************************************************************
|
||||
@@ -841,7 +848,6 @@ static void close_connections(void)
|
||||
DBUG_PRINT("quit",("close_connections thread"));
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
#endif /*EMBEDDED_LIBRARY*/
|
||||
|
||||
|
||||
static void close_server_sock()
|
||||
@@ -884,6 +890,8 @@ static void close_server_sock()
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /*EMBEDDED_LIBRARY*/
|
||||
|
||||
|
||||
void kill_mysql(void)
|
||||
{
|
||||
@@ -969,7 +977,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
|
||||
@@ -1190,6 +1198,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
|
||||
@@ -1258,6 +1268,9 @@ static void clean_up_mutexes()
|
||||
(void) pthread_cond_destroy(&COND_manager);
|
||||
}
|
||||
|
||||
#endif /*EMBEDDED_LIBRARY*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
** Init IP and UNIX socket
|
||||
****************************************************************************/
|
||||
@@ -1292,7 +1305,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
|
||||
@@ -1300,12 +1313,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;
|
||||
}
|
||||
@@ -1318,23 +1333,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);
|
||||
@@ -1343,10 +1360,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
|
||||
@@ -1355,33 +1373,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);
|
||||
@@ -1728,6 +1747,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)
|
||||
{
|
||||
@@ -1968,6 +1988,7 @@ static void init_signals(void)
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void start_signal_handler(void)
|
||||
{
|
||||
// Save vm id of this process
|
||||
@@ -2019,6 +2040,7 @@ static void init_signals(void)
|
||||
signal_thread = pthread_self();
|
||||
}
|
||||
|
||||
|
||||
static void start_signal_handler(void)
|
||||
{}
|
||||
|
||||
@@ -2141,6 +2163,8 @@ bugs.\n");
|
||||
#define SA_NODEFER 0
|
||||
#endif
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
|
||||
static void init_signals(void)
|
||||
{
|
||||
sigset_t set;
|
||||
@@ -2213,7 +2237,6 @@ static void init_signals(void)
|
||||
}
|
||||
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
static void start_signal_handler(void)
|
||||
{
|
||||
int error;
|
||||
@@ -2381,11 +2404,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__*/
|
||||
|
||||
|
||||
@@ -2448,6 +2471,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));
|
||||
@@ -2458,6 +2482,7 @@ static void my_str_free_mysqld(void *ptr)
|
||||
{
|
||||
my_free((gptr)ptr, MYF(MY_FAE));
|
||||
}
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
|
||||
|
||||
#ifdef __WIN__
|
||||
@@ -2590,7 +2615,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();
|
||||
@@ -2606,7 +2631,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);
|
||||
|
||||
@@ -2960,6 +2985,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
|
||||
@@ -2985,6 +3012,7 @@ static void init_ssl()
|
||||
#endif /* HAVE_OPENSSL */
|
||||
}
|
||||
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
|
||||
static int init_server_components()
|
||||
{
|
||||
@@ -2996,7 +3024,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
|
||||
@@ -3225,6 +3253,7 @@ server.");
|
||||
}
|
||||
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
static void create_maintenance_thread()
|
||||
{
|
||||
if (
|
||||
@@ -3242,7 +3271,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;
|
||||
@@ -3258,9 +3286,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()
|
||||
@@ -6398,7 +6426,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";
|
||||
@@ -7489,6 +7517,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;
|
||||
@@ -7508,7 +7538,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