summaryrefslogtreecommitdiff
path: root/sql/mysqld.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/mysqld.cc')
-rw-r--r--sql/mysqld.cc71
1 files changed, 50 insertions, 21 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 4f70c72f8ec..3c23ecd3c3d 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -47,10 +47,6 @@
#define ONE_THREAD
#endif
-#define SHUTDOWN_THD
-#define MAIN_THD
-#define SIGNAL_THD
-
#ifdef HAVE_purify
#define IF_PURIFY(A,B) (A)
#else
@@ -306,7 +302,7 @@ ulong binlog_cache_use= 0, binlog_cache_disk_use= 0;
ulong max_connections,max_used_connections,
max_connect_errors, max_user_connections = 0;
ulong thread_id=1L,current_pid;
-ulong slow_launch_threads = 0;
+ulong slow_launch_threads = 0, sync_binlog_period;
ulong expire_logs_days = 0;
ulong rpl_recovery_rank=0;
ulong my_bind_addr; /* the address we bind to */
@@ -324,12 +320,13 @@ ulonglong log_10_int[20]=
time_t start_time;
-char mysql_home[FN_REFLEN], pidfile_name[FN_REFLEN], time_zone[30];
+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_ptr= log_error_file;
char mysql_real_data_home[FN_REFLEN],
language[LIBLEN],reg_ext[FN_EXTLEN], mysql_charsets_dir[FN_REFLEN],
- max_sort_char,*mysqld_user,*mysqld_chroot, *opt_init_file,
+ *mysqld_user,*mysqld_chroot, *opt_init_file,
*opt_init_connect, *opt_init_slave,
def_ft_boolean_syntax[sizeof(ft_boolean_syntax)];
@@ -375,8 +372,8 @@ KEY_CACHE *sql_key_cache;
CHARSET_INFO *system_charset_info, *files_charset_info ;
CHARSET_INFO *national_charset_info, *table_alias_charset;
-SHOW_COMP_OPTION have_berkeley_db, have_innodb, have_isam,
- have_ndbcluster, have_example_db;
+SHOW_COMP_OPTION have_berkeley_db, have_innodb, have_isam, have_ndbcluster,
+ have_example_db, have_archive_db;
SHOW_COMP_OPTION have_raid, have_openssl, have_symlink, have_query_cache;
SHOW_COMP_OPTION have_geometry, have_rtree_keys;
SHOW_COMP_OPTION have_crypt, have_compress;
@@ -827,7 +824,6 @@ static void __cdecl kill_server(int sig_ptr)
#if defined(USE_ONE_SIGNAL_HAND) || (defined(__NETWARE__) && defined(SIGNALS_DONT_BREAK_READ))
extern "C" pthread_handler_decl(kill_server_thread,arg __attribute__((unused)))
{
- SHUTDOWN_THD;
my_thread_init(); // Initialize new thread
kill_server(0);
my_thread_end(); // Normally never reached
@@ -911,6 +907,7 @@ void clean_up(bool print_message)
if (use_slave_mask)
bitmap_free(&slave_error_mask);
#endif
+ my_tz_free();
#ifndef NO_EMBEDDED_ACCESS_CHECKS
acl_free(1);
grant_free();
@@ -1716,7 +1713,6 @@ static void init_signals(void)
signal(SIGALRM, SIG_IGN);
signal(SIGBREAK,SIG_IGN);
signal_thread = pthread_self();
- SIGNAL_THD;
}
static void start_signal_handler(void)
@@ -2116,7 +2112,6 @@ int uname(struct utsname *a)
extern "C" pthread_handler_decl(handle_shutdown,arg)
{
MSG msg;
- SHUTDOWN_THD;
my_thread_init();
/* this call should create the message queue for this thread */
@@ -2145,7 +2140,6 @@ int STDCALL handle_kill(ulong ctrl_type)
#ifdef OS2
extern "C" pthread_handler_decl(handle_shutdown,arg)
{
- SHUTDOWN_THD;
my_thread_init();
// wait semaphore
@@ -2270,9 +2264,17 @@ static int init_common_variables(const char *conf_file_name, int argc,
{
struct tm tm_tmp;
localtime_r(&start_time,&tm_tmp);
- strmov(time_zone,tzname[tm_tmp.tm_isdst != 0 ? 1 : 0]);
+ strmov(system_time_zone, tzname[tm_tmp.tm_isdst != 0 ? 1 : 0]);
}
#endif
+ /*
+ We set SYSTEM time zone as reasonable default and
+ also for failure of my_tz_init() and bootstrap mode.
+ If user explicitly set time zone with --default-time-zone
+ option we will change this value in my_tz_init().
+ */
+ global_system_variables.time_zone= my_tz_SYSTEM;
+
/*
Init mutexes for the global MYSQL_LOG objects.
@@ -2810,7 +2812,8 @@ we force server id to 2, but this MySQL server will not act as a slave.");
*/
error_handler_hook = my_message_sql;
start_signal_handler(); // Creates pidfile
- if (acl_init((THD *)0, opt_noacl))
+ if (acl_init((THD *)0, opt_noacl) ||
+ my_tz_init((THD *)0, default_tz_name, opt_bootstrap))
{
abort_loop=1;
select_thread_in_use=0;
@@ -3884,7 +3887,7 @@ enum options_mysqld
OPT_RANGE_ALLOC_BLOCK_SIZE,
OPT_QUERY_ALLOC_BLOCK_SIZE, OPT_QUERY_PREALLOC_SIZE,
OPT_TRANS_ALLOC_BLOCK_SIZE, OPT_TRANS_PREALLOC_SIZE,
- OPT_SYNC_FRM, OPT_BDB_NOSYNC,
+ OPT_SYNC_FRM, OPT_SYNC_BINLOG, OPT_BDB_NOSYNC,
OPT_ENABLE_SHARED_MEMORY,
OPT_SHARED_MEMORY_BASE_NAME,
OPT_OLD_PASSWORDS,
@@ -3897,7 +3900,8 @@ enum options_mysqld
OPT_DATE_FORMAT,
OPT_TIME_FORMAT,
OPT_DATETIME_FORMAT,
- OPT_LOG_QUERIES_NOT_USING_INDEXES
+ OPT_LOG_QUERIES_NOT_USING_INDEXES,
+ OPT_DEFAULT_TIME_ZONE
};
@@ -3959,6 +3963,12 @@ Disable with --skip-bdb (will save memory).",
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"bootstrap", OPT_BOOTSTRAP, "Used by mysql installation scripts.", 0, 0, 0,
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"character_set_server", 'C', "Set the default character set.",
+ (gptr*) &default_character_set_name, (gptr*) &default_character_set_name,
+ 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
+ {"collation_server", OPT_DEFAULT_COLLATION, "Set the default collation.",
+ (gptr*) &default_collation_name, (gptr*) &default_collation_name,
+ 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{"console", OPT_CONSOLE, "Write error output on screen; Don't remove the console window on windows.",
(gptr*) &opt_console, (gptr*) &opt_console, 0, GET_BOOL, NO_ARG, 0, 0, 0,
0, 0, 0},
@@ -3992,10 +4002,10 @@ Disable with --skip-bdb (will save memory).",
(gptr*) &des_key_file, (gptr*) &des_key_file, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
#endif /* HAVE_OPENSSL */
- {"default-character-set", 'C', "Set the default character set.",
+ {"default-character-set", 'C', "Set the default character set (Deprecated option, use character_set_server instead).",
(gptr*) &default_character_set_name, (gptr*) &default_character_set_name,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
- {"default-collation", OPT_DEFAULT_COLLATION, "Set the default collation.",
+ {"default-collation", OPT_DEFAULT_COLLATION, "Set the default collation (Deprecated option, use character_set_server instead).",
(gptr*) &default_collation_name, (gptr*) &default_collation_name,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{"default-storage-engine", OPT_STORAGE_ENGINE,
@@ -4004,6 +4014,9 @@ Disable with --skip-bdb (will save memory).",
{"default-table-type", OPT_STORAGE_ENGINE,
"(deprecated) Use default-storage-engine.", 0, 0,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"default-time-zone", OPT_DEFAULT_TIME_ZONE, "Set the default time zone.",
+ (gptr*) &default_tz_name, (gptr*) &default_tz_name,
+ 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{"delay-key-write", OPT_DELAY_KEY_WRITE, "Type of DELAY_KEY_WRITE.",
0,0,0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"delay-key-write-for-all-tables", OPT_DELAY_KEY_WRITE_ALL,
@@ -4860,6 +4873,12 @@ The minimum value for this variable is 4096.",
(gptr*) &max_system_variables.sortbuff_size, 0, GET_ULONG, REQUIRED_ARG,
MAX_SORT_MEMORY, MIN_SORT_MEMORY+MALLOC_OVERHEAD*2, ~0L, MALLOC_OVERHEAD,
1, 0},
+ {"sync-binlog", OPT_SYNC_BINLOG,
+ "Sync the binlog to disk after every #th event. \
+#=0 (the default) does no sync. Syncing slows MySQL down",
+ (gptr*) &sync_binlog_period,
+ (gptr*) &sync_binlog_period, 0, GET_ULONG, REQUIRED_ARG, 0, 0, ~0L, 0, 1,
+ 0},
{"table_cache", OPT_TABLE_CACHE,
"The number of open tables for all threads.", (gptr*) &table_cache_size,
(gptr*) &table_cache_size, 0, GET_ULONG, REQUIRED_ARG, 64, 1, 512*1024L,
@@ -5017,6 +5036,12 @@ struct show_var_st status_vars[]= {
{"Com_unlock_tables", (char*) (com_stat+(uint) SQLCOM_UNLOCK_TABLES),SHOW_LONG},
{"Com_update", (char*) (com_stat+(uint) SQLCOM_UPDATE),SHOW_LONG},
{"Com_update_multi", (char*) (com_stat+(uint) SQLCOM_UPDATE_MULTI),SHOW_LONG},
+ {"Com_prepare_sql", (char*) (com_stat+(uint) SQLCOM_PREPARE),
+ SHOW_LONG},
+ {"Com_execute_sql", (char*) (com_stat+(uint) SQLCOM_EXECUTE),
+ SHOW_LONG},
+ {"Com_dealloc_sql", (char*) (com_stat+(uint)
+ SQLCOM_DEALLOCATE_PREPARE), SHOW_LONG},
{"Connections", (char*) &thread_id, SHOW_LONG_CONST},
{"Created_tmp_disk_tables", (char*) &created_tmp_disk_tables,SHOW_LONG},
{"Created_tmp_files", (char*) &my_tmp_file_created, SHOW_LONG},
@@ -5231,7 +5256,6 @@ static void mysql_init_variables(void)
specialflag= opened_tables= created_tmp_tables= created_tmp_disk_tables= 0;
binlog_cache_use= binlog_cache_disk_use= 0;
max_used_connections= slow_launch_threads = 0;
- max_sort_char= 0;
mysqld_user= mysqld_chroot= opt_init_file= opt_bin_logname = 0;
errmesg= 0;
mysqld_unix_port= opt_mysql_tmpdir= my_bind_addr_str= NullS;
@@ -5338,6 +5362,11 @@ static void mysql_init_variables(void)
#else
have_example_db= SHOW_OPTION_NO;
#endif
+#ifdef HAVE_ARCHIVE_DB
+ have_archive_db= SHOW_OPTION_YES;
+#else
+ have_archive_db= SHOW_OPTION_NO;
+#endif
#ifdef HAVE_NDBCLUSTER_DB
have_ndbcluster=SHOW_OPTION_DISABLED;
#else
@@ -5444,7 +5473,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
mysql_data_home= mysql_real_data_home;
break;
case 'u':
- if (!mysqld_user)
+ if (!mysqld_user || !strcmp(mysqld_user, argument))
mysqld_user= argument;
else
fprintf(stderr, "Warning: Ignoring user change to '%s' because the user was set to '%s' earlier on the command line\n", argument, mysqld_user);