Commit 2010cfab authored by Sergei Golubchik's avatar Sergei Golubchik Committed by Monty

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.
parent d10b3b01
......@@ -40,7 +40,6 @@ C_MODE_START
#define GET_FLAGSET 15
#define GET_BIT 16
#define GET_ADJUST_VALUE 256
#define GET_ASK_ADDR 128
#define GET_AUTO 64
#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 *,
int *);
typedef void (*my_getopt_adjust)(const struct my_option *, void *);
extern char *disabled_my_option;
extern char *autoset_my_option;
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_error_reporter my_getopt_error_reporter;
extern my_getopt_value my_getopt_get_addr;
extern my_getopt_adjust my_getopt_adjust_value;
extern int handle_options (int *argc, char ***argv,
const struct my_option *longopts, my_get_one_option)
......
......@@ -1739,29 +1739,29 @@ old-alter-table DEFAULT
old-mode UTF8_IS_UTF8MB3
old-passwords 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-extra-pruning-depth 8
optimizer-index-block-copy-cost 3.56e-05
optimizer-key-compare-cost 1.1361e-05
optimizer-key-copy-cost 1.5685e-05
optimizer-key-lookup-cost 0.000435777
optimizer-key-next-find-cost 8.2347e-05
optimizer-index-block-copy-cost 0.0356
optimizer-key-compare-cost 0.011361
optimizer-key-copy-cost 0.015685
optimizer-key-lookup-cost 0.435777
optimizer-key-next-find-cost 0.082347
optimizer-max-sel-arg-weight 32000
optimizer-prune-level 2
optimizer-row-copy-cost 6.0866e-05
optimizer-row-lookup-cost 0.000130839
optimizer-row-next-find-cost 4.5916e-05
optimizer-rowid-compare-cost 2.653e-06
optimizer-rowid-copy-cost 2.653e-06
optimizer-scan-setup-cost 0.01
optimizer-row-copy-cost 0.060866
optimizer-row-lookup-cost 0.130839
optimizer-row-next-find-cost 0.045916
optimizer-rowid-compare-cost 0.002653
optimizer-rowid-copy-cost 0.002653
optimizer-scan-setup-cost 10
optimizer-search-depth 62
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-trace
optimizer-trace-max-mem-size 1048576
optimizer-use-condition-selectivity 4
optimizer-where-cost 3.2e-05
optimizer-where-cost 0.032
performance-schema FALSE
performance-schema-accounts-size -1
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_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, ...)
{
......@@ -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);
DBUG_RETURN(0);
......
......@@ -4863,6 +4863,25 @@ init_gtid_pos_auto_engines(void)
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) \
{ option, OPT_MYSQL_COMPATIBILITY, \
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
if (!opt_abort && ddl_log_initialize())
unireg_abort(1);
if (!opt_abort)
{
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,
(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, ...)
{
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_error_reporter= option_error_reporter;
my_getopt_adjust_value= mariadb_getopt_adjust_value;
/* prepare all_options array */
my_init_dynamic_array(PSI_INSTRUMENT_ME, &all_options, sizeof(my_option),
......
......@@ -1250,14 +1250,12 @@ class Sys_var_optimizer_cost: public Sys_var_double
on_update_function on_update_func=0,
const char *substitute=0)
: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,
on_check_func,
on_update_func,
substitute)
{
if (arg_cost_adjust == 1000)
option.var_type|= GET_ADJUST_VALUE;
cost_adjust= (double) arg_cost_adjust;
}
bool session_update(THD *thd, set_var *var)
......@@ -1275,8 +1273,7 @@ class Sys_var_optimizer_cost: public Sys_var_double
void global_save_default(THD *thd, set_var *var)
{
var->save_result.double_value= getopt_ulonglong2double(option.def_value)*
cost_adjust;
var->save_result.double_value= getopt_ulonglong2double(option.def_value);
}
const uchar *tmp_ptr(THD *thd) const
{
......@@ -1312,33 +1309,20 @@ class Sys_var_optimizer_cost: public Sys_var_double
#define COST_VAR(X) GLOBAL_VAR(default_optimizer_costs.X)
#define cost_var_ptr(KC, OFF) (((uchar*)(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
{
cost_update_function cost_update;
public:
Sys_var_engine_optimizer_cost(const char *name_arg,
const char *comment, int flag_args, ptrdiff_t off, size_t size,
CMD_LINE getopt,
double min_val, double max_val, double def_val,
long cost_adjust, PolyLock *lock= 0,
cost_update_function on_update_func= update_cost,
const char *substitute=0)
: Sys_var_optimizer_cost(name_arg, comment, flag_args, off, size,
getopt, min_val, max_val, def_val, cost_adjust,
lock, VARIABLE_NOT_IN_BINLOG, 0,
0, substitute),
cost_update(on_update_func)
0, substitute)
{
option.var_type|= GET_ASK_ADDR;
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;
LEX_CSTRING *base_name= &var->base;
OPTIMIZER_COSTS *optimizer_costs;
bool res;
/* If no basename, assume it's for the default costs */
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);
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);
return res;
return 0;
}
const uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base) const
{
......
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