diff options
Diffstat (limited to 'sql/set_var.cc')
-rw-r--r-- | sql/set_var.cc | 205 |
1 files changed, 155 insertions, 50 deletions
diff --git a/sql/set_var.cc b/sql/set_var.cc index b5b19f52c9e..e6c1bf94135 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -130,9 +130,11 @@ static void fix_net_read_timeout(THD *thd, enum_var_type type); static void fix_net_write_timeout(THD *thd, enum_var_type type); static void fix_net_retry_count(THD *thd, enum_var_type type); static void fix_max_join_size(THD *thd, enum_var_type type); -static void fix_query_cache_size(THD *thd, enum_var_type type); #ifdef HAVE_QUERY_CACHE +static void fix_query_cache_size(THD *thd, enum_var_type type); static void fix_query_cache_min_res_unit(THD *thd, enum_var_type type); +static int check_query_cache_type(THD *thd, set_var *var); +static void fix_query_cache_type(THD *thd, enum_var_type type); #endif static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type); static void fix_max_binlog_size(THD *thd, enum_var_type type); @@ -156,6 +158,7 @@ static bool sys_update_slow_log_path(THD *thd, set_var * var); static void sys_default_slow_log_path(THD *thd, enum_var_type type); static void fix_sys_log_slow_filter(THD *thd, enum_var_type); static uchar *get_myisam_mmap_size(THD *thd); +static uchar *in_transaction(THD *thd); static int check_max_allowed_packet(THD *thd, set_var *var); static int check_net_buffer_length(THD *thd, set_var *var); @@ -187,6 +190,9 @@ static sys_var_const sys_back_log(&vars, "back_log", OPT_GLOBAL, SHOW_LONG, (uchar*) &back_log); static sys_var_const_os_str sys_basedir(&vars, "basedir", mysql_home); +static sys_var_thd_bool +sys_binlog_annotate_row_events(&vars, "binlog_annotate_row_events", + &SV::binlog_annotate_row_events); static sys_var_long_ptr sys_binlog_cache_size(&vars, "binlog_cache_size", &binlog_cache_size); static sys_var_thd_binlog_format sys_binlog_format(&vars, "binlog_format", @@ -261,6 +267,9 @@ static sys_var_thd_ulong sys_deadlock_timeout_long(&vars, &SV::wt_timeout_long); #ifndef DBUG_OFF static sys_var_thd_dbug sys_dbug(&vars, "debug"); +static sys_var_long_ptr sys_var_debug_binlog_fsync_sleep(&vars, + "debug_binlog_fsync_sleep", + &opt_binlog_dbug_fsync_sleep); #endif static sys_var_enum sys_delay_key_write(&vars, "delay_key_write", &delay_key_write_options, @@ -325,6 +334,11 @@ static sys_var_thd_ulong sys_interactive_timeout(&vars, "interactive_timeout", &SV::net_interactive_timeout); static sys_var_thd_ulong sys_join_buffer_size(&vars, "join_buffer_size", &SV::join_buff_size); +static sys_var_thd_ulonglong sys_join_buffer_space_limit(&vars, + "join_buffer_space_limit", + &SV::join_buff_space_limit); +static sys_var_thd_ulong sys_join_cache_level(&vars, "join_cache_level", + &SV::join_cache_level); static sys_var_key_buffer_size sys_key_buffer_size(&vars, "key_buffer_size"); static sys_var_key_cache_long sys_key_cache_block_size(&vars, "key_cache_block_size", @@ -461,8 +475,6 @@ static sys_var_long_ptr sys_max_write_lock_count(&vars, "max_write_lock_count", &max_write_lock_count); static sys_var_thd_ulong sys_min_examined_row_limit(&vars, "min_examined_row_limit", &SV::min_examined_row_limit); -static sys_var_thd_ulong sys_multi_range_count(&vars, "multi_range_count", - &SV::multi_range_count); static sys_var_long_ptr sys_myisam_data_pointer_size(&vars, "myisam_data_pointer_size", &myisam_data_pointer_size); static sys_var_thd_ulonglong sys_myisam_max_sort_file_size(&vars, "myisam_max_sort_file_size", &SV::myisam_max_sort_file_size, fix_myisam_max_sort_file_size, 1); @@ -520,6 +532,11 @@ static sys_var_thd_ulong sys_optimizer_search_depth(&vars, "optimizer_sea &SV::optimizer_search_depth); static sys_var_thd_optimizer_switch sys_optimizer_switch(&vars, "optimizer_switch", &SV::optimizer_switch); + +static sys_var_thd_ulong sys_progress_report_time(&vars, + "progress_report_time", + &SV::progress_report_time); + static sys_var_const sys_pid_file(&vars, "pid_file", OPT_GLOBAL, SHOW_CHAR, (uchar*) pidfile_name); @@ -543,16 +560,18 @@ static sys_var_bool_ptr sys_userstat(&vars, "userstat", static sys_var_thd_ulong sys_read_rnd_buff_size(&vars, "read_rnd_buffer_size", &SV::read_rnd_buff_size); +static sys_var_thd_ulong sys_mrr_buff_size(&vars, "mrr_buffer_size", + &SV::mrr_buff_size); static sys_var_thd_ulong sys_div_precincrement(&vars, "div_precision_increment", &SV::div_precincrement); static sys_var_long_ptr sys_rpl_recovery_rank(&vars, "rpl_recovery_rank", &rpl_recovery_rank); -static sys_var_long_ptr sys_query_cache_size(&vars, "query_cache_size", - &query_cache_size, - fix_query_cache_size); static sys_var_thd_ulong sys_range_alloc_block_size(&vars, "range_alloc_block_size", &SV::range_alloc_block_size); +static sys_var_thd_ulong sys_rowid_merge_buff_size(&vars, "rowid_merge_buff_size", + &SV::rowid_merge_buff_size); + static sys_var_thd_ulong sys_query_alloc_block_size(&vars, "query_alloc_block_size", &SV::query_alloc_block_size, 0, fix_thd_mem_root); @@ -614,17 +633,25 @@ sys_var_enum_const sys_thread_handling(&vars, "thread_handling", &thread_handling_typelib); #ifdef HAVE_QUERY_CACHE +static sys_var_long_ptr sys_query_cache_size(&vars, "query_cache_size", + &query_cache_size, + fix_query_cache_size); static sys_var_long_ptr sys_query_cache_limit(&vars, "query_cache_limit", - &query_cache.query_cache_limit); -static sys_var_long_ptr sys_query_cache_min_res_unit(&vars, "query_cache_min_res_unit", - &query_cache_min_res_unit, - fix_query_cache_min_res_unit); + &query_cache.query_cache_limit); +static sys_var_long_ptr + sys_query_cache_min_res_unit(&vars, "query_cache_min_res_unit", + &query_cache_min_res_unit, + fix_query_cache_min_res_unit); static sys_var_thd_enum sys_query_cache_type(&vars, "query_cache_type", &SV::query_cache_type, - &query_cache_type_typelib); + &query_cache_type_typelib, + fix_query_cache_type, + check_query_cache_type); static sys_var_thd_bool sys_query_cache_wlock_invalidate(&vars, "query_cache_wlock_invalidate", &SV::query_cache_wlock_invalidate); +static sys_var_bool_ptr sys_query_cache_strip_comments(&vars, "query_cache_strip_comments", + &opt_query_cache_strip_comments); #endif /* HAVE_QUERY_CACHE */ static sys_var_bool_ptr sys_secure_auth(&vars, "secure_auth", &opt_secure_auth); static sys_var_const_str_ptr sys_secure_file_priv(&vars, "secure_file_priv", @@ -980,6 +1007,12 @@ static sys_var_enum_const sys_plugin_maturity(&vars, "plugin_maturity", &plugin_maturity, &plugin_maturity_values); +static sys_var_readonly sys_in_transaction(&vars, "in_transaction", + OPT_SESSION, SHOW_BOOL, + in_transaction); + + + bool sys_var::check(THD *thd, set_var *var) { var->save_result.ulonglong_value= var->value->val_int(); @@ -1206,10 +1239,9 @@ static void fix_net_retry_count(THD *thd __attribute__((unused)), {} #endif /* HAVE_REPLICATION */ - +#ifdef HAVE_QUERY_CACHE static void fix_query_cache_size(THD *thd, enum_var_type type) { -#ifdef HAVE_QUERY_CACHE ulong new_cache_size= query_cache.resize(query_cache_size); /* @@ -1223,11 +1255,60 @@ static void fix_query_cache_size(THD *thd, enum_var_type type) query_cache_size, new_cache_size); query_cache_size= new_cache_size; -#endif } -#ifdef HAVE_QUERY_CACHE +/** + Trigger before query_cache_type variable is updated. + @param thd Thread handler + @param var Pointer to the new variable status + + @return Status code + @retval TRUE Failure + @retval FALSE Success +*/ + +static int check_query_cache_type(THD *thd, set_var *var) +{ + /* + Don't allow changes of the query_cache_type if the query cache + is disabled. + */ + if (query_cache.is_disable_in_progress()) + { + my_error(ER_QUERY_CACHE_IS_DISABLED, MYF(0)); + return TRUE; + } + if (var->type != OPT_GLOBAL && + global_system_variables.query_cache_type == 0 && + var->value->val_int() != 0) + { + my_error(ER_QUERY_CACHE_IS_GLOBALY_DISABLED, MYF(0)); + return TRUE; + } + + return FALSE; +} + + +static void fix_query_cache_type(THD *thd, enum_var_type type) +{ + if (type == OPT_GLOBAL) + { + if (global_system_variables.query_cache_type != 0 && + query_cache.is_disabled()) + { + /* if disabling in progress variable will not be set */ + DBUG_ASSERT(!query_cache.is_disable_in_progress()); + /* Enable query cache because it was disabled */ + fix_query_cache_size(thd, type); + } + else if (global_system_variables.query_cache_type == 0) + query_cache.disable_query_cache(thd); + } +} + + static void fix_query_cache_min_res_unit(THD *thd, enum_var_type type) { query_cache_min_res_unit= @@ -2835,38 +2916,43 @@ int set_var_collation_client::update(THD *thd) bool sys_var_timestamp::check(THD *thd, set_var *var) { - longlong val; - var->save_result.ulonglong_value= var->value->val_int(); - val= (longlong) var->save_result.ulonglong_value; - if (val != 0 && // this is how you set the default value - (val < TIMESTAMP_MIN_VALUE || val > TIMESTAMP_MAX_VALUE)) + ulonglong sec; + ulong sec_part; + char buf[64], *errval= 0; + if (var->value->get_seconds(&sec, &sec_part)) + errval= llstr(sec, buf); + else if (sec > TIMESTAMP_MAX_VALUE) + errval= ullstr(sec, buf); + + if (errval) { - char buf[64]; - my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), "timestamp", llstr(val, buf)); + my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), "timestamp", errval); return TRUE; } + var->save_result.ulonglong_value= hrtime_from_time(sec)+sec_part; return FALSE; } bool sys_var_timestamp::update(THD *thd, set_var *var) { - thd->set_time((time_t) var->save_result.ulonglong_value); + my_hrtime_t hrtime = { var->save_result.ulonglong_value }; + thd->set_time(hrtime); return FALSE; } void sys_var_timestamp::set_default(THD *thd, enum_var_type type) { - thd->user_time=0; + thd->user_time.val= 0; } uchar *sys_var_timestamp::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { - thd->sys_var_tmp.long_value= (long) thd->start_time; - return (uchar*) &thd->sys_var_tmp.long_value; + thd->sys_var_tmp.double_value= thd->start_time + thd->start_time_sec_part/1e6; + return (uchar*) &thd->sys_var_tmp.double_value; } @@ -3001,7 +3087,19 @@ void sys_var_thd_time_zone::set_default(THD *thd, enum_var_type type) bool sys_var_max_user_conn::check(THD *thd, set_var *var) { if (var->type == OPT_GLOBAL) + { + if (! max_user_connections_checking) + { + /* + We can't change the value of max_user_connections from 0 as then + connect counting would be wrong. + */ + my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), + "--max-user-connections=0"); + return TRUE; + } return sys_var_thd::check(thd, var); + } else { /* @@ -3017,7 +3115,7 @@ bool sys_var_max_user_conn::update(THD *thd, set_var *var) { DBUG_ASSERT(var->type == OPT_GLOBAL); pthread_mutex_lock(&LOCK_global_system_variables); - max_user_connections= (uint)var->save_result.ulonglong_value; + max_user_connections= (int) var->save_result.ulonglong_value; pthread_mutex_unlock(&LOCK_global_system_variables); return 0; } @@ -3119,7 +3217,7 @@ void sys_var_thd_lc_time_names::set_default(THD *thd, enum_var_type type) } /* - Handling of microseoncds given as seconds.part_seconds + Handling of microseconds given as seconds.part_seconds NOTES The argument to long query time is in seconds in decimal @@ -3165,10 +3263,10 @@ void sys_var_microseconds::set_default(THD *thd, enum_var_type type) uchar *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { - thd->tmp_double_value= (double) ((type == OPT_GLOBAL) ? + thd->sys_var_tmp.double_value= (double) ((type == OPT_GLOBAL) ? global_system_variables.*offset : thd->variables.*offset) / 1000000.0; - return (uchar*) &thd->tmp_double_value; + return (uchar*) &thd->sys_var_tmp.double_value; } @@ -3199,35 +3297,26 @@ static bool set_option_log_bin_bit(THD *thd, set_var *var) static bool set_option_autocommit(THD *thd, set_var *var) { - /* The test is negative as the flag we use is NOT autocommit */ - - ulonglong org_options= thd->options; + ulonglong new_options= thd->options; - if (var->save_result.ulong_value != 0) - thd->options&= ~((sys_var_thd_bit*) var->var)->bit_flag; + /* The test is negative as the flag we use is NOT autocommit */ + if (var->save_result.ulong_value) + new_options&= ~OPTION_NOT_AUTOCOMMIT; else - thd->options|= ((sys_var_thd_bit*) var->var)->bit_flag; + new_options|= OPTION_NOT_AUTOCOMMIT; - if ((org_options ^ thd->options) & OPTION_NOT_AUTOCOMMIT) + if ((new_options ^ thd->options) & OPTION_NOT_AUTOCOMMIT) { - if ((org_options & OPTION_NOT_AUTOCOMMIT)) + if ((thd->options & OPTION_NOT_AUTOCOMMIT)) { - /* We changed to auto_commit mode */ - if (thd->transaction.xid_state.xa_state != XA_NOTR) - { - thd->options= org_options; - my_error(ER_XAER_RMFAIL, MYF(0), - xa_state_names[thd->transaction.xid_state.xa_state]); + if (end_active_trans(thd)) return 1; - } - thd->options&= ~(ulonglong) (OPTION_BEGIN | OPTION_KEEP_LOG); - thd->transaction.all.modified_non_trans_table= FALSE; thd->server_status|= SERVER_STATUS_AUTOCOMMIT; - if (ha_commit(thd)) - return 1; + thd->options= new_options; } else { + thd->options= new_options; thd->transaction.all.modified_non_trans_table= FALSE; thd->server_status&= ~SERVER_STATUS_AUTOCOMMIT; } @@ -3329,6 +3418,12 @@ static uchar *get_myisam_mmap_size(THD *thd) return (uchar *)&myisam_mmap_size; } +static uchar *in_transaction(THD *thd) +{ + thd->sys_var_tmp.my_bool_value= + test(thd->server_status & SERVER_STATUS_IN_TRANS); + return (uchar*) &thd->sys_var_tmp.my_bool_value; +} /**************************************************************************** Main handling of variables: @@ -3651,6 +3746,16 @@ bool not_all_support_one_shot(List<set_var_base> *var_list) Functions to handle SET mysql_internal_variable=const_expr *****************************************************************************/ +/** + Verify that the supplied value is correct. + + @param thd Thread handler + + @return status code + @retval -1 Failure + @retval 0 Success +*/ + int set_var::check(THD *thd) { if (var->is_readonly()) @@ -4044,7 +4149,7 @@ bool sys_var_thd_optimizer_switch:: symbolic_mode_representation(THD *thd, ulonglong val, LEX_STRING *rep) { - char buff[STRING_BUFFER_USUAL_SIZE*8]; + char buff[STRING_BUFFER_USUAL_SIZE*18]; String tmp(buff, sizeof(buff), &my_charset_latin1); int i; ulonglong bit; |