diff options
Diffstat (limited to 'sql/sys_vars.cc')
-rw-r--r-- | sql/sys_vars.cc | 388 |
1 files changed, 296 insertions, 92 deletions
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 16126c471c0..1ec035f35ae 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -1,7 +1,7 @@ /* Copyright (c) 2002, 2015, Oracle and/or its affiliates. - Copyright (c) 2012, 2018, MariaDB + Copyright (c) 2012, 2018, MariaDB Corporation. - This program is free software; you can redistribute it and/or modify + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. @@ -62,6 +62,7 @@ #include "sql_repl.h" #include "opt_range.h" #include "rpl_parallel.h" +#include <ssl_compat.h> /* The rule for this file: everything should be 'static'. When a sys_var @@ -283,7 +284,7 @@ static Sys_var_long Sys_pfs_events_stages_history_size( /** Variable performance_schema_max_statement_classes. The default number of statement classes is the sum of: - - COM_END for all regular "statement/com/...", + - (COM_END - mariadb gap) for all regular "statement/com/...", - 1 for "statement/com/new_packet", for unknown enum_server_command - 1 for "statement/com/Error", for invalid enum_server_command - SQLCOM_END for all regular "statement/sql/...", @@ -295,7 +296,8 @@ static Sys_var_ulong Sys_pfs_max_statement_classes( "Maximum number of statement instruments.", PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_statement_class_sizing), CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 256), - DEFAULT((ulong) SQLCOM_END + (ulong) COM_END + 4), + DEFAULT((ulong) SQLCOM_END + + (ulong) (COM_END -(COM_MDB_GAP_END - COM_MDB_GAP_BEG + 1)) + 4), BLOCK_SIZE(1)); static Sys_var_long Sys_pfs_events_statements_history_long_size( @@ -454,17 +456,29 @@ static bool binlog_format_check(sys_var *self, THD *thd, set_var *var) /* MariaDB Galera does not support STATEMENT or MIXED binlog format currently. */ - if (WSREP(thd) && var->save_result.ulonglong_value != BINLOG_FORMAT_ROW) + if ((WSREP(thd) || opt_support_flashback) && + var->save_result.ulonglong_value != BINLOG_FORMAT_ROW) { // Push a warning to the error log. push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, - "MariaDB Galera does not support binlog format: %s", + "MariaDB Galera and flashback do not support binlog format: %s", binlog_format_names[var->save_result.ulonglong_value]); + /* + We allow setting up binlog_format other then ROW for session scope when + wsrep/flasback is enabled.This is done because of 2 reasons + 1. User might want to run pt-table-checksum. + 2. SuperUser knows what is doing :-) + For refrence:- MDEV-7322 + */ if (var->type == OPT_GLOBAL) { - WSREP_ERROR("MariaDB Galera does not support binlog format: %s", - binlog_format_names[var->save_result.ulonglong_value]); + if (WSREP(thd)) + WSREP_ERROR("MariaDB Galera does not support binlog format: %s", + binlog_format_names[var->save_result.ulonglong_value]); + else + my_error(ER_FLASHBACK_NOT_SUPPORTED,MYF(0),"binlog_format", + binlog_format_names[var->save_result.ulonglong_value]); return true; } } @@ -482,7 +496,8 @@ static bool binlog_format_check(sys_var *self, THD *thd, set_var *var) switching @@SESSION.binlog_format from MIXED to STATEMENT when there are open temp tables and we are logging in row format. */ - if (thd->temporary_tables && var->type == OPT_SESSION && + if (thd->has_thd_temporary_tables() && + var->type == OPT_SESSION && var->save_result.ulonglong_value == BINLOG_FORMAT_STMT && ((thd->variables.binlog_format == BINLOG_FORMAT_MIXED && thd->is_current_stmt_binlog_format_row()) || @@ -517,7 +532,7 @@ static Sys_var_enum Sys_binlog_format( "UDFs) or the UUID() function; for those, row-based binary logging is " "automatically used.", SESSION_VAR(binlog_format), CMD_LINE(REQUIRED_ARG, OPT_BINLOG_FORMAT), - binlog_format_names, DEFAULT(BINLOG_FORMAT_STMT), + binlog_format_names, DEFAULT(BINLOG_FORMAT_MIXED), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(binlog_format_check), ON_UPDATE(fix_binlog_format_after_update)); @@ -664,6 +679,8 @@ static Sys_var_struct Sys_character_set_client( offsetof(CHARSET_INFO, csname), DEFAULT(&default_charset_info), NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(check_cs_client), ON_UPDATE(fix_thd_charset)); +// for check changing +export sys_var *Sys_character_set_client_ptr= &Sys_character_set_client; static Sys_var_struct Sys_character_set_connection( "character_set_connection", "The character set used for " @@ -673,6 +690,8 @@ static Sys_var_struct Sys_character_set_connection( offsetof(CHARSET_INFO, csname), DEFAULT(&default_charset_info), NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(check_charset_not_null), ON_UPDATE(fix_thd_charset)); +// for check changing +export sys_var *Sys_character_set_connection_ptr= &Sys_character_set_connection; static Sys_var_struct Sys_character_set_results( "character_set_results", "The character set used for returning " @@ -680,6 +699,8 @@ static Sys_var_struct Sys_character_set_results( SESSION_VAR(character_set_results), NO_CMD_LINE, offsetof(CHARSET_INFO, csname), DEFAULT(&default_charset_info), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_charset)); +// for check changing +export sys_var *Sys_character_set_results_ptr= &Sys_character_set_results; static Sys_var_struct Sys_character_set_filesystem( "character_set_filesystem", "The filesystem character set", @@ -1156,7 +1177,7 @@ static Sys_var_ulong Sys_lock_wait_timeout( "lock_wait_timeout", "Timeout in seconds to wait for a lock before returning an error.", SESSION_VAR(lock_wait_timeout), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(1, LONG_TIMEOUT), DEFAULT(LONG_TIMEOUT), BLOCK_SIZE(1)); + VALID_RANGE(1, LONG_TIMEOUT), DEFAULT(24 * 60 * 60), BLOCK_SIZE(1)); #ifdef HAVE_MLOCKALL static Sys_var_mybool Sys_locked_in_memory( @@ -1170,6 +1191,18 @@ static Sys_var_mybool Sys_log_bin( "log_bin", "Whether the binary log is enabled", READ_ONLY GLOBAL_VAR(opt_bin_log), NO_CMD_LINE, DEFAULT(FALSE)); +static Sys_var_mybool Sys_log_bin_compress( + "log_bin_compress", "Whether the binary log can be compressed", + GLOBAL_VAR(opt_bin_log_compress), CMD_LINE(OPT_ARG), DEFAULT(FALSE)); + +/* the min length is 10, means that Begin/Commit/Rollback would never be compressed! */ +static Sys_var_uint Sys_log_bin_compress_min_len( + "log_bin_compress_min_len", + "Minimum length of sql statement(in statement mode) or record(in row mode)" + "that can be compressed.", + GLOBAL_VAR(opt_bin_log_compress_min_len), + CMD_LINE(OPT_ARG), VALID_RANGE(10, 1024), DEFAULT(256), BLOCK_SIZE(1)); + static Sys_var_mybool Sys_trust_function_creators( "log_bin_trust_function_creators", "If set to FALSE (the default), then when --log-bin is used, creation " @@ -1203,13 +1236,13 @@ static Sys_var_mybool Sys_log_slow_admin_statements( "Log slow OPTIMIZE, ANALYZE, ALTER and other administrative statements to " "the slow log if it is open.", GLOBAL_VAR(opt_log_slow_admin_statements), - CMD_LINE(OPT_ARG), DEFAULT(FALSE)); + CMD_LINE(OPT_ARG), DEFAULT(TRUE)); static Sys_var_mybool Sys_log_slow_slave_statements( "log_slow_slave_statements", "Log slow statements executed by slave thread to the slow log if it is open.", GLOBAL_VAR(opt_log_slow_slave_statements), - CMD_LINE(OPT_ARG), DEFAULT(FALSE)); + CMD_LINE(OPT_ARG), DEFAULT(TRUE)); static Sys_var_ulong Sys_log_warnings( "log_warnings", @@ -1217,7 +1250,7 @@ static Sys_var_ulong Sys_log_warnings( "Value can be between 0 and 11. Higher values mean more verbosity", SESSION_VAR(log_warnings), CMD_LINE(OPT_ARG, 'W'), - VALID_RANGE(0, UINT_MAX), DEFAULT(1), BLOCK_SIZE(1)); + VALID_RANGE(0, UINT_MAX), DEFAULT(2), BLOCK_SIZE(1)); static bool update_cached_long_query_time(sys_var *self, THD *thd, enum_var_type type) @@ -1234,8 +1267,8 @@ static bool update_cached_long_query_time(sys_var *self, THD *thd, static Sys_var_double Sys_long_query_time( "long_query_time", "Log all queries that have taken more than long_query_time seconds " - "to execute to file. The argument will be treated as a decimal value " - "with microsecond precision", + "to execute to the slow query log file. The argument will be treated " + "as a decimal value with microsecond precision", SESSION_VAR(long_query_time_double), CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, LONG_TIMEOUT), DEFAULT(10), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), @@ -1337,7 +1370,7 @@ static Sys_var_ulong Sys_max_allowed_packet( "max_allowed_packet", "Max packet length to send to or receive from the server", SESSION_VAR(max_allowed_packet), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(1024, 1024*1024*1024), DEFAULT(4*1024*1024), + VALID_RANGE(1024, 1024*1024*1024), DEFAULT(16*1024*1024), BLOCK_SIZE(1024), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_max_allowed_packet)); @@ -1448,7 +1481,7 @@ static Sys_var_ulonglong Sys_max_heap_table_size( "max_heap_table_size", "Don't allow creation of heap tables bigger than this", SESSION_VAR(max_heap_table_size), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(16384, (ulonglong)~(intptr)0), DEFAULT(16*1024*1024), + VALID_RANGE(16384, SIZE_T_MAX), DEFAULT(16*1024*1024), BLOCK_SIZE(1024)); static ulong mdl_locks_cache_size; @@ -1465,16 +1498,11 @@ static Sys_var_ulong Sys_metadata_locks_hash_instances( VALID_RANGE(1, 1024), DEFAULT(8), BLOCK_SIZE(1)); -/* - "pseudo_thread_id" variable used in the test suite to detect 32/64bit - systems. If you change it to something else then ulong then fix the tests - in mysql-test/include/have_32bit.inc and have_64bit.inc. -*/ -static Sys_var_ulong Sys_pseudo_thread_id( +static Sys_var_ulonglong Sys_pseudo_thread_id( "pseudo_thread_id", "This variable is for internal server use", SESSION_ONLY(pseudo_thread_id), - NO_CMD_LINE, VALID_RANGE(0, ULONG_MAX), DEFAULT(0), + NO_CMD_LINE, VALID_RANGE(0, ULONGLONG_MAX), DEFAULT(0), BLOCK_SIZE(1), NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(check_has_super)); @@ -1812,6 +1840,8 @@ static Sys_var_last_gtid Sys_last_gtid( "or the empty string if none.", READ_ONLY sys_var::ONLY_SESSION, NO_CMD_LINE); +export sys_var *Sys_last_gtid_ptr= &Sys_last_gtid; // for check changing + uchar * Sys_var_last_gtid::session_value_ptr(THD *thd, const LEX_STRING *base) @@ -1822,8 +1852,9 @@ Sys_var_last_gtid::session_value_ptr(THD *thd, const LEX_STRING *base) bool first= true; str.length(0); - if ((thd->last_commit_gtid.seq_no > 0 && - rpl_slave_state_tostring_helper(&str, &thd->last_commit_gtid, &first)) || + rpl_gtid gtid= thd->get_last_commit_gtid(); + if ((gtid.seq_no > 0 && + rpl_slave_state_tostring_helper(&str, >id, &first)) || !(p= thd->strmake(str.ptr(), str.length()))) { my_error(ER_OUT_OF_RESOURCES, MYF(0)); @@ -1865,6 +1896,15 @@ static Sys_var_ulong Sys_slave_parallel_threads( NOT_IN_BINLOG, ON_CHECK(check_slave_parallel_threads), ON_UPDATE(fix_slave_parallel_threads)); +/* Alias for @@slave_parallel_threads to match what MySQL 5.7 uses. */ +static Sys_var_ulong Sys_slave_parallel_workers( + "slave_parallel_workers", + "Alias for slave_parallel_threads", + GLOBAL_VAR(opt_slave_parallel_threads), CMD_LINE(REQUIRED_ARG), + VALID_RANGE(0,16383), DEFAULT(0), BLOCK_SIZE(1), NO_MUTEX_GUARD, + NOT_IN_BINLOG, ON_CHECK(check_slave_parallel_threads), + ON_UPDATE(fix_slave_parallel_threads)); + static bool check_slave_domain_parallel_threads(sys_var *self, THD *thd, set_var *var) @@ -1934,7 +1974,7 @@ Sys_var_slave_parallel_mode::global_update(THD *thd, set_var *var) if (mi->rli.slave_running) { my_error(ER_SLAVE_MUST_STOP, MYF(0), - mi->connection_name.length, mi->connection_name.str); + (int) mi->connection_name.length, mi->connection_name.str); res= true; } else @@ -2124,6 +2164,12 @@ static Sys_var_uint Sys_max_prepared_stmt_count( VALID_RANGE(0, UINT_MAX32), DEFAULT(16382), BLOCK_SIZE(1), &PLock_prepared_stmt_count); +static Sys_var_ulong Sys_max_recursive_iterations( + "max_recursive_iterations", + "Maximum number of iterations when executing recursive queries", + SESSION_VAR(max_recursive_iterations), CMD_LINE(OPT_ARG), + VALID_RANGE(0, UINT_MAX), DEFAULT(UINT_MAX), BLOCK_SIZE(1)); + static Sys_var_ulong Sys_max_sort_length( "max_sort_length", "The number of bytes to use when sorting BLOB or TEXT values (only " @@ -2280,10 +2326,10 @@ export sys_var *Sys_old_passwords_ptr= &Sys_old_passwords; // for sql_acl.cc static Sys_var_ulong Sys_open_files_limit( "open_files_limit", "If this is not 0, then mysqld will use this value to reserve file " - "descriptors to use with setrlimit(). If this value is 0 then mysqld " - "will reserve max_connections*5 or max_connections + table_cache*2 " - "(whichever is larger) number of file descriptors", - READ_ONLY GLOBAL_VAR(open_files_limit), CMD_LINE(REQUIRED_ARG), + "descriptors to use with setrlimit(). If this value is 0 or autoset " + "then mysqld will reserve max_connections*5 or max_connections + " + "table_cache*2 (whichever is larger) number of file descriptors", + AUTO_SET READ_ONLY GLOBAL_VAR(open_files_limit), CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, OS_FILE_LIMIT), DEFAULT(0), BLOCK_SIZE(1)); /// @todo change to enum @@ -2325,17 +2371,6 @@ static Sys_var_ulong Sys_optimizer_use_condition_selectivity( SESSION_VAR(optimizer_use_condition_selectivity), CMD_LINE(REQUIRED_ARG), VALID_RANGE(1, 5), DEFAULT(1), BLOCK_SIZE(1)); -/** Warns about deprecated value 63 */ -static bool fix_optimizer_search_depth(sys_var *self, THD *thd, - enum_var_type type) -{ - SV *sv= type == OPT_GLOBAL ? &global_system_variables : &thd->variables; - if (sv->optimizer_search_depth == MAX_TABLES+2) - WARN_DEPRECATED(thd, 10, 2, "optimizer-search-depth=63", - "a search depth less than 63"); - return false; -} - static Sys_var_ulong Sys_optimizer_search_depth( "optimizer_search_depth", "Maximum depth of search performed by the query optimizer. Values " @@ -2343,13 +2378,10 @@ static Sys_var_ulong Sys_optimizer_search_depth( "query plans, but take longer to compile a query. Values smaller " "than the number of tables in a relation result in faster " "optimization, but may produce very bad query plans. If set to 0, " - "the system will automatically pick a reasonable value; if set to " - "63, the optimizer will switch to the original find_best search. " - "NOTE: The value 63 and its associated behaviour is deprecated.", + "the system will automatically pick a reasonable value.", SESSION_VAR(optimizer_search_depth), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(0, MAX_TABLES+2), DEFAULT(MAX_TABLES+1), BLOCK_SIZE(1), - NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), - ON_UPDATE(fix_optimizer_search_depth)); + VALID_RANGE(0, MAX_TABLES+1), DEFAULT(MAX_TABLES+1), BLOCK_SIZE(1), + NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(0)); /* this is used in the sigsegv handler */ export const char *optimizer_switch_names[]= @@ -2376,6 +2408,7 @@ export const char *optimizer_switch_names[]= "extended_keys", "exists_to_in", "orderby_uses_equalities", + "condition_pushdown_for_derived", "default", NullS }; @@ -2429,7 +2462,7 @@ static Sys_var_uint Sys_protocol_version( "protocol_version", "The version of the client/server protocol used by the MariaDB server", READ_ONLY GLOBAL_VAR(protocol_version), CMD_LINE_HELP_ONLY, - VALID_RANGE(0, ~0), DEFAULT(PROTOCOL_VERSION), BLOCK_SIZE(1)); + VALID_RANGE(0, ~0U), DEFAULT(PROTOCOL_VERSION), BLOCK_SIZE(1)); static Sys_var_proxy_user Sys_proxy_user( "proxy_user", "The proxy user account name used when logging in", @@ -2551,6 +2584,16 @@ static Sys_var_ulong Sys_div_precincrement( SESSION_VAR(div_precincrement), CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, DECIMAL_MAX_SCALE), DEFAULT(4), BLOCK_SIZE(1)); +static Sys_var_uint Sys_eq_range_index_dive_limit( + "eq_range_index_dive_limit", + "The optimizer will use existing index statistics instead of " + "doing index dives for equality ranges if the number of equality " + "ranges for the index is larger than or equal to this number. " + "If set to 0, index dives are always used.", + SESSION_VAR(eq_range_index_dive_limit), CMD_LINE(REQUIRED_ARG), + VALID_RANGE(0, UINT_MAX32), DEFAULT(0), + BLOCK_SIZE(1)); + static Sys_var_ulong Sys_range_alloc_block_size( "range_alloc_block_size", "Allocation block size for storing ranges during optimization", @@ -2715,7 +2758,7 @@ static Sys_var_enum Sys_thread_handling( #ifdef HAVE_QUERY_CACHE static bool fix_query_cache_size(sys_var *self, THD *thd, enum_var_type type) { - ulong new_cache_size= query_cache.resize(query_cache_size); + ulong new_cache_size= query_cache.resize((ulong)query_cache_size); /* Note: query_cache_size is a global variable reflecting the requested cache size. See also query_cache_size_arg @@ -2842,7 +2885,6 @@ static bool fix_server_id(sys_var *self, THD *thd, enum_var_type type) { if (type == OPT_GLOBAL) { - server_id_supplied = 1; thd->variables.server_id= global_system_variables.server_id; /* Historically, server_id was a global variable that is exported to @@ -2859,7 +2901,7 @@ static Sys_var_ulong Sys_server_id( "Uniquely identifies the server instance in the community of " "replication partners", SESSION_VAR(server_id), CMD_LINE(REQUIRED_ARG, OPT_SERVER_ID), - VALID_RANGE(0, UINT_MAX32), DEFAULT(0), BLOCK_SIZE(1), NO_MUTEX_GUARD, + VALID_RANGE(1, UINT_MAX32), DEFAULT(1), BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_has_super), ON_UPDATE(fix_server_id)); static Sys_var_mybool Sys_slave_compressed_protocol( @@ -2978,7 +3020,7 @@ static Sys_var_ulonglong Sys_sort_buffer( VALID_RANGE(MIN_SORT_MEMORY, SIZE_T_MAX), DEFAULT(MAX_SORT_MEMORY), BLOCK_SIZE(1)); -export ulonglong expand_sql_mode(ulonglong sql_mode) +export sql_mode_t expand_sql_mode(sql_mode_t sql_mode) { if (sql_mode & MODE_ANSI) { @@ -3032,7 +3074,7 @@ export ulonglong expand_sql_mode(ulonglong sql_mode) static bool check_sql_mode(sys_var *self, THD *thd, set_var *var) { var->save_result.ulonglong_value= - expand_sql_mode(var->save_result.ulonglong_value); + (ulonglong) expand_sql_mode(var->save_result.ulonglong_value); return false; } static bool fix_sql_mode(sys_var *self, THD *thd, enum_var_type type) @@ -3069,7 +3111,8 @@ static const char *sql_mode_names[]= "PAD_CHAR_TO_FULL_LENGTH", 0 }; -export bool sql_mode_string_representation(THD *thd, ulonglong sql_mode, + +export bool sql_mode_string_representation(THD *thd, sql_mode_t sql_mode, LEX_STRING *ls) { set_to_string(thd, ls, sql_mode, sql_mode_names); @@ -3085,7 +3128,9 @@ static Sys_var_set Sys_sql_mode( "Sets the sql mode", SESSION_VAR(sql_mode), CMD_LINE(REQUIRED_ARG), sql_mode_names, - DEFAULT(MODE_NO_ENGINE_SUBSTITUTION | + DEFAULT(MODE_STRICT_TRANS_TABLES | + MODE_ERROR_FOR_DIVISION_BY_ZERO | + MODE_NO_ENGINE_SUBSTITUTION | MODE_NO_AUTO_CREATE_USER), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_sql_mode), ON_UPDATE(fix_sql_mode)); @@ -3153,6 +3198,12 @@ static Sys_var_charptr Sys_ssl_crlpath( READ_ONLY GLOBAL_VAR(opt_ssl_crlpath), SSL_OPT(OPT_SSL_CRLPATH), IN_FS_CHARSET, DEFAULT(0)); +static Sys_var_mybool Sys_standard_compliant_cte( + "standard_compliant_cte", + "Allow only CTEs compliant to SQL standard", + SESSION_VAR(only_standard_compliant_cte), CMD_LINE(OPT_ARG), + DEFAULT(TRUE)); + // why ENUM and not BOOL ? static const char *updatable_views_with_limit_names[]= {"NO", "YES", 0}; @@ -3206,18 +3257,21 @@ static Sys_var_ulong Sys_table_cache_size( BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(fix_table_open_cache)); +static Sys_var_uint Sys_table_cache_instances( + "table_open_cache_instances", "Maximum number of table cache instances", + READ_ONLY GLOBAL_VAR(tc_instances), CMD_LINE(REQUIRED_ARG), + VALID_RANGE(1, 64), DEFAULT(8), BLOCK_SIZE(1)); + static Sys_var_ulong Sys_thread_cache_size( "thread_cache_size", - "How many threads we should keep in a cache for reuse", + "How many threads we should keep in a cache for reuse. These are freed after 5 minutes of idle time", GLOBAL_VAR(thread_cache_size), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(0, 16384), DEFAULT(0), BLOCK_SIZE(1)); + VALID_RANGE(0, 16384), DEFAULT(256), BLOCK_SIZE(1)); #ifdef HAVE_POOL_OF_THREADS static bool fix_tp_max_threads(sys_var *, THD *, enum_var_type) { -#ifdef _WIN32 tp_set_max_threads(threadpool_max_threads); -#endif return false; } @@ -3230,8 +3284,6 @@ static bool fix_tp_min_threads(sys_var *, THD *, enum_var_type) } #endif - -#ifndef _WIN32 static bool check_threadpool_size(sys_var *self, THD *thd, set_var *var) { ulonglong v= var->save_result.ulonglong_value; @@ -3256,7 +3308,6 @@ static bool fix_threadpool_stall_limit(sys_var*, THD*, enum_var_type) tp_set_threadpool_stall_limit(threadpool_stall_limit); return false; } -#endif #ifdef _WIN32 static Sys_var_uint Sys_threadpool_min_threads( @@ -3267,7 +3318,24 @@ static Sys_var_uint Sys_threadpool_min_threads( NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(fix_tp_min_threads) ); -#else + +static const char *threadpool_mode_names[]={ "windows", "generic", 0 }; +static Sys_var_enum Sys_threadpool_mode( + "thread_pool_mode", + "Chose implementation of the threadpool", + READ_ONLY GLOBAL_VAR(threadpool_mode), CMD_LINE(REQUIRED_ARG), + threadpool_mode_names, DEFAULT(TP_MODE_WINDOWS) + ); +#endif + +static const char *threadpool_priority_names[]={ "high", "low", "auto", 0 }; +static Sys_var_enum Sys_thread_pool_priority( + "thread_pool_priority", + "Threadpool priority. High priority connections usually start executing earlier than low priority." + "If priority set to 'auto', the the actual priority(low or high) is determined based on whether or not connection is inside transaction.", + SESSION_VAR(threadpool_priority), CMD_LINE(REQUIRED_ARG), + threadpool_priority_names, DEFAULT(TP_PRIORITY_AUTO)); + static Sys_var_uint Sys_threadpool_idle_thread_timeout( "thread_pool_idle_timeout", "Timeout in seconds for an idle thread in the thread pool." @@ -3302,15 +3370,22 @@ static Sys_var_uint Sys_threadpool_stall_limit( NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(fix_threadpool_stall_limit) ); -#endif /* !WIN32 */ + static Sys_var_uint Sys_threadpool_max_threads( "thread_pool_max_threads", "Maximum allowed number of worker threads in the thread pool", GLOBAL_VAR(threadpool_max_threads), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(1, 65536), DEFAULT(1000), BLOCK_SIZE(1), + VALID_RANGE(1, 65536), DEFAULT(65536), BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(fix_tp_max_threads) ); + +static Sys_var_uint Sys_threadpool_threadpool_prio_kickup_timer( + "thread_pool_prio_kickup_timer", + "The number of milliseconds before a dequeued low-priority statement is moved to the high-priority queue", + GLOBAL_VAR(threadpool_prio_kickup_timer), CMD_LINE(REQUIRED_ARG), + VALID_RANGE(0, UINT_MAX), DEFAULT(1000), BLOCK_SIZE(1) +); #endif /* HAVE_POOL_OF_THREADS */ /** @@ -3362,6 +3437,20 @@ bool Sys_var_tx_read_only::session_update(THD *thd, set_var *var) { // @see Sys_var_tx_isolation::session_update() above for the rules. thd->tx_read_only= var->save_result.ulonglong_value; + +#ifndef EMBEDDED_LIBRARY + if (thd->variables.session_track_transaction_info > TX_TRACK_NONE) + { + Transaction_state_tracker *tst= (Transaction_state_tracker *) + thd->session_tracker.get_tracker(TRANSACTION_INFO_TRACKER); + + if (var->type == OPT_DEFAULT) + tst->set_read_flags(thd, + thd->tx_read_only ? TX_READ_ONLY : TX_READ_WRITE); + else + tst->set_read_flags(thd, TX_READ_INHERIT); + } +#endif //EMBEDDED_LIBRARY } return false; } @@ -3377,12 +3466,30 @@ static Sys_var_tx_read_only Sys_tx_read_only( static Sys_var_ulonglong Sys_tmp_table_size( "tmp_table_size", + "Alias for tmp_memory_table_size. " "If an internal in-memory temporary table exceeds this size, MariaDB " "will automatically convert it to an on-disk MyISAM or Aria table.", - SESSION_VAR(tmp_table_size), CMD_LINE(REQUIRED_ARG), + SESSION_VAR(tmp_memory_table_size), CMD_LINE(REQUIRED_ARG), + VALID_RANGE(1024, (ulonglong)~(intptr)0), DEFAULT(16*1024*1024), + BLOCK_SIZE(1)); + +static Sys_var_ulonglong Sys_tmp_memory_table_size( + "tmp_memory_table_size", + "If an internal in-memory temporary table exceeds this size, MariaDB " + "will automatically convert it to an on-disk MyISAM or Aria table. " + "Same as tmp_table_size.", + SESSION_VAR(tmp_memory_table_size), CMD_LINE(REQUIRED_ARG), VALID_RANGE(1024, (ulonglong)~(intptr)0), DEFAULT(16*1024*1024), BLOCK_SIZE(1)); +static Sys_var_ulonglong Sys_tmp_disk_table_size( + "tmp_disk_table_size", + "Max size for data for an internal temporary on-disk MyISAM or Aria table.", + SESSION_VAR(tmp_disk_table_size), CMD_LINE(REQUIRED_ARG), + VALID_RANGE(1024, (ulonglong)~(intptr)0), + DEFAULT((ulonglong)~(intptr)0), + BLOCK_SIZE(1)); + static Sys_var_mybool Sys_timed_mutexes( "timed_mutexes", "Specify whether to time mutexes. Deprecated, has no effect.", @@ -3390,7 +3497,6 @@ static Sys_var_mybool Sys_timed_mutexes( NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(NULL), ON_UPDATE(NULL), DEPRECATED("")); -static char *server_version_ptr; static Sys_var_charptr Sys_version( "version", "Server version number. It may also include a suffix " "with configuration or build information. -debug indicates " @@ -3425,21 +3531,32 @@ static Sys_var_charptr Sys_version_compile_os( CMD_LINE_HELP_ONLY, IN_SYSTEM_CHARSET, DEFAULT(SYSTEM_TYPE)); +static char *guess_malloc_library() +{ + if (strcmp(MALLOC_LIBRARY, "system") == 0) + { +#ifdef HAVE_DLOPEN + typedef int (*mallctl_type)(const char*, void*, size_t*, void*, size_t); + mallctl_type mallctl_func; + mallctl_func= (mallctl_type)dlsym(RTLD_DEFAULT, "mallctl"); + if (mallctl_func) + { + static char buf[128]; + char *ver; + size_t len = sizeof(ver); + mallctl_func("version", &ver, &len, NULL, 0); + strxnmov(buf, sizeof(buf)-1, "jemalloc ", ver, NULL); + return buf; + } +#endif + } + return const_cast<char*>(MALLOC_LIBRARY); +} static char *malloc_library; static Sys_var_charptr Sys_malloc_library( "version_malloc_library", "Version of the used malloc library", READ_ONLY GLOBAL_VAR(malloc_library), CMD_LINE_HELP_ONLY, - IN_SYSTEM_CHARSET, DEFAULT(MALLOC_LIBRARY)); - -#ifdef HAVE_YASSL -#include <openssl/ssl.h> -#define SSL_LIBRARY "YaSSL " YASSL_VERSION -#elif HAVE_OPENSSL -#include <openssl/crypto.h> -#define SSL_LIBRARY SSLeay_version(SSLEAY_VERSION) -#else -#error No SSL? -#endif + IN_SYSTEM_CHARSET, DEFAULT(guess_malloc_library())); static char *ssl_library; static Sys_var_charptr Sys_ssl_library( @@ -3547,7 +3664,8 @@ static bool fix_autocommit(sys_var *self, THD *thd, enum_var_type type) { thd->variables.option_bits&= ~OPTION_AUTOCOMMIT; thd->mdl_context.release_transactional_locks(); - WSREP_DEBUG("autocommit, MDL TRX lock released: %lu", thd->thread_id); + WSREP_DEBUG("autocommit, MDL TRX lock released: %lld", + (longlong) thd->thread_id); return true; } /* @@ -3746,6 +3864,12 @@ static Sys_var_bit Sys_unique_checks( REVERSE(OPTION_RELAXED_UNIQUE_CHECKS), DEFAULT(TRUE), NO_MUTEX_GUARD, IN_BINLOG); +static Sys_var_bit Sys_no_check_constraint( + "check_constraint_checks", "check_constraint_checks", + SESSION_VAR(option_bits), NO_CMD_LINE, + REVERSE(OPTION_NO_CHECK_CONSTRAINT_CHECKS), + DEFAULT(TRUE), NO_MUTEX_GUARD, IN_BINLOG); + #ifdef ENABLED_PROFILING static bool update_profiling(sys_var *self, THD *thd, enum_var_type type) { @@ -3968,9 +4092,9 @@ static Sys_var_ulong Sys_default_week_format( static Sys_var_ulonglong Sys_group_concat_max_len( "group_concat_max_len", - "The maximum length of the result of function GROUP_CONCAT()", + "The maximum length of the result of function GROUP_CONCAT()", SESSION_VAR(group_concat_max_len), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(4, SIZE_T_MAX), DEFAULT(1024), BLOCK_SIZE(1)); + VALID_RANGE(4, SIZE_T_MAX), DEFAULT(1024*1024), BLOCK_SIZE(1)); static char *glob_hostname_ptr; static Sys_var_charptr Sys_hostname( @@ -4366,7 +4490,7 @@ bool Sys_var_rpl_filter::global_update(THD *thd, set_var *var) if (mi->rli.slave_running) { my_error(ER_SLAVE_MUST_STOP, MYF(0), - mi->connection_name.length, + (int) mi->connection_name.length, mi->connection_name.str); result= true; } @@ -4569,7 +4693,7 @@ static bool update_slave_skip_counter(sys_var *self, THD *thd, Master_info *mi) { if (mi->rli.slave_running) { - my_error(ER_SLAVE_MUST_STOP, MYF(0), mi->connection_name.length, + my_error(ER_SLAVE_MUST_STOP, MYF(0), (int) mi->connection_name.length, mi->connection_name.str); return true; } @@ -4610,7 +4734,7 @@ static Sys_var_multi_source_ulonglong Sys_slave_skip_counter( static bool update_max_relay_log_size(sys_var *self, THD *thd, Master_info *mi) { mi->rli.max_relay_log_size= thd->variables.max_relay_log_size; - mi->rli.relay_log.set_max_size(mi->rli.max_relay_log_size); + mi->rli.relay_log.set_max_size((ulong)mi->rli.max_relay_log_size); return false; } @@ -4630,6 +4754,12 @@ static Sys_var_charptr Sys_slave_skip_errors( READ_ONLY GLOBAL_VAR(opt_slave_skip_errors), CMD_LINE(REQUIRED_ARG), IN_SYSTEM_CHARSET, DEFAULT(0)); +static Sys_var_ulonglong Sys_read_binlog_speed_limit( + "read_binlog_speed_limit", "Maximum speed(KB/s) to read binlog from" + " master (0 = no limit)", + GLOBAL_VAR(opt_read_binlog_speed_limit), CMD_LINE(REQUIRED_ARG), + VALID_RANGE(0, ULONG_MAX), DEFAULT(0), BLOCK_SIZE(1)); + static Sys_var_ulonglong Sys_relay_log_space_limit( "relay_log_space_limit", "Maximum space to use for all relay logs", READ_ONLY GLOBAL_VAR(relay_log_space_limit), CMD_LINE(REQUIRED_ARG), @@ -4709,8 +4839,7 @@ static bool check_locale(sys_var *self, THD *thd, set_var *var) mysql_mutex_lock(&LOCK_error_messages); res= (!locale->errmsgs->errmsgs && read_texts(ERRMSG_FILE, locale->errmsgs->language, - &locale->errmsgs->errmsgs, - ER_ERROR_LAST - ER_ERROR_FIRST + 1)); + &locale->errmsgs->errmsgs)); mysql_mutex_unlock(&LOCK_error_messages); if (res) { @@ -5193,7 +5322,7 @@ int default_regex_flags_pcre(const THD *thd) int i, res; for (i= res= 0; default_regex_flags_to_pcre[i]; i++) { - if (src & (1 << i)) + if (src & (1ULL << i)) res|= default_regex_flags_to_pcre[i]; } return res; @@ -5239,7 +5368,7 @@ static Sys_var_ulong Sys_rowid_merge_buff_size( "rowid_merge_buff_size", "The size of the buffers used [NOT] IN evaluation via partial matching", SESSION_VAR(rowid_merge_buff_size), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(0, ((ulonglong)~(intptr)0)/2), DEFAULT(8*1024*1024), + VALID_RANGE(0, LONG_MAX), DEFAULT(8*1024*1024), BLOCK_SIZE(1)); static Sys_var_mybool Sys_userstat( @@ -5254,7 +5383,7 @@ static Sys_var_mybool Sys_binlog_annotate_row_events( "Tells the master to annotate RBR events with the statement that " "caused these events", SESSION_VAR(binlog_annotate_row_events), CMD_LINE(OPT_ARG), - DEFAULT(FALSE)); + DEFAULT(TRUE)); #ifdef HAVE_REPLICATION static Sys_var_mybool Sys_replicate_annotate_row_events( @@ -5262,7 +5391,7 @@ static Sys_var_mybool Sys_replicate_annotate_row_events( "Tells the slave to write annotate rows events received from the master " "to its own binary log. Ignored if log_slave_updates is not set", READ_ONLY GLOBAL_VAR(opt_replicate_annotate_row_events), - CMD_LINE(OPT_ARG), DEFAULT(0)); + CMD_LINE(OPT_ARG), DEFAULT(TRUE)); #endif static Sys_var_ulonglong Sys_join_buffer_space_limit( @@ -5465,3 +5594,78 @@ static Sys_var_ulonglong Sys_max_thread_mem( "session variable MEM_USED", SESSION_VAR(max_mem_used), CMD_LINE(REQUIRED_ARG), VALID_RANGE(8192, ULONGLONG_MAX), DEFAULT(LONGLONG_MAX), BLOCK_SIZE(1)); + +#ifndef EMBEDDED_LIBRARY + +static Sys_var_sesvartrack Sys_track_session_sys_vars( + "session_track_system_variables", + "Track changes in registered system variables. " + "For compatibility with MySQL defaults this variable should be set to " + "\"autocommit, character_set_client, character_set_connection, " + "character_set_results, time_zone\"", + CMD_LINE(REQUIRED_ARG), IN_SYSTEM_CHARSET, + DEFAULT(""), + NO_MUTEX_GUARD); + +static bool update_session_track_schema(sys_var *self, THD *thd, + enum_var_type type) +{ + DBUG_ENTER("update_session_track_schema"); + DBUG_RETURN(thd->session_tracker.get_tracker(CURRENT_SCHEMA_TRACKER)-> + update(thd, NULL)); +} + +static Sys_var_mybool Sys_session_track_schema( + "session_track_schema", + "Track changes to the default schema.", + SESSION_VAR(session_track_schema), + CMD_LINE(OPT_ARG), DEFAULT(TRUE), + NO_MUTEX_GUARD, NOT_IN_BINLOG, + ON_CHECK(0), + ON_UPDATE(update_session_track_schema)); + + +static bool update_session_track_tx_info(sys_var *self, THD *thd, + enum_var_type type) +{ + DBUG_ENTER("update_session_track_tx_info"); + DBUG_RETURN(thd->session_tracker.get_tracker(TRANSACTION_INFO_TRACKER)-> + update(thd, NULL)); +} + +static const char *session_track_transaction_info_names[]= + { "OFF", "STATE", "CHARACTERISTICS", NullS }; + +static Sys_var_enum Sys_session_track_transaction_info( + "session_track_transaction_info", + "Track changes to the transaction attributes. OFF to disable; " + "STATE to track just transaction state (Is there an active transaction? " + "Does it have any data? etc.); CHARACTERISTICS to track transaction " + "state and report all statements needed to start a transaction with" + "the same characteristics (isolation level, read only/read write," + "snapshot - but not any work done / data modified within the " + "transaction).", + SESSION_VAR(session_track_transaction_info), + CMD_LINE(REQUIRED_ARG), session_track_transaction_info_names, + DEFAULT(0), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), + ON_UPDATE(update_session_track_tx_info)); + + +static bool update_session_track_state_change(sys_var *self, THD *thd, + enum_var_type type) +{ + DBUG_ENTER("update_session_track_state_change"); + DBUG_RETURN(thd->session_tracker.get_tracker(SESSION_STATE_CHANGE_TRACKER)-> + update(thd, NULL)); +} + +static Sys_var_mybool Sys_session_track_state_change( + "session_track_state_change", + "Track changes to the session state.", + SESSION_VAR(session_track_state_change), + CMD_LINE(OPT_ARG), DEFAULT(FALSE), + NO_MUTEX_GUARD, NOT_IN_BINLOG, + ON_CHECK(0), + ON_UPDATE(update_session_track_state_change)); + +#endif //EMBEDDED_LIBRARY |