mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Cleanup: changing set_handler_by_field_type(field_type()) to set_handler(type_handler()).
This gives better performance, as excludes handler-by-type lookup.
This commit is contained in:
10
sql/item.cc
10
sql/item.cc
@ -3511,7 +3511,7 @@ Item_param::Item_param(THD *thd, const LEX_CSTRING *name_arg,
|
|||||||
uint pos_in_query_arg, uint len_in_query_arg):
|
uint pos_in_query_arg, uint len_in_query_arg):
|
||||||
Item_basic_value(thd),
|
Item_basic_value(thd),
|
||||||
Rewritable_query_parameter(pos_in_query_arg, len_in_query_arg),
|
Rewritable_query_parameter(pos_in_query_arg, len_in_query_arg),
|
||||||
Type_handler_hybrid_field_type(MYSQL_TYPE_VARCHAR),
|
Type_handler_hybrid_field_type(&type_handler_varchar),
|
||||||
state(NO_VALUE),
|
state(NO_VALUE),
|
||||||
/* Don't pretend to be a literal unless value for this item is set. */
|
/* Don't pretend to be a literal unless value for this item is set. */
|
||||||
item_type(PARAM_ITEM),
|
item_type(PARAM_ITEM),
|
||||||
@ -3793,11 +3793,11 @@ bool Item_param::set_from_item(THD *thd, Item *item)
|
|||||||
switch (item->cmp_type()) {
|
switch (item->cmp_type()) {
|
||||||
case REAL_RESULT:
|
case REAL_RESULT:
|
||||||
set_double(tmp.value.m_double);
|
set_double(tmp.value.m_double);
|
||||||
set_handler_by_field_type(MYSQL_TYPE_DOUBLE);
|
set_handler(&type_handler_double);
|
||||||
break;
|
break;
|
||||||
case INT_RESULT:
|
case INT_RESULT:
|
||||||
set_int(tmp.value.m_longlong, MY_INT64_NUM_DECIMAL_DIGITS);
|
set_int(tmp.value.m_longlong, MY_INT64_NUM_DECIMAL_DIGITS);
|
||||||
set_handler_by_field_type(MYSQL_TYPE_LONGLONG);
|
set_handler(&type_handler_longlong);
|
||||||
break;
|
break;
|
||||||
case STRING_RESULT:
|
case STRING_RESULT:
|
||||||
{
|
{
|
||||||
@ -3806,7 +3806,7 @@ bool Item_param::set_from_item(THD *thd, Item *item)
|
|||||||
Exact value of max_length is not known unless data is converted to
|
Exact value of max_length is not known unless data is converted to
|
||||||
charset of connection, so we have to set it later.
|
charset of connection, so we have to set it later.
|
||||||
*/
|
*/
|
||||||
set_handler_by_field_type(MYSQL_TYPE_VARCHAR);
|
set_handler(&type_handler_varchar);
|
||||||
|
|
||||||
if (set_str(tmp.m_string.ptr(), tmp.m_string.length()))
|
if (set_str(tmp.m_string.ptr(), tmp.m_string.length()))
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
@ -3815,7 +3815,7 @@ bool Item_param::set_from_item(THD *thd, Item *item)
|
|||||||
case DECIMAL_RESULT:
|
case DECIMAL_RESULT:
|
||||||
{
|
{
|
||||||
set_decimal(&tmp.m_decimal, unsigned_flag);
|
set_decimal(&tmp.m_decimal, unsigned_flag);
|
||||||
set_handler_by_field_type(MYSQL_TYPE_NEWDECIMAL);
|
set_handler(&type_handler_newdecimal);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TIME_RESULT:
|
case TIME_RESULT:
|
||||||
|
@ -1026,7 +1026,7 @@ protected:
|
|||||||
cache_type_info(items[1], true);
|
cache_type_info(items[1], true);
|
||||||
// If both arguments are NULL, make resulting type BINARY(0).
|
// If both arguments are NULL, make resulting type BINARY(0).
|
||||||
if (items[1]->type() == NULL_ITEM)
|
if (items[1]->type() == NULL_ITEM)
|
||||||
set_handler_by_field_type(MYSQL_TYPE_STRING);
|
set_handler(&type_handler_string);
|
||||||
}
|
}
|
||||||
else if (items[1]->type() == NULL_ITEM)
|
else if (items[1]->type() == NULL_ITEM)
|
||||||
{
|
{
|
||||||
|
@ -5318,7 +5318,7 @@ void Item_func_get_user_var::fix_length_and_dec()
|
|||||||
break;
|
break;
|
||||||
case STRING_RESULT:
|
case STRING_RESULT:
|
||||||
max_length= MAX_BLOB_WIDTH - 1;
|
max_length= MAX_BLOB_WIDTH - 1;
|
||||||
set_handler_by_field_type(MYSQL_TYPE_MEDIUM_BLOB);
|
set_handler(&type_handler_medium_blob);
|
||||||
break;
|
break;
|
||||||
case DECIMAL_RESULT:
|
case DECIMAL_RESULT:
|
||||||
fix_char_length(DECIMAL_MAX_STR_LENGTH);
|
fix_char_length(DECIMAL_MAX_STR_LENGTH);
|
||||||
@ -5334,7 +5334,7 @@ void Item_func_get_user_var::fix_length_and_dec()
|
|||||||
{
|
{
|
||||||
collation.set(&my_charset_bin, DERIVATION_IMPLICIT);
|
collation.set(&my_charset_bin, DERIVATION_IMPLICIT);
|
||||||
null_value= 1;
|
null_value= 1;
|
||||||
set_handler_by_field_type(MYSQL_TYPE_LONG_BLOB);
|
set_handler(&type_handler_long_blob);
|
||||||
max_length= MAX_BLOB_WIDTH;
|
max_length= MAX_BLOB_WIDTH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1027,7 +1027,7 @@ protected:
|
|||||||
public:
|
public:
|
||||||
Item_sum_hybrid(THD *thd, Item *item_par,int sign):
|
Item_sum_hybrid(THD *thd, Item *item_par,int sign):
|
||||||
Item_sum(thd, item_par),
|
Item_sum(thd, item_par),
|
||||||
Type_handler_hybrid_field_type(MYSQL_TYPE_LONGLONG),
|
Type_handler_hybrid_field_type(&type_handler_longlong),
|
||||||
value(0), arg_cache(0), cmp(0),
|
value(0), arg_cache(0), cmp(0),
|
||||||
cmp_sign(sign), was_values(TRUE)
|
cmp_sign(sign), was_values(TRUE)
|
||||||
{ collation.set(&my_charset_bin); }
|
{ collation.set(&my_charset_bin); }
|
||||||
|
@ -243,9 +243,9 @@ bool Item_sum_hybrid_simple::fix_fields(THD *thd, Item **ref)
|
|||||||
|
|
||||||
Item *item2= args[0]->real_item();
|
Item *item2= args[0]->real_item();
|
||||||
if (item2->type() == Item::FIELD_ITEM)
|
if (item2->type() == Item::FIELD_ITEM)
|
||||||
set_handler_by_field_type(((Item_field*) item2)->field->type());
|
set_handler(item2->type_handler());
|
||||||
else if (args[0]->cmp_type() == TIME_RESULT)
|
else if (args[0]->cmp_type() == TIME_RESULT)
|
||||||
set_handler_by_field_type(item2->field_type());
|
set_handler(item2->type_handler());
|
||||||
else
|
else
|
||||||
set_handler_by_result_type(item2->result_type(),
|
set_handler_by_result_type(item2->result_type(),
|
||||||
max_length, collation.collation);
|
max_length, collation.collation);
|
||||||
|
@ -285,13 +285,13 @@ class Item_sum_hybrid_simple : public Item_sum,
|
|||||||
public:
|
public:
|
||||||
Item_sum_hybrid_simple(THD *thd, Item *arg):
|
Item_sum_hybrid_simple(THD *thd, Item *arg):
|
||||||
Item_sum(thd, arg),
|
Item_sum(thd, arg),
|
||||||
Type_handler_hybrid_field_type(MYSQL_TYPE_LONGLONG),
|
Type_handler_hybrid_field_type(&type_handler_longlong),
|
||||||
value(NULL)
|
value(NULL)
|
||||||
{ collation.set(&my_charset_bin); }
|
{ collation.set(&my_charset_bin); }
|
||||||
|
|
||||||
Item_sum_hybrid_simple(THD *thd, Item *arg1, Item *arg2):
|
Item_sum_hybrid_simple(THD *thd, Item *arg1, Item *arg2):
|
||||||
Item_sum(thd, arg1, arg2),
|
Item_sum(thd, arg1, arg2),
|
||||||
Type_handler_hybrid_field_type(MYSQL_TYPE_LONGLONG),
|
Type_handler_hybrid_field_type(&type_handler_longlong),
|
||||||
value(NULL)
|
value(NULL)
|
||||||
{ collation.set(&my_charset_bin); }
|
{ collation.set(&my_charset_bin); }
|
||||||
|
|
||||||
|
@ -2241,7 +2241,7 @@ bool Type_handler_numeric::
|
|||||||
/* MIN/MAX can return NULL for empty set indepedent of the used column */
|
/* MIN/MAX can return NULL for empty set indepedent of the used column */
|
||||||
func->maybe_null= func->null_value= true;
|
func->maybe_null= func->null_value= true;
|
||||||
if (item2->type() == Item::FIELD_ITEM)
|
if (item2->type() == Item::FIELD_ITEM)
|
||||||
func->set_handler_by_field_type(item2->field_type());
|
func->set_handler(item2->type_handler());
|
||||||
else
|
else
|
||||||
func->set_handler(handler);
|
func->set_handler(handler);
|
||||||
return false;
|
return false;
|
||||||
@ -2292,7 +2292,7 @@ bool Type_handler_string_result::
|
|||||||
if (item2->type() == Item::FIELD_ITEM)
|
if (item2->type() == Item::FIELD_ITEM)
|
||||||
{
|
{
|
||||||
// Fields: convert ENUM/SET to CHAR, preserve the type otherwise.
|
// Fields: convert ENUM/SET to CHAR, preserve the type otherwise.
|
||||||
func->set_handler_by_field_type(item->field_type());
|
func->set_handler(item->type_handler());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2259,9 +2259,6 @@ public:
|
|||||||
Type_handler_hybrid_field_type(const Type_handler *handler)
|
Type_handler_hybrid_field_type(const Type_handler *handler)
|
||||||
:m_type_handler(handler)
|
:m_type_handler(handler)
|
||||||
{ }
|
{ }
|
||||||
Type_handler_hybrid_field_type(enum_field_types type)
|
|
||||||
:m_type_handler(Type_handler::get_handler_by_field_type(type))
|
|
||||||
{ }
|
|
||||||
Type_handler_hybrid_field_type(const Type_handler_hybrid_field_type *other)
|
Type_handler_hybrid_field_type(const Type_handler_hybrid_field_type *other)
|
||||||
:m_type_handler(other->m_type_handler)
|
:m_type_handler(other->m_type_handler)
|
||||||
{ }
|
{ }
|
||||||
|
Reference in New Issue
Block a user