Commit d8c9c5ea authored by Monty's avatar Monty

MDEV-34491 Setting log_slow_admin="" at startup should be converted to log_slow_admin=ALL

We have an issue if a user have the following in a configuration file:
log_slow_filter=""                  # Log everything to slow query log
log_queries_not_using_indexes=ON

This set log_slow_filter to 'not_using_index' which disables
slow_query_logging of most queries.
In effect, on should never use log_slow_filter="" in config files but
instead use log_slow_filter=ALL.

Fixed by changing log_slow_filter="" that comes either from a
configuration file or from the command line, when starting to the server,
to log_slow_filter=ALL.
A warning will be printed when this happens.

Other things:
- One can now use =ALL for any 'set' variable to set all options at once.
  (backported from 10.6)
parent 090cecd5
--log-slow-filter= --log_queries_not_using_indexes=0
call mtr.add_suppression("log_slow_filter=\"\" changed to log_slow_filter=ALL");
show variables like "log_slow_filter";
Variable_name Value
log_slow_filter admin,filesort,filesort_on_disk,filesort_priority_queue,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk
set @@log_slow_filter="all";
show variables like "log_slow_filter";
Variable_name Value
log_slow_filter admin,filesort,filesort_on_disk,filesort_priority_queue,full_join,full_scan,not_using_index,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk
# Test setting log_slow_filter to empty in config files
call mtr.add_suppression("log_slow_filter=\"\" changed to log_slow_filter=ALL");
show variables like "log_slow_filter";
set @@log_slow_filter="all";
show variables like "log_slow_filter";
......@@ -496,10 +496,10 @@ The following specify which files/extra groups are read (specified before remain
combination of: admin, call, slave, sp
--log-slow-filter=name
Log only certain types of queries to the slow log. If
variable empty alll kind of queries are logged. All
types are bound by slow_query_time, except
'not_using_index' which is always logged if enabled. Any
combination of: admin, filesort, filesort_on_disk,
variable empty all kind of queries are logged. All types
are bound by slow_query_time, except 'not_using_index'
which is always logged if enabled. Any combination of:
admin, filesort, filesort_on_disk,
filesort_priority_queue, full_join, full_scan,
not_using_index, query_cache, query_cache_miss, tmp_table,
tmp_table_on_disk
......
......@@ -1675,7 +1675,7 @@ COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME LOG_SLOW_FILTER
VARIABLE_SCOPE SESSION
VARIABLE_TYPE SET
VARIABLE_COMMENT Log only certain types of queries to the slow log. If variable empty alll kind of queries are logged. All types are bound by slow_query_time, except 'not_using_index' which is always logged if enabled
VARIABLE_COMMENT Log only certain types of queries to the slow log. If variable empty all kind of queries are logged. All types are bound by slow_query_time, except 'not_using_index' which is always logged if enabled
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
......
......@@ -1815,7 +1815,7 @@ COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME LOG_SLOW_FILTER
VARIABLE_SCOPE SESSION
VARIABLE_TYPE SET
VARIABLE_COMMENT Log only certain types of queries to the slow log. If variable empty alll kind of queries are logged. All types are bound by slow_query_time, except 'not_using_index' which is always logged if enabled
VARIABLE_COMMENT Log only certain types of queries to the slow log. If variable empty all kind of queries are logged. All types are bound by slow_query_time, except 'not_using_index' which is always logged if enabled
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
......
......@@ -801,6 +801,11 @@ static int setval(const struct my_option *opts, void *value, char *argument,
case GET_SET:
*((ulonglong*)value)= find_typeset(argument, opts->typelib, &err);
if (err)
{
/* Check if option 'all' is used (to set all bits) */
if (!my_strcasecmp(&my_charset_latin1, argument, "all"))
*(ulonglong*) value= ((1ULL << opts->typelib->count) - 1);
else
{
/* Accept an integer representation of the set */
char *endptr;
......@@ -811,6 +816,7 @@ static int setval(const struct my_option *opts, void *value, char *argument,
goto ret;
};
*(ulonglong*)value= arg;
}
err= 0;
}
break;
......
......@@ -8294,6 +8294,14 @@ mysqld_get_one_option(const struct my_option *opt, const char *argument,
if (argument == NULL) /* no argument */
log_error_file_ptr= const_cast<char*>("");
break;
case OPT_LOG_SLOW_FILTER:
if (argument == NULL || *argument == 0)
{
/* By default log_slow_filter_has all values except QPLAN_NOT_USING_INDEX */
global_system_variables.log_slow_filter= opt->def_value | QPLAN_NOT_USING_INDEX;
sql_print_warning("log_slow_filter=\"\" changed to log_slow_filter=ALL");
}
break;
case OPT_IGNORE_DB_DIRECTORY:
opt_ignore_db_dirs= NULL; // will be set in ignore_db_dirs_process_additions
if (*argument == 0)
......
......@@ -789,6 +789,7 @@ enum options_mysqld
OPT_KEY_CACHE_CHANGED_BLOCKS_HASH_SIZE,
OPT_LOG_BASENAME,
OPT_LOG_ERROR,
OPT_LOG_SLOW_FILTER,
OPT_LOWER_CASE_TABLE_NAMES,
OPT_PLUGIN_LOAD,
OPT_PLUGIN_LOAD_ADD,
......
......@@ -6280,8 +6280,9 @@ static const char *log_slow_filter_names[]=
static Sys_var_set Sys_log_slow_filter(
"log_slow_filter",
"Log only certain types of queries to the slow log. If variable empty alll kind of queries are logged. All types are bound by slow_query_time, except 'not_using_index' which is always logged if enabled",
SESSION_VAR(log_slow_filter), CMD_LINE(REQUIRED_ARG),
"Log only certain types of queries to the slow log. If variable empty all kind of queries are logged. All types are bound by slow_query_time, except 'not_using_index' which is always logged if enabled",
SESSION_VAR(log_slow_filter), CMD_LINE(REQUIRED_ARG,
OPT_LOG_SLOW_FILTER),
log_slow_filter_names,
/* by default we log all queries except 'not_using_index' */
DEFAULT(my_set_bits(array_elements(log_slow_filter_names)-1) &
......
......@@ -1379,6 +1379,10 @@ class Sys_var_flagset: public Sys_var_typelib
Backing store: ulonglong
*/
static const LEX_CSTRING all_clex_str= {STRING_WITH_LEN("all")};
class Sys_var_set: public Sys_var_typelib
{
public:
......@@ -1438,6 +1442,13 @@ class Sys_var_set: public Sys_var_typelib
var->save_result.ulonglong_value=
find_set(&typelib, res->ptr(), res->length(), NULL,
&error, &error_len, &not_used);
if (error_len &&
!my_charset_latin1.strnncollsp(res->ptr(), res->length(),
all_clex_str.str, all_clex_str.length))
{
var->save_result.ulonglong_value= ((1ULL << (typelib.count)) -1);
error_len= 0;
}
/*
note, we only issue an error if error_len > 0.
That is even while empty (zero-length) values are considered
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment