mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
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)
This commit is contained in:
parent
090cecd5e8
commit
d8c9c5ead6
11 changed files with 62 additions and 16 deletions
4
mysql-test/main/log_slow_filter.opt
Normal file
4
mysql-test/main/log_slow_filter.opt
Normal file
|
@ -0,0 +1,4 @@
|
|||
--log-slow-filter= --log_queries_not_using_indexes=0
|
||||
|
||||
|
||||
|
8
mysql-test/main/log_slow_filter.result
Normal file
8
mysql-test/main/log_slow_filter.result
Normal file
|
@ -0,0 +1,8 @@
|
|||
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
|
7
mysql-test/main/log_slow_filter.test
Normal file
7
mysql-test/main/log_slow_filter.test
Normal file
|
@ -0,0 +1,7 @@
|
|||
# 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
|
||||
|
|
|
@ -802,15 +802,21 @@ static int setval(const struct my_option *opts, void *value, char *argument,
|
|||
*((ulonglong*)value)= find_typeset(argument, opts->typelib, &err);
|
||||
if (err)
|
||||
{
|
||||
/* Accept an integer representation of the set */
|
||||
char *endptr;
|
||||
ulonglong arg= (ulonglong) strtol(argument, &endptr, 10);
|
||||
if (*endptr || (arg >> 1) >= (1ULL << (opts->typelib->count-1)))
|
||||
/* 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
|
||||
{
|
||||
res= EXIT_ARGUMENT_INVALID;
|
||||
goto ret;
|
||||
};
|
||||
*(ulonglong*)value= arg;
|
||||
/* Accept an integer representation of the set */
|
||||
char *endptr;
|
||||
ulonglong arg= (ulonglong) strtol(argument, &endptr, 10);
|
||||
if (*endptr || (arg >> 1) >= (1ULL << (opts->typelib->count-1)))
|
||||
{
|
||||
res= EXIT_ARGUMENT_INVALID;
|
||||
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 @@ public:
|
|||
|
||||
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 @@ public:
|
|||
var->save_result.ulonglong_value=
|
||||
find_set(&typelib, res->ptr(), res->length(), NULL,
|
||||
&error, &error_len, ¬_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
|
||||
|
|
Loading…
Reference in a new issue