mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
remove GET_ADJUST_VALUE
avoid contaminating my_getopt with sysvar implementation details. adjust variable values after my_getopt, like it's done for others. this fixes --help to show correct values.
This commit is contained in:
@@ -40,7 +40,6 @@ C_MODE_START
|
|||||||
#define GET_FLAGSET 15
|
#define GET_FLAGSET 15
|
||||||
#define GET_BIT 16
|
#define GET_BIT 16
|
||||||
|
|
||||||
#define GET_ADJUST_VALUE 256
|
|
||||||
#define GET_ASK_ADDR 128
|
#define GET_ASK_ADDR 128
|
||||||
#define GET_AUTO 64
|
#define GET_AUTO 64
|
||||||
#define GET_TYPE_MASK 63
|
#define GET_TYPE_MASK 63
|
||||||
@@ -101,8 +100,6 @@ typedef my_bool (*my_get_one_option)(const struct my_option *, const char *, con
|
|||||||
typedef void *(*my_getopt_value)(const char *, uint, const struct my_option *,
|
typedef void *(*my_getopt_value)(const char *, uint, const struct my_option *,
|
||||||
int *);
|
int *);
|
||||||
|
|
||||||
typedef void (*my_getopt_adjust)(const struct my_option *, void *);
|
|
||||||
|
|
||||||
extern char *disabled_my_option;
|
extern char *disabled_my_option;
|
||||||
extern char *autoset_my_option;
|
extern char *autoset_my_option;
|
||||||
extern my_bool my_getopt_print_errors;
|
extern my_bool my_getopt_print_errors;
|
||||||
@@ -111,7 +108,6 @@ extern my_bool my_getopt_prefix_matching;
|
|||||||
extern my_bool my_handle_options_init_variables;
|
extern my_bool my_handle_options_init_variables;
|
||||||
extern my_error_reporter my_getopt_error_reporter;
|
extern my_error_reporter my_getopt_error_reporter;
|
||||||
extern my_getopt_value my_getopt_get_addr;
|
extern my_getopt_value my_getopt_get_addr;
|
||||||
extern my_getopt_adjust my_getopt_adjust_value;
|
|
||||||
|
|
||||||
extern int handle_options (int *argc, char ***argv,
|
extern int handle_options (int *argc, char ***argv,
|
||||||
const struct my_option *longopts, my_get_one_option)
|
const struct my_option *longopts, my_get_one_option)
|
||||||
|
@@ -1739,29 +1739,29 @@ old-alter-table DEFAULT
|
|||||||
old-mode UTF8_IS_UTF8MB3
|
old-mode UTF8_IS_UTF8MB3
|
||||||
old-passwords FALSE
|
old-passwords FALSE
|
||||||
old-style-user-limits FALSE
|
old-style-user-limits FALSE
|
||||||
optimizer-disk-read-cost 0.01024
|
optimizer-disk-read-cost 10.24
|
||||||
optimizer-disk-read-ratio 0.02
|
optimizer-disk-read-ratio 0.02
|
||||||
optimizer-extra-pruning-depth 8
|
optimizer-extra-pruning-depth 8
|
||||||
optimizer-index-block-copy-cost 3.56e-05
|
optimizer-index-block-copy-cost 0.0356
|
||||||
optimizer-key-compare-cost 1.1361e-05
|
optimizer-key-compare-cost 0.011361
|
||||||
optimizer-key-copy-cost 1.5685e-05
|
optimizer-key-copy-cost 0.015685
|
||||||
optimizer-key-lookup-cost 0.000435777
|
optimizer-key-lookup-cost 0.435777
|
||||||
optimizer-key-next-find-cost 8.2347e-05
|
optimizer-key-next-find-cost 0.082347
|
||||||
optimizer-max-sel-arg-weight 32000
|
optimizer-max-sel-arg-weight 32000
|
||||||
optimizer-prune-level 2
|
optimizer-prune-level 2
|
||||||
optimizer-row-copy-cost 6.0866e-05
|
optimizer-row-copy-cost 0.060866
|
||||||
optimizer-row-lookup-cost 0.000130839
|
optimizer-row-lookup-cost 0.130839
|
||||||
optimizer-row-next-find-cost 4.5916e-05
|
optimizer-row-next-find-cost 0.045916
|
||||||
optimizer-rowid-compare-cost 2.653e-06
|
optimizer-rowid-compare-cost 0.002653
|
||||||
optimizer-rowid-copy-cost 2.653e-06
|
optimizer-rowid-copy-cost 0.002653
|
||||||
optimizer-scan-setup-cost 0.01
|
optimizer-scan-setup-cost 10
|
||||||
optimizer-search-depth 62
|
optimizer-search-depth 62
|
||||||
optimizer-selectivity-sampling-limit 100
|
optimizer-selectivity-sampling-limit 100
|
||||||
optimizer-switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
|
optimizer-switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
|
||||||
optimizer-trace
|
optimizer-trace
|
||||||
optimizer-trace-max-mem-size 1048576
|
optimizer-trace-max-mem-size 1048576
|
||||||
optimizer-use-condition-selectivity 4
|
optimizer-use-condition-selectivity 4
|
||||||
optimizer-where-cost 3.2e-05
|
optimizer-where-cost 0.032
|
||||||
performance-schema FALSE
|
performance-schema FALSE
|
||||||
performance-schema-accounts-size -1
|
performance-schema-accounts-size -1
|
||||||
performance-schema-consumer-events-stages-current FALSE
|
performance-schema-consumer-events-stages-current FALSE
|
||||||
|
@@ -86,7 +86,6 @@ my_bool my_getopt_prefix_matching= 1;
|
|||||||
my_bool my_handle_options_init_variables = 1;
|
my_bool my_handle_options_init_variables = 1;
|
||||||
|
|
||||||
my_getopt_value my_getopt_get_addr= 0;
|
my_getopt_value my_getopt_get_addr= 0;
|
||||||
my_getopt_adjust my_getopt_adjust_value= 0;
|
|
||||||
|
|
||||||
static void default_reporter(enum loglevel level, const char *format, ...)
|
static void default_reporter(enum loglevel level, const char *format, ...)
|
||||||
{
|
{
|
||||||
@@ -899,9 +898,6 @@ static int setval(const struct my_option *opts, void *value, char *argument,
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts->var_type & GET_ADJUST_VALUE)
|
|
||||||
(*my_getopt_adjust_value)(opts, value);
|
|
||||||
|
|
||||||
validate_value(opts->name, argument, option_file);
|
validate_value(opts->name, argument, option_file);
|
||||||
|
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
|
@@ -4863,6 +4863,25 @@ init_gtid_pos_auto_engines(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define us_to_ms(X) if (X > 0) X/= 1000;
|
||||||
|
static int adjust_optimizer_costs(void *, OPTIMIZER_COSTS *oc, void *)
|
||||||
|
{
|
||||||
|
us_to_ms(oc->disk_read_cost);
|
||||||
|
us_to_ms(oc->index_block_copy_cost);
|
||||||
|
us_to_ms(oc->key_cmp_cost);
|
||||||
|
us_to_ms(oc->key_copy_cost);
|
||||||
|
us_to_ms(oc->key_lookup_cost);
|
||||||
|
us_to_ms(oc->key_next_find_cost);
|
||||||
|
us_to_ms(oc->row_copy_cost);
|
||||||
|
us_to_ms(oc->row_lookup_cost);
|
||||||
|
us_to_ms(oc->row_next_find_cost);
|
||||||
|
us_to_ms(oc->rowid_cmp_cost);
|
||||||
|
us_to_ms(oc->rowid_copy_cost);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#define MYSQL_COMPATIBILITY_OPTION(option) \
|
#define MYSQL_COMPATIBILITY_OPTION(option) \
|
||||||
{ option, OPT_MYSQL_COMPATIBILITY, \
|
{ option, OPT_MYSQL_COMPATIBILITY, \
|
||||||
0, 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0 }
|
0, 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0 }
|
||||||
@@ -5207,8 +5226,15 @@ static int init_server_components()
|
|||||||
|
|
||||||
tc_log= 0; // ha_initialize_handlerton() needs that
|
tc_log= 0; // ha_initialize_handlerton() needs that
|
||||||
|
|
||||||
if (!opt_abort && ddl_log_initialize())
|
if (!opt_abort)
|
||||||
unireg_abort(1);
|
{
|
||||||
|
if (ddl_log_initialize())
|
||||||
|
unireg_abort(1);
|
||||||
|
|
||||||
|
process_optimizer_costs((process_optimizer_costs_t)adjust_optimizer_costs, 0);
|
||||||
|
us_to_ms(global_system_variables.optimizer_where_cost);
|
||||||
|
us_to_ms(global_system_variables.optimizer_scan_setup_cost);
|
||||||
|
}
|
||||||
|
|
||||||
if (plugin_init(&remaining_argc, remaining_argv,
|
if (plugin_init(&remaining_argc, remaining_argv,
|
||||||
(opt_noacl ? PLUGIN_INIT_SKIP_PLUGIN_TABLE : 0) |
|
(opt_noacl ? PLUGIN_INIT_SKIP_PLUGIN_TABLE : 0) |
|
||||||
@@ -8547,31 +8573,6 @@ mysql_getopt_value(const char *name, uint length,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
mariadb_getopt_adjust_value(const struct my_option *option, void *value)
|
|
||||||
{
|
|
||||||
switch (option->id) {
|
|
||||||
case OPT_COSTS_DISK_READ_COST:
|
|
||||||
case OPT_COSTS_INDEX_BLOCK_COPY_COST:
|
|
||||||
case OPT_COSTS_KEY_CMP_COST:
|
|
||||||
case OPT_COSTS_KEY_COPY_COST:
|
|
||||||
case OPT_COSTS_KEY_LOOKUP_COST:
|
|
||||||
case OPT_COSTS_KEY_NEXT_FIND_COST:
|
|
||||||
case OPT_COSTS_DISK_READ_RATIO:
|
|
||||||
case OPT_COSTS_ROW_COPY_COST:
|
|
||||||
case OPT_COSTS_ROW_LOOKUP_COST:
|
|
||||||
case OPT_COSTS_ROW_NEXT_FIND_COST:
|
|
||||||
case OPT_COSTS_ROWID_CMP_COST:
|
|
||||||
case OPT_COSTS_ROWID_COPY_COST:
|
|
||||||
/* Value from command is line given in usec. Convert to ms */
|
|
||||||
*(double*) value= *(double*) value/1000.0;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void option_error_reporter(enum loglevel level, const char *format, ...)
|
static void option_error_reporter(enum loglevel level, const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
@@ -8610,7 +8611,6 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
|
|||||||
|
|
||||||
my_getopt_get_addr= mysql_getopt_value;
|
my_getopt_get_addr= mysql_getopt_value;
|
||||||
my_getopt_error_reporter= option_error_reporter;
|
my_getopt_error_reporter= option_error_reporter;
|
||||||
my_getopt_adjust_value= mariadb_getopt_adjust_value;
|
|
||||||
|
|
||||||
/* prepare all_options array */
|
/* prepare all_options array */
|
||||||
my_init_dynamic_array(PSI_INSTRUMENT_ME, &all_options, sizeof(my_option),
|
my_init_dynamic_array(PSI_INSTRUMENT_ME, &all_options, sizeof(my_option),
|
||||||
|
@@ -1250,14 +1250,12 @@ public:
|
|||||||
on_update_function on_update_func=0,
|
on_update_function on_update_func=0,
|
||||||
const char *substitute=0)
|
const char *substitute=0)
|
||||||
:Sys_var_double(name_arg, comment, flag_args, off, size, getopt,
|
:Sys_var_double(name_arg, comment, flag_args, off, size, getopt,
|
||||||
min_val, max_val, def_val, lock,
|
min_val, max_val, def_val * arg_cost_adjust, lock,
|
||||||
binlog_status_arg,
|
binlog_status_arg,
|
||||||
on_check_func,
|
on_check_func,
|
||||||
on_update_func,
|
on_update_func,
|
||||||
substitute)
|
substitute)
|
||||||
{
|
{
|
||||||
if (arg_cost_adjust == 1000)
|
|
||||||
option.var_type|= GET_ADJUST_VALUE;
|
|
||||||
cost_adjust= (double) arg_cost_adjust;
|
cost_adjust= (double) arg_cost_adjust;
|
||||||
}
|
}
|
||||||
bool session_update(THD *thd, set_var *var)
|
bool session_update(THD *thd, set_var *var)
|
||||||
@@ -1275,8 +1273,7 @@ public:
|
|||||||
|
|
||||||
void global_save_default(THD *thd, set_var *var)
|
void global_save_default(THD *thd, set_var *var)
|
||||||
{
|
{
|
||||||
var->save_result.double_value= getopt_ulonglong2double(option.def_value)*
|
var->save_result.double_value= getopt_ulonglong2double(option.def_value);
|
||||||
cost_adjust;
|
|
||||||
}
|
}
|
||||||
const uchar *tmp_ptr(THD *thd) const
|
const uchar *tmp_ptr(THD *thd) const
|
||||||
{
|
{
|
||||||
@@ -1312,33 +1309,20 @@ public:
|
|||||||
#define COST_VAR(X) GLOBAL_VAR(default_optimizer_costs.X)
|
#define COST_VAR(X) GLOBAL_VAR(default_optimizer_costs.X)
|
||||||
#define cost_var_ptr(KC, OFF) (((uchar*)(KC))+(OFF))
|
#define cost_var_ptr(KC, OFF) (((uchar*)(KC))+(OFF))
|
||||||
#define cost_var(KC, OFF) (*(double*)cost_var_ptr(KC, OFF))
|
#define cost_var(KC, OFF) (*(double*)cost_var_ptr(KC, OFF))
|
||||||
typedef bool (*cost_update_function)(THD *, OPTIMIZER_COSTS *, ptrdiff_t,
|
|
||||||
double, double);
|
|
||||||
|
|
||||||
static bool update_cost(THD *thd, OPTIMIZER_COSTS *key_cache,
|
|
||||||
ptrdiff_t offset, double new_value, double cost_adjust)
|
|
||||||
{
|
|
||||||
cost_var(key_cache, offset)= new_value / cost_adjust;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class Sys_var_engine_optimizer_cost: public Sys_var_optimizer_cost
|
class Sys_var_engine_optimizer_cost: public Sys_var_optimizer_cost
|
||||||
{
|
{
|
||||||
cost_update_function cost_update;
|
|
||||||
public:
|
public:
|
||||||
Sys_var_engine_optimizer_cost(const char *name_arg,
|
Sys_var_engine_optimizer_cost(const char *name_arg,
|
||||||
const char *comment, int flag_args, ptrdiff_t off, size_t size,
|
const char *comment, int flag_args, ptrdiff_t off, size_t size,
|
||||||
CMD_LINE getopt,
|
CMD_LINE getopt,
|
||||||
double min_val, double max_val, double def_val,
|
double min_val, double max_val, double def_val,
|
||||||
long cost_adjust, PolyLock *lock= 0,
|
long cost_adjust, PolyLock *lock= 0,
|
||||||
cost_update_function on_update_func= update_cost,
|
|
||||||
const char *substitute=0)
|
const char *substitute=0)
|
||||||
: Sys_var_optimizer_cost(name_arg, comment, flag_args, off, size,
|
: Sys_var_optimizer_cost(name_arg, comment, flag_args, off, size,
|
||||||
getopt, min_val, max_val, def_val, cost_adjust,
|
getopt, min_val, max_val, def_val, cost_adjust,
|
||||||
lock, VARIABLE_NOT_IN_BINLOG, 0,
|
lock, VARIABLE_NOT_IN_BINLOG, 0,
|
||||||
0, substitute),
|
0, substitute)
|
||||||
cost_update(on_update_func)
|
|
||||||
{
|
{
|
||||||
option.var_type|= GET_ASK_ADDR;
|
option.var_type|= GET_ASK_ADDR;
|
||||||
option.value= (uchar**)1; // crash me, please
|
option.value= (uchar**)1; // crash me, please
|
||||||
@@ -1351,7 +1335,6 @@ class Sys_var_engine_optimizer_cost: public Sys_var_optimizer_cost
|
|||||||
double new_value= var->save_result.double_value;
|
double new_value= var->save_result.double_value;
|
||||||
LEX_CSTRING *base_name= &var->base;
|
LEX_CSTRING *base_name= &var->base;
|
||||||
OPTIMIZER_COSTS *optimizer_costs;
|
OPTIMIZER_COSTS *optimizer_costs;
|
||||||
bool res;
|
|
||||||
|
|
||||||
/* If no basename, assume it's for the default costs */
|
/* If no basename, assume it's for the default costs */
|
||||||
if (!base_name->length)
|
if (!base_name->length)
|
||||||
@@ -1364,9 +1347,9 @@ class Sys_var_engine_optimizer_cost: public Sys_var_optimizer_cost
|
|||||||
mysql_mutex_unlock(&LOCK_optimizer_costs);
|
mysql_mutex_unlock(&LOCK_optimizer_costs);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
res= cost_update(thd, optimizer_costs, offset, new_value, cost_adjust);
|
cost_var(optimizer_costs, offset)= new_value / cost_adjust;
|
||||||
mysql_mutex_unlock(&LOCK_optimizer_costs);
|
mysql_mutex_unlock(&LOCK_optimizer_costs);
|
||||||
return res;
|
return 0;
|
||||||
}
|
}
|
||||||
const uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base) const
|
const uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base) const
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user