Commit d10b3b01 authored by Sergei Golubchik's avatar Sergei Golubchik Committed by Monty

remove SHOW_OPTIMIZER_COST

avoid contaminating SHOW code with sysvar implementation details.
And no hard-coded factor either.
parent affab99c
......@@ -5920,7 +5920,6 @@ bool Item_func_get_system_var::fix_length_and_dec(THD *thd)
decimals=0;
break;
case SHOW_DOUBLE:
case SHOW_OPTIMIZER_COST:
decimals= 6;
collation= DTCollation_numeric();
fix_char_length(DBL_DIG + 6);
......@@ -5978,7 +5977,6 @@ const Type_handler *Item_func_get_system_var::type_handler() const
case SHOW_CHAR_PTR:
case SHOW_LEX_STRING:
return &type_handler_varchar;
case SHOW_OPTIMIZER_COST:
case SHOW_DOUBLE:
return &type_handler_double;
default:
......
......@@ -310,13 +310,7 @@ do { \
case SHOW_HA_ROWS: do_num_val (ha_rows,CMD);
#define case_for_double(CMD) \
case SHOW_DOUBLE: do_num_val (double,CMD); \
case SHOW_OPTIMIZER_COST: \
{ \
double val= ((*(double*) value) == OPTIMIZER_COST_UNDEF ? OPTIMIZER_COST_UNDEF : \
(*(double*) value) * 1000); \
CMD; \
} while (0)
case SHOW_DOUBLE: do_num_val (double,CMD);
#define case_get_string_as_lex_string \
case SHOW_CHAR: \
......
......@@ -24,7 +24,6 @@
#define SHOW_always_last SHOW_KEY_CACHE_LONG, \
SHOW_HAVE, SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, \
SHOW_LONG_NOFLUSH, SHOW_LEX_STRING, SHOW_ATOMIC_COUNTER_UINT32_T, \
SHOW_OPTIMIZER_COST, \
/* SHOW_*_STATUS must be at the end, SHOW_LONG_STATUS being first */ \
SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS, SHOW_LONGLONG_STATUS, \
SHOW_UINT32_STATUS
......
......@@ -3669,9 +3669,6 @@ const char* get_one_variable(THD *thd,
/* 6 is the default precision for '%f' in sprintf() */
end= buff + my_fcvt(*value.as_double, 6, buff, NULL);
break;
case SHOW_OPTIMIZER_COST: // Stored in 1ms, displayed in us
end= buff + my_fcvt(*value.as_double*1000, 6, buff, NULL);
break;
case SHOW_LONG_STATUS:
value.as_char= status_var_value.as_char + value.as_intptr;
/* fall through */
......
......@@ -1257,10 +1257,7 @@ class Sys_var_optimizer_cost: public Sys_var_double
substitute)
{
if (arg_cost_adjust == 1000)
{
show_val_type= SHOW_OPTIMIZER_COST; // For select @@var
option.var_type|= GET_ADJUST_VALUE;
}
cost_adjust= (double) arg_cost_adjust;
}
bool session_update(THD *thd, set_var *var)
......@@ -1281,6 +1278,22 @@ class Sys_var_optimizer_cost: public Sys_var_double
var->save_result.double_value= getopt_ulonglong2double(option.def_value)*
cost_adjust;
}
const uchar *tmp_ptr(THD *thd) const
{
if (thd->sys_var_tmp.double_value > 0)
thd->sys_var_tmp.double_value*= cost_adjust;
return (uchar*) &thd->sys_var_tmp.double_value;
}
const uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base) const
{
thd->sys_var_tmp.double_value= session_var(thd, double);
return tmp_ptr(thd);
}
const uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base) const
{
thd->sys_var_tmp.double_value= global_var(double);
return tmp_ptr(thd);
}
};
......@@ -1360,7 +1373,8 @@ class Sys_var_engine_optimizer_cost: public Sys_var_optimizer_cost
OPTIMIZER_COSTS *optimizer_costs= get_optimizer_costs(base);
if (!optimizer_costs)
optimizer_costs= &default_optimizer_costs;
return cost_var_ptr(optimizer_costs, offset);
thd->sys_var_tmp.double_value= cost_var(optimizer_costs, offset);
return tmp_ptr(thd);
}
};
......
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