diff options
Diffstat (limited to 'sql/mysqld.cc')
-rw-r--r-- | sql/mysqld.cc | 52 |
1 files changed, 34 insertions, 18 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 0a49eb0c7ee..301555fa3c5 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1004,7 +1004,8 @@ static PSI_cond_info all_server_conds[]= PSI_thread_key key_thread_bootstrap, key_thread_delayed_insert, key_thread_handle_manager, key_thread_main, - key_thread_one_connection, key_thread_signal_hand; + key_thread_one_connection, key_thread_signal_hand, + key_thread_slave_init; static PSI_thread_info all_server_threads[]= { @@ -1029,7 +1030,8 @@ static PSI_thread_info all_server_threads[]= { &key_thread_handle_manager, "manager", PSI_FLAG_GLOBAL}, { &key_thread_main, "main", PSI_FLAG_GLOBAL}, { &key_thread_one_connection, "one_connection", 0}, - { &key_thread_signal_hand, "signal_handler", PSI_FLAG_GLOBAL} + { &key_thread_signal_hand, "signal_handler", PSI_FLAG_GLOBAL}, + { &key_thread_slave_init, "slave_init", PSI_FLAG_GLOBAL} }; #ifdef HAVE_MMAP @@ -3416,14 +3418,25 @@ sizeof(load_default_groups)/sizeof(load_default_groups[0]); #ifndef EMBEDDED_LIBRARY -static -int -check_enough_stack_size() +/** + This function is used to check for stack overrun for pathological + cases of regular expressions and 'like' expressions. + The call to current_thd is quite expensive, so we try to avoid it + for the normal cases. + The size of each stack frame for the wildcmp() routines is ~128 bytes, + so checking *every* recursive call is not necessary. + */ +extern "C" int +check_enough_stack_size(int recurse_level) { uchar stack_top; + if (recurse_level % 16 != 0) + return 0; - return check_stack_overrun(current_thd, STACK_MIN_SIZE, - &stack_top); + THD *my_thd= current_thd; + if (my_thd != NULL) + return check_stack_overrun(my_thd, STACK_MIN_SIZE * 2, &stack_top); + return 0; } #endif @@ -3781,7 +3794,7 @@ static int init_common_variables() WideCharToMultiByte(CP_UTF8,0, wtz_name, -1, system_time_zone, sizeof(system_time_zone) - 1, NULL, NULL); #else - strmake(system_time_zone, tz_name, sizeof(system_time_zone)-1); + strmake_buf(system_time_zone, tz_name); #endif /* _WIN32 */ #endif /* HAVE_TZNAME */ @@ -4047,6 +4060,7 @@ static int init_common_variables() item_init(); #ifndef EMBEDDED_LIBRARY my_regex_init(&my_charset_latin1, check_enough_stack_size); + my_string_stack_guard= check_enough_stack_size; #else my_regex_init(&my_charset_latin1, NULL); #endif @@ -4563,11 +4577,13 @@ will be ignored as the --log-bin option is not defined."); } #endif + DBUG_ASSERT(!opt_bin_log || opt_bin_logname); + if (opt_bin_log) { /* Reports an error and aborts, if the --log-bin's path is a directory.*/ - if (opt_bin_logname && + if (opt_bin_logname[0] && opt_bin_logname[strlen(opt_bin_logname) - 1] == FN_LIBCHAR) { sql_print_error("Path '%s' is a directory name, please specify \ @@ -4589,7 +4605,7 @@ a file name for --log-bin-index option", opt_binlog_index_name); char buf[FN_REFLEN]; const char *ln; ln= mysql_bin_log.generate_name(opt_bin_logname, "-bin", 1, buf); - if (!opt_bin_logname && !opt_binlog_index_name) + if (!opt_bin_logname[0] && !opt_binlog_index_name) { /* User didn't give us info to name the binlog index file. @@ -7840,8 +7856,8 @@ static int mysql_init_variables(void) /* Set directory paths */ mysql_real_data_home_len= - strmake(mysql_real_data_home, get_relative_path(MYSQL_DATADIR), - sizeof(mysql_real_data_home)-1) - mysql_real_data_home; + strmake_buf(mysql_real_data_home, + get_relative_path(MYSQL_DATADIR)) - mysql_real_data_home; /* Replication parameters */ master_info_file= (char*) "master.info", relay_log_info_file= (char*) "relay-log.info"; @@ -7950,7 +7966,7 @@ static int mysql_init_variables(void) const char *tmpenv; if (!(tmpenv = getenv("MY_BASEDIR_VERSION"))) tmpenv = DEFAULT_MYSQL_HOME; - (void) strmake(mysql_home, tmpenv, sizeof(mysql_home)-1); + strmake_buf(mysql_home, tmpenv); #endif return 0; } @@ -7989,7 +8005,7 @@ mysqld_get_one_option(int optid, global_system_variables.tx_isolation= ISO_SERIALIZABLE; break; case 'b': - strmake(mysql_home,argument,sizeof(mysql_home)-1); + strmake_buf(mysql_home, argument); break; case 'C': if (default_collation_name == compiled_default_collation_name) @@ -8000,7 +8016,7 @@ mysqld_get_one_option(int optid, opt_log=1; break; case 'h': - strmake(mysql_real_data_home,argument, sizeof(mysql_real_data_home)-1); + strmake_buf(mysql_real_data_home, argument); /* Correct pointer set by my_getopt (for embedded library) */ mysql_real_data_home_ptr= mysql_real_data_home; break; @@ -8011,7 +8027,7 @@ mysqld_get_one_option(int optid, sql_print_warning("Ignoring user change to '%s' because the user was set to '%s' earlier on the command line\n", argument, mysqld_user); break; case 'L': - strmake(lc_messages_dir, argument, sizeof(lc_messages_dir)-1); + strmake_buf(lc_messages_dir, argument); break; case OPT_BINLOG_FORMAT: binlog_format_used= true; @@ -8804,7 +8820,7 @@ static int fix_paths(void) char *sharedir=get_relative_path(SHAREDIR); if (test_if_hard_path(sharedir)) - strmake(buff,sharedir,sizeof(buff)-1); /* purecov: tested */ + strmake_buf(buff, sharedir); /* purecov: tested */ else strxnmov(buff,sizeof(buff)-1,mysql_home,sharedir,NullS); convert_dirname(buff,buff,NullS); @@ -8812,7 +8828,7 @@ static int fix_paths(void) /* If --character-sets-dir isn't given, use shared library dir */ if (charsets_dir) - strmake(mysql_charsets_dir, charsets_dir, sizeof(mysql_charsets_dir)-1); + strmake_buf(mysql_charsets_dir, charsets_dir); else strxnmov(mysql_charsets_dir, sizeof(mysql_charsets_dir)-1, buff, CHARSET_DIR, NullS); |