Commit 46239f29 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-12713 Define virtual type_handler() for all Item classes

parent 5a644e17
...@@ -729,10 +729,7 @@ class Item: public Value_source, ...@@ -729,10 +729,7 @@ class Item: public Value_source,
} }
virtual bool eq(const Item *, bool binary_cmp) const; virtual bool eq(const Item *, bool binary_cmp) const;
virtual enum_field_types field_type() const= 0; virtual enum_field_types field_type() const= 0;
virtual const Type_handler *type_handler() const virtual const Type_handler *type_handler() const= 0;
{
return Type_handler::get_handler_by_field_type(field_type());
}
const Type_handler *type_handler_for_comparison() const const Type_handler *type_handler_for_comparison() const
{ {
return type_handler()->type_handler_for_comparison(); return type_handler()->type_handler_for_comparison();
...@@ -759,6 +756,10 @@ class Item: public Value_source, ...@@ -759,6 +756,10 @@ class Item: public Value_source,
{ {
return Type_handler::string_type_handler(max_length)->field_type(); return Type_handler::string_type_handler(max_length)->field_type();
} }
const Type_handler *string_type_handler() const
{
return Type_handler::string_type_handler(max_length);
}
/* /*
Calculate the maximum length of an expression. Calculate the maximum length of an expression.
This method is used in data type aggregation for UNION, e.g.: This method is used in data type aggregation for UNION, e.g.:
...@@ -2395,6 +2396,7 @@ class Item_case_expr :public Item_sp_variable ...@@ -2395,6 +2396,7 @@ class Item_case_expr :public Item_sp_variable
inline enum Type type() const; inline enum Type type() const;
inline Item_result result_type() const; inline Item_result result_type() const;
enum_field_types field_type() const { return this_item()->field_type(); } enum_field_types field_type() const { return this_item()->field_type(); }
const Type_handler *type_handler() const { return this_item()->type_handler(); }
public: public:
/* /*
...@@ -2456,6 +2458,11 @@ class Item_name_const : public Item ...@@ -2456,6 +2458,11 @@ class Item_name_const : public Item
bool is_null(); bool is_null();
virtual void print(String *str, enum_query_type query_type); virtual void print(String *str, enum_query_type query_type);
const Type_handler *type_handler() const
{
return value_item->type_handler();
}
enum_field_types field_type() const enum_field_types field_type() const
{ {
return value_item->field_type(); return value_item->field_type();
...@@ -2617,6 +2624,11 @@ class Item_ident_for_show :public Item ...@@ -2617,6 +2624,11 @@ class Item_ident_for_show :public Item
my_decimal *val_decimal(my_decimal *dec) { return field->val_decimal(dec); } my_decimal *val_decimal(my_decimal *dec) { return field->val_decimal(dec); }
void make_field(THD *thd, Send_field *tmp_field); void make_field(THD *thd, Send_field *tmp_field);
enum_field_types field_type() const { return field->type(); } enum_field_types field_type() const { return field->type(); }
const Type_handler *type_handler() const
{
const Type_handler *handler= field->type_handler();
return handler->type_handler_for_item_field();
}
Item* get_copy(THD *thd, MEM_ROOT *mem_root) Item* get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_ident_for_show>(thd, mem_root, this); } { return get_item_copy<Item_ident_for_show>(thd, mem_root, this); }
}; };
...@@ -2916,6 +2928,7 @@ class Item_null :public Item_basic_constant ...@@ -2916,6 +2928,7 @@ class Item_null :public Item_basic_constant
bool send(Protocol *protocol, st_value *buffer); bool send(Protocol *protocol, st_value *buffer);
enum Item_result result_type () const { return STRING_RESULT; } enum Item_result result_type () const { return STRING_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_NULL; } enum_field_types field_type() const { return MYSQL_TYPE_NULL; }
const Type_handler *type_handler() const { return &type_handler_null; }
bool basic_const_item() const { return 1; } bool basic_const_item() const { return 1; }
Item *clone_item(THD *thd); Item *clone_item(THD *thd);
bool is_null() { return 1; } bool is_null() { return 1; }
...@@ -3332,6 +3345,7 @@ class Item_decimal :public Item_num ...@@ -3332,6 +3345,7 @@ class Item_decimal :public Item_num
enum Type type() const { return DECIMAL_ITEM; } enum Type type() const { return DECIMAL_ITEM; }
enum Item_result result_type () const { return DECIMAL_RESULT; } enum Item_result result_type () const { return DECIMAL_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; } enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; }
const Type_handler *type_handler() const { return &type_handler_newdecimal; }
longlong val_int(); longlong val_int();
double val_real(); double val_real();
String *val_str(String*); String *val_str(String*);
...@@ -3373,6 +3387,7 @@ class Item_float :public Item_num ...@@ -3373,6 +3387,7 @@ class Item_float :public Item_num
int save_in_field(Field *field, bool no_conversions); int save_in_field(Field *field, bool no_conversions);
enum Type type() const { return REAL_ITEM; } enum Type type() const { return REAL_ITEM; }
enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; } enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
const Type_handler *type_handler() const { return &type_handler_double; }
double val_real() { DBUG_ASSERT(fixed == 1); return value; } double val_real() { DBUG_ASSERT(fixed == 1); return value; }
longlong val_int() longlong val_int()
{ {
...@@ -3513,6 +3528,7 @@ class Item_string :public Item_basic_constant ...@@ -3513,6 +3528,7 @@ class Item_string :public Item_basic_constant
int save_in_field(Field *field, bool no_conversions); int save_in_field(Field *field, bool no_conversions);
enum Item_result result_type () const { return STRING_RESULT; } enum Item_result result_type () const { return STRING_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; } enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; }
const Type_handler *type_handler() const { return &type_handler_varchar; }
bool basic_const_item() const { return 1; } bool basic_const_item() const { return 1; }
bool eq(const Item *item, bool binary_cmp) const bool eq(const Item *item, bool binary_cmp) const
{ {
...@@ -3698,6 +3714,10 @@ class Item_return_date_time :public Item_partition_func_safe_string ...@@ -3698,6 +3714,10 @@ class Item_return_date_time :public Item_partition_func_safe_string
date_time_field_type(field_type_arg) date_time_field_type(field_type_arg)
{ decimals= 0; } { decimals= 0; }
enum_field_types field_type() const { return date_time_field_type; } enum_field_types field_type() const { return date_time_field_type; }
const Type_handler *type_handler() const
{
return Type_handler::get_handler_by_field_type(field_type());
}
}; };
...@@ -3787,6 +3807,7 @@ class Item_hex_constant: public Item_basic_constant ...@@ -3787,6 +3807,7 @@ class Item_hex_constant: public Item_basic_constant
enum Type type() const { return VARBIN_ITEM; } enum Type type() const { return VARBIN_ITEM; }
enum Item_result result_type () const { return STRING_RESULT; } enum Item_result result_type () const { return STRING_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; } enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; }
const Type_handler *type_handler() const { return &type_handler_varchar; }
virtual Item *safe_charset_converter(THD *thd, CHARSET_INFO *tocs) virtual Item *safe_charset_converter(THD *thd, CHARSET_INFO *tocs)
{ {
return const_charset_converter(thd, tocs, true); return const_charset_converter(thd, tocs, true);
...@@ -3964,6 +3985,7 @@ class Item_date_literal: public Item_temporal_literal ...@@ -3964,6 +3985,7 @@ class Item_date_literal: public Item_temporal_literal
maybe_null= !ltime->month || !ltime->day; maybe_null= !ltime->month || !ltime->day;
} }
enum_field_types field_type() const { return MYSQL_TYPE_DATE; } enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
const Type_handler *type_handler() const { return &type_handler_newdate; }
void print(String *str, enum_query_type query_type); void print(String *str, enum_query_type query_type);
Item *clone_item(THD *thd); Item *clone_item(THD *thd);
bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date); bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date);
...@@ -3985,6 +4007,7 @@ class Item_time_literal: public Item_temporal_literal ...@@ -3985,6 +4007,7 @@ class Item_time_literal: public Item_temporal_literal
fixed= 1; fixed= 1;
} }
enum_field_types field_type() const { return MYSQL_TYPE_TIME; } enum_field_types field_type() const { return MYSQL_TYPE_TIME; }
const Type_handler *type_handler() const { return &type_handler_time2; }
void print(String *str, enum_query_type query_type); void print(String *str, enum_query_type query_type);
Item *clone_item(THD *thd); Item *clone_item(THD *thd);
bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date); bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date);
...@@ -4008,6 +4031,7 @@ class Item_datetime_literal: public Item_temporal_literal ...@@ -4008,6 +4031,7 @@ class Item_datetime_literal: public Item_temporal_literal
maybe_null= !ltime->month || !ltime->day; maybe_null= !ltime->month || !ltime->day;
} }
enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; } enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; }
const Type_handler *type_handler() const { return &type_handler_datetime2; }
void print(String *str, enum_query_type query_type); void print(String *str, enum_query_type query_type);
Item *clone_item(THD *thd); Item *clone_item(THD *thd);
bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date); bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date);
...@@ -4323,6 +4347,7 @@ class Item_ref :public Item_ident ...@@ -4323,6 +4347,7 @@ class Item_ref :public Item_ident
{ return (*ref)->setup_fast_field_copier(field); } { return (*ref)->setup_fast_field_copier(field); }
enum Item_result result_type () const { return (*ref)->result_type(); } enum Item_result result_type () const { return (*ref)->result_type(); }
enum_field_types field_type() const { return (*ref)->field_type(); } enum_field_types field_type() const { return (*ref)->field_type(); }
const Type_handler *type_handler() const { return (*ref)->type_handler(); }
const Type_handler *real_type_handler() const const Type_handler *real_type_handler() const
{ return (*ref)->real_type_handler(); } { return (*ref)->real_type_handler(); }
Field *get_tmp_table_field() Field *get_tmp_table_field()
...@@ -4618,6 +4643,7 @@ class Item_cache_wrapper :public Item_result_field ...@@ -4618,6 +4643,7 @@ class Item_cache_wrapper :public Item_result_field
orig_item->fix_after_pullout(new_parent, &orig_item); orig_item->fix_after_pullout(new_parent, &orig_item);
} }
int save_in_field(Field *to, bool no_conversions); int save_in_field(Field *to, bool no_conversions);
const Type_handler *type_handler() const { return orig_item->type_handler(); }
enum Item_result result_type () const { return orig_item->result_type(); } enum Item_result result_type () const { return orig_item->result_type(); }
enum_field_types field_type() const { return orig_item->field_type(); } enum_field_types field_type() const { return orig_item->field_type(); }
table_map used_tables() const { return orig_item->used_tables(); } table_map used_tables() const { return orig_item->used_tables(); }
...@@ -5011,7 +5037,7 @@ class Item_copy :public Item, ...@@ -5011,7 +5037,7 @@ class Item_copy :public Item,
null_value=maybe_null=item->maybe_null; null_value=maybe_null=item->maybe_null;
Type_std_attributes::set(item); Type_std_attributes::set(item);
name= item->name; name= item->name;
set_handler_by_field_type(item->field_type()); set_handler(item->type_handler());
fixed= item->fixed; fixed= item->fixed;
} }
......
...@@ -1014,7 +1014,7 @@ class Item_func_case_abbreviation2 :public Item_func_case_expression ...@@ -1014,7 +1014,7 @@ class Item_func_case_abbreviation2 :public Item_func_case_expression
void cache_type_info(const Item *source, bool maybe_null_arg) void cache_type_info(const Item *source, bool maybe_null_arg)
{ {
Type_std_attributes::set(source); Type_std_attributes::set(source);
set_handler_by_field_type(source->field_type()); set_handler(source->type_handler());
maybe_null= maybe_null_arg; maybe_null= maybe_null_arg;
} }
...@@ -2767,7 +2767,6 @@ class Item_cond :public Item_bool_func ...@@ -2767,7 +2767,6 @@ class Item_cond :public Item_bool_func
Item *transform(THD *thd, Item_transformer transformer, uchar *arg); Item *transform(THD *thd, Item_transformer transformer, uchar *arg);
void traverse_cond(Cond_traverser, void *arg, traverse_order order); void traverse_cond(Cond_traverser, void *arg, traverse_order order);
void neg_arguments(THD *thd); void neg_arguments(THD *thd);
enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
Item* propagate_equal_fields(THD *, const Context &, COND_EQUAL *); Item* propagate_equal_fields(THD *, const Context &, COND_EQUAL *);
Item *compile(THD *thd, Item_analyzer analyzer, uchar **arg_p, Item *compile(THD *thd, Item_analyzer analyzer, uchar **arg_p,
Item_transformer transformer, uchar *arg_t); Item_transformer transformer, uchar *arg_t);
......
...@@ -5612,7 +5612,7 @@ enum Item_result Item_func_get_system_var::result_type() const ...@@ -5612,7 +5612,7 @@ enum Item_result Item_func_get_system_var::result_type() const
} }
enum_field_types Item_func_get_system_var::field_type() const const Type_handler *Item_func_get_system_var::type_handler() const
{ {
switch (var->show_type()) switch (var->show_type())
{ {
...@@ -5625,16 +5625,16 @@ enum_field_types Item_func_get_system_var::field_type() const ...@@ -5625,16 +5625,16 @@ enum_field_types Item_func_get_system_var::field_type() const
case SHOW_ULONG: case SHOW_ULONG:
case SHOW_ULONGLONG: case SHOW_ULONGLONG:
case SHOW_HA_ROWS: case SHOW_HA_ROWS:
return MYSQL_TYPE_LONGLONG; return &type_handler_longlong;
case SHOW_CHAR: case SHOW_CHAR:
case SHOW_CHAR_PTR: case SHOW_CHAR_PTR:
case SHOW_LEX_STRING: case SHOW_LEX_STRING:
return MYSQL_TYPE_VARCHAR; return &type_handler_varchar;
case SHOW_DOUBLE: case SHOW_DOUBLE:
return MYSQL_TYPE_DOUBLE; return &type_handler_double;
default: default:
my_error(ER_VAR_CANT_BE_READ, MYF(0), var->name.str); my_error(ER_VAR_CANT_BE_READ, MYF(0), var->name.str);
return MYSQL_TYPE_VARCHAR; // keep the compiler happy return &type_handler_varchar; // keep the compiler happy
} }
} }
...@@ -6458,6 +6458,15 @@ Item_func_sp::field_type() const ...@@ -6458,6 +6458,15 @@ Item_func_sp::field_type() const
DBUG_RETURN(sp_result_field->type()); DBUG_RETURN(sp_result_field->type());
} }
const Type_handler *Item_func_sp::type_handler() const
{
DBUG_ENTER("Item_func_sp::type_handler");
DBUG_ASSERT(sp_result_field);
// This converts ENUM/SET to STRING
const Type_handler *handler= sp_result_field->type_handler();
DBUG_RETURN(handler->type_handler_for_item_field());
}
Item_result Item_result
Item_func_sp::result_type() const Item_func_sp::result_type() const
{ {
......
...@@ -372,6 +372,7 @@ class Item_real_func :public Item_func ...@@ -372,6 +372,7 @@ class Item_real_func :public Item_func
{ DBUG_ASSERT(fixed == 1); return (longlong) rint(val_real()); } { DBUG_ASSERT(fixed == 1); return (longlong) rint(val_real()); }
enum Item_result result_type () const { return REAL_RESULT; } enum Item_result result_type () const { return REAL_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; } enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
const Type_handler *type_handler() const { return &type_handler_double; }
void fix_length_and_dec() void fix_length_and_dec()
{ decimals= NOT_FIXED_DEC; max_length= float_length(decimals); } { decimals= NOT_FIXED_DEC; max_length= float_length(decimals); }
}; };
...@@ -737,6 +738,7 @@ class Item_int_func :public Item_func ...@@ -737,6 +738,7 @@ class Item_int_func :public Item_func
String *val_str(String*str); String *val_str(String*str);
enum Item_result result_type () const { return INT_RESULT; } enum Item_result result_type () const { return INT_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; } enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
const Type_handler *type_handler() const { return &type_handler_longlong; }
void fix_length_and_dec() {} void fix_length_and_dec() {}
}; };
...@@ -909,6 +911,7 @@ class Item_decimal_typecast :public Item_func ...@@ -909,6 +911,7 @@ class Item_decimal_typecast :public Item_func
my_decimal *val_decimal(my_decimal*); my_decimal *val_decimal(my_decimal*);
enum Item_result result_type () const { return DECIMAL_RESULT; } enum Item_result result_type () const { return DECIMAL_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; } enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; }
const Type_handler *type_handler() const { return &type_handler_newdecimal; }
void fix_length_and_dec_generic() {} void fix_length_and_dec_generic() {}
void fix_length_and_dec() void fix_length_and_dec()
{ {
...@@ -932,7 +935,6 @@ class Item_double_typecast :public Item_real_func ...@@ -932,7 +935,6 @@ class Item_double_typecast :public Item_real_func
max_length= (uint32) len; max_length= (uint32) len;
} }
double val_real(); double val_real();
enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
void fix_length_and_dec_generic() { maybe_null= 1; } void fix_length_and_dec_generic() { maybe_null= 1; }
void fix_length_and_dec() void fix_length_and_dec()
{ {
...@@ -1546,6 +1548,7 @@ class Item_func_rollup_const :public Item_func ...@@ -1546,6 +1548,7 @@ class Item_func_rollup_const :public Item_func
bool const_item() const { return 0; } bool const_item() const { return 0; }
Item_result result_type() const { return args[0]->result_type(); } Item_result result_type() const { return args[0]->result_type(); }
enum_field_types field_type() const { return args[0]->field_type(); } enum_field_types field_type() const { return args[0]->field_type(); }
const Type_handler *type_handler() const { return args[0]->type_handler(); }
void fix_length_and_dec() void fix_length_and_dec()
{ {
collation= args[0]->collation; collation= args[0]->collation;
...@@ -1953,6 +1956,7 @@ class Item_func_udf_float :public Item_udf_func ...@@ -1953,6 +1956,7 @@ class Item_func_udf_float :public Item_udf_func
double val_real(); double val_real();
String *val_str(String *str); String *val_str(String *str);
enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; } enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
const Type_handler *type_handler() const { return &type_handler_double; }
void fix_length_and_dec() { fix_num_length_and_dec(); } void fix_length_and_dec() { fix_num_length_and_dec(); }
Item *get_copy(THD *thd, MEM_ROOT *mem_root) Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_udf_float>(thd, mem_root, this); } { return get_item_copy<Item_func_udf_float>(thd, mem_root, this); }
...@@ -1972,6 +1976,7 @@ class Item_func_udf_int :public Item_udf_func ...@@ -1972,6 +1976,7 @@ class Item_func_udf_int :public Item_udf_func
String *val_str(String *str); String *val_str(String *str);
enum Item_result result_type () const { return INT_RESULT; } enum Item_result result_type () const { return INT_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; } enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
const Type_handler *type_handler() const { return &type_handler_longlong; }
void fix_length_and_dec() { decimals= 0; max_length= 21; } void fix_length_and_dec() { decimals= 0; max_length= 21; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root) Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_udf_int>(thd, mem_root, this); } { return get_item_copy<Item_func_udf_int>(thd, mem_root, this); }
...@@ -1991,6 +1996,7 @@ class Item_func_udf_decimal :public Item_udf_func ...@@ -1991,6 +1996,7 @@ class Item_func_udf_decimal :public Item_udf_func
String *val_str(String *str); String *val_str(String *str);
enum Item_result result_type () const { return DECIMAL_RESULT; } enum Item_result result_type () const { return DECIMAL_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; } enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; }
const Type_handler *type_handler() const { return &type_handler_newdecimal; }
void fix_length_and_dec() { fix_num_length_and_dec(); } void fix_length_and_dec() { fix_num_length_and_dec(); }
Item *get_copy(THD *thd, MEM_ROOT *mem_root) Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_udf_decimal>(thd, mem_root, this); } { return get_item_copy<Item_func_udf_decimal>(thd, mem_root, this); }
...@@ -2031,6 +2037,7 @@ class Item_func_udf_str :public Item_udf_func ...@@ -2031,6 +2037,7 @@ class Item_func_udf_str :public Item_udf_func
} }
enum Item_result result_type () const { return STRING_RESULT; } enum Item_result result_type () const { return STRING_RESULT; }
enum_field_types field_type() const { return string_field_type(); } enum_field_types field_type() const { return string_field_type(); }
const Type_handler *type_handler() const { return string_type_handler(); }
void fix_length_and_dec(); void fix_length_and_dec();
Item *get_copy(THD *thd, MEM_ROOT *mem_root) Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_udf_str>(thd, mem_root, this); } { return get_item_copy<Item_func_udf_str>(thd, mem_root, this); }
...@@ -2360,6 +2367,7 @@ class Item_user_var_as_out_param :public Item, ...@@ -2360,6 +2367,7 @@ class Item_user_var_as_out_param :public Item,
void load_data_print(THD *thd, String *str); void load_data_print(THD *thd, String *str);
void load_data_set_null_value(CHARSET_INFO* cs); void load_data_set_null_value(CHARSET_INFO* cs);
void load_data_set_value(const char *str, uint length, CHARSET_INFO* cs); void load_data_set_value(const char *str, uint length, CHARSET_INFO* cs);
const Type_handler *type_handler() const { return &type_handler_double; }
enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; } enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root) Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_user_var_as_out_param>(thd, mem_root, this); } { return get_item_copy<Item_user_var_as_out_param>(thd, mem_root, this); }
...@@ -2396,7 +2404,11 @@ class Item_func_get_system_var :public Item_func ...@@ -2396,7 +2404,11 @@ class Item_func_get_system_var :public Item_func
bool const_item() const { return true; } bool const_item() const { return true; }
table_map used_tables() const { return 0; } table_map used_tables() const { return 0; }
enum Item_result result_type() const; enum Item_result result_type() const;
enum_field_types field_type() const; enum_field_types field_type() const
{
return Item_func_get_system_var::type_handler()->field_type();
}
const Type_handler *type_handler() const;
double val_real(); double val_real();
longlong val_int(); longlong val_int();
String* val_str(String*); String* val_str(String*);
...@@ -2658,6 +2670,8 @@ class Item_func_sp :public Item_func ...@@ -2658,6 +2670,8 @@ class Item_func_sp :public Item_func
enum enum_field_types field_type() const; enum enum_field_types field_type() const;
const Type_handler *type_handler() const;
Field *create_field_for_create_select(TABLE *table) Field *create_field_for_create_select(TABLE *table)
{ {
return result_type() != STRING_RESULT ? return result_type() != STRING_RESULT ?
...@@ -2843,6 +2857,7 @@ class Item_func_last_value :public Item_func ...@@ -2843,6 +2857,7 @@ class Item_func_last_value :public Item_func
const char *func_name() const { return "last_value"; } const char *func_name() const { return "last_value"; }
table_map not_null_tables() const { return 0; } table_map not_null_tables() const { return 0; }
enum_field_types field_type() const { return last_value->field_type(); } enum_field_types field_type() const { return last_value->field_type(); }
const Type_handler *type_handler() const { return last_value->type_handler(); }
bool const_item() const { return 0; } bool const_item() const { return 0; }
void evaluate_sideeffects(); void evaluate_sideeffects();
void update_used_tables() void update_used_tables()
......
...@@ -40,6 +40,7 @@ class Item_geometry_func: public Item_str_func ...@@ -40,6 +40,7 @@ class Item_geometry_func: public Item_str_func
Item_geometry_func(THD *thd, List<Item> &list): Item_str_func(thd, list) {} Item_geometry_func(THD *thd, List<Item> &list): Item_str_func(thd, list) {}
void fix_length_and_dec(); void fix_length_and_dec();
enum_field_types field_type() const { return MYSQL_TYPE_GEOMETRY; } enum_field_types field_type() const { return MYSQL_TYPE_GEOMETRY; }
const Type_handler *type_handler() const { return &type_handler_geometry; }
}; };
class Item_func_geometry_from_text: public Item_geometry_func class Item_func_geometry_from_text: public Item_geometry_func
...@@ -101,6 +102,7 @@ class Item_func_as_wkb: public Item_geometry_func ...@@ -101,6 +102,7 @@ class Item_func_as_wkb: public Item_geometry_func
const char *func_name() const { return "st_aswkb"; } const char *func_name() const { return "st_aswkb"; }
String *val_str(String *); String *val_str(String *);
enum_field_types field_type() const { return MYSQL_TYPE_LONG_BLOB; } enum_field_types field_type() const { return MYSQL_TYPE_LONG_BLOB; }
const Type_handler *type_handler() const { return &type_handler_long_blob; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root) Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_as_wkb>(thd, mem_root, this); } { return get_item_copy<Item_func_as_wkb>(thd, mem_root, this); }
}; };
......
...@@ -66,6 +66,7 @@ class Item_str_func :public Item_func ...@@ -66,6 +66,7 @@ class Item_str_func :public Item_func
my_decimal *val_decimal(my_decimal *); my_decimal *val_decimal(my_decimal *);
enum Item_result result_type () const { return STRING_RESULT; } enum Item_result result_type () const { return STRING_RESULT; }
enum_field_types field_type() const { return string_field_type(); } enum_field_types field_type() const { return string_field_type(); }
const Type_handler *type_handler() const { return string_type_handler(); }
void left_right_max_length(); void left_right_max_length();
bool fix_fields(THD *thd, Item **ref); bool fix_fields(THD *thd, Item **ref);
void update_null_value() void update_null_value()
......
...@@ -398,6 +398,7 @@ class Item_exists_subselect :public Item_subselect ...@@ -398,6 +398,7 @@ class Item_exists_subselect :public Item_subselect
enum Item_result result_type() const { return INT_RESULT;} enum Item_result result_type() const { return INT_RESULT;}
enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; } enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
const Type_handler *type_handler() const { return &type_handler_longlong; }
longlong val_int(); longlong val_int();
double val_real(); double val_real();
String *val_str(String*); String *val_str(String*);
......
...@@ -750,6 +750,7 @@ class Item_sum_int :public Item_sum_num ...@@ -750,6 +750,7 @@ class Item_sum_int :public Item_sum_num
my_decimal *val_decimal(my_decimal *); my_decimal *val_decimal(my_decimal *);
enum Item_result result_type () const { return INT_RESULT; } enum Item_result result_type () const { return INT_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; } enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
const Type_handler *type_handler() const { return &type_handler_longlong; }
void fix_length_and_dec() void fix_length_and_dec()
{ decimals=0; max_length=21; maybe_null=null_value=0; } { decimals=0; max_length=21; maybe_null=null_value=0; }
}; };
...@@ -982,6 +983,7 @@ class Item_sum_variance : public Item_sum_num ...@@ -982,6 +983,7 @@ class Item_sum_variance : public Item_sum_num
Field *create_tmp_field(bool group, TABLE *table); Field *create_tmp_field(bool group, TABLE *table);
enum Item_result result_type () const { return REAL_RESULT; } enum Item_result result_type () const { return REAL_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE;} enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE;}
const Type_handler *type_handler() const { return &type_handler_double; }
void cleanup() void cleanup()
{ {
count= 0; count= 0;
...@@ -1265,6 +1267,7 @@ class Item_avg_field_double :public Item_avg_field ...@@ -1265,6 +1267,7 @@ class Item_avg_field_double :public Item_avg_field
{ } { }
enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; } enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
enum Item_result result_type () const { return REAL_RESULT; } enum Item_result result_type () const { return REAL_RESULT; }
const Type_handler *type_handler() const { return &type_handler_double; }
longlong val_int() { return val_int_from_real(); } longlong val_int() { return val_int_from_real(); }
my_decimal *val_decimal(my_decimal *dec) { return val_decimal_from_real(dec); } my_decimal *val_decimal(my_decimal *dec) { return val_decimal_from_real(dec); }
String *val_str(String *str) { return val_string_from_real(str); } String *val_str(String *str) { return val_string_from_real(str); }
...@@ -1286,6 +1289,7 @@ class Item_avg_field_decimal :public Item_avg_field ...@@ -1286,6 +1289,7 @@ class Item_avg_field_decimal :public Item_avg_field
{ } { }
enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; } enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; }
enum Item_result result_type () const { return DECIMAL_RESULT; } enum Item_result result_type () const { return DECIMAL_RESULT; }
const Type_handler *type_handler() const { return &type_handler_newdecimal; }
double val_real() { return val_real_from_decimal(); } double val_real() { return val_real_from_decimal(); }
longlong val_int() { return val_int_from_decimal(); } longlong val_int() { return val_int_from_decimal(); }
String *val_str(String *str) { return val_string_from_decimal(str); } String *val_str(String *str) { return val_string_from_decimal(str); }
...@@ -1311,6 +1315,7 @@ class Item_variance_field :public Item_sum_field ...@@ -1311,6 +1315,7 @@ class Item_variance_field :public Item_sum_field
{ return val_decimal_from_real(dec_buf); } { return val_decimal_from_real(dec_buf); }
bool is_null() { update_null_value(); return null_value; } bool is_null() { update_null_value(); return null_value; }
enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; } enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
const Type_handler *type_handler() const { return &type_handler_double; }
enum Item_result result_type () const { return REAL_RESULT; } enum Item_result result_type () const { return REAL_RESULT; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root) Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_variance_field>(thd, mem_root, this); } { return get_item_copy<Item_variance_field>(thd, mem_root, this); }
...@@ -1412,6 +1417,7 @@ class Item_sum_udf_float :public Item_udf_sum ...@@ -1412,6 +1417,7 @@ class Item_sum_udf_float :public Item_udf_sum
enum Item_result result_type () const { return REAL_RESULT; } enum Item_result result_type () const { return REAL_RESULT; }
enum Item_result cmp_type () const { return REAL_RESULT; } enum Item_result cmp_type () const { return REAL_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; } enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
const Type_handler *type_handler() const { return &type_handler_double; }
void fix_length_and_dec() { fix_num_length_and_dec(); } void fix_length_and_dec() { fix_num_length_and_dec(); }
Item *copy_or_same(THD* thd); Item *copy_or_same(THD* thd);
Item *get_copy(THD *thd, MEM_ROOT *mem_root) Item *get_copy(THD *thd, MEM_ROOT *mem_root)
...@@ -1435,6 +1441,7 @@ class Item_sum_udf_int :public Item_udf_sum ...@@ -1435,6 +1441,7 @@ class Item_sum_udf_int :public Item_udf_sum
my_decimal *val_decimal(my_decimal *); my_decimal *val_decimal(my_decimal *);
enum Item_result result_type () const { return INT_RESULT; } enum Item_result result_type () const { return INT_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; } enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
const Type_handler *type_handler() const { return &type_handler_longlong; }
void fix_length_and_dec() { decimals=0; max_length=21; } void fix_length_and_dec() { decimals=0; max_length=21; }
Item *copy_or_same(THD* thd); Item *copy_or_same(THD* thd);
Item *get_copy(THD *thd, MEM_ROOT *mem_root) Item *get_copy(THD *thd, MEM_ROOT *mem_root)
...@@ -1477,6 +1484,7 @@ class Item_sum_udf_str :public Item_udf_sum ...@@ -1477,6 +1484,7 @@ class Item_sum_udf_str :public Item_udf_sum
my_decimal *val_decimal(my_decimal *dec); my_decimal *val_decimal(my_decimal *dec);
enum Item_result result_type () const { return STRING_RESULT; } enum Item_result result_type () const { return STRING_RESULT; }
enum_field_types field_type() const { return string_field_type(); } enum_field_types field_type() const { return string_field_type(); }
const Type_handler *type_handler() const { return string_type_handler(); }
void fix_length_and_dec(); void fix_length_and_dec();
Item *copy_or_same(THD* thd); Item *copy_or_same(THD* thd);
Item *get_copy(THD *thd, MEM_ROOT *mem_root) Item *get_copy(THD *thd, MEM_ROOT *mem_root)
...@@ -1499,6 +1507,7 @@ class Item_sum_udf_decimal :public Item_udf_sum ...@@ -1499,6 +1507,7 @@ class Item_sum_udf_decimal :public Item_udf_sum
my_decimal *val_decimal(my_decimal *); my_decimal *val_decimal(my_decimal *);
enum Item_result result_type () const { return DECIMAL_RESULT; } enum Item_result result_type () const { return DECIMAL_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; } enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; }
const Type_handler *type_handler() const { return &type_handler_newdecimal; }
void fix_length_and_dec() { fix_num_length_and_dec(); } void fix_length_and_dec() { fix_num_length_and_dec(); }
Item *copy_or_same(THD* thd); Item *copy_or_same(THD* thd);
Item *get_copy(THD *thd, MEM_ROOT *mem_root) Item *get_copy(THD *thd, MEM_ROOT *mem_root)
...@@ -1650,11 +1659,14 @@ class Item_func_group_concat : public Item_sum ...@@ -1650,11 +1659,14 @@ class Item_func_group_concat : public Item_sum
virtual Item_result result_type () const { return STRING_RESULT; } virtual Item_result result_type () const { return STRING_RESULT; }
virtual Item_result cmp_type () const { return STRING_RESULT; } virtual Item_result cmp_type () const { return STRING_RESULT; }
enum_field_types field_type() const enum_field_types field_type() const
{
return Item_func_group_concat::type_handler()->field_type();
}
const Type_handler *type_handler() const
{ {
if (too_big_for_varchar()) if (too_big_for_varchar())
return MYSQL_TYPE_BLOB; return &type_handler_blob;
else return &type_handler_varchar;
return MYSQL_TYPE_VARCHAR;
} }
void clear(); void clear();
bool add(); bool add();
......
...@@ -157,6 +157,7 @@ class Item_func_month :public Item_func ...@@ -157,6 +157,7 @@ class Item_func_month :public Item_func
const char *func_name() const { return "month"; } const char *func_name() const { return "month"; }
enum Item_result result_type () const { return INT_RESULT; } enum Item_result result_type () const { return INT_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; } enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
const Type_handler *type_handler() const { return &type_handler_longlong; }
void fix_length_and_dec() void fix_length_and_dec()
{ {
decimals= 0; decimals= 0;
...@@ -407,6 +408,7 @@ class Item_func_weekday :public Item_func ...@@ -407,6 +408,7 @@ class Item_func_weekday :public Item_func
} }
enum Item_result result_type () const { return INT_RESULT; } enum Item_result result_type () const { return INT_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; } enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
const Type_handler *type_handler() const { return &type_handler_longlong; }
void fix_length_and_dec() void fix_length_and_dec()
{ {
decimals= 0; decimals= 0;
...@@ -432,6 +434,7 @@ class Item_func_dayname :public Item_func_weekday ...@@ -432,6 +434,7 @@ class Item_func_dayname :public Item_func_weekday
String *val_str(String *str); String *val_str(String *str);
enum Item_result result_type () const { return STRING_RESULT; } enum Item_result result_type () const { return STRING_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; } enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; }
const Type_handler *type_handler() const { return &type_handler_varchar; }
void fix_length_and_dec(); void fix_length_and_dec();
bool check_partition_func_processor(void *int_arg) {return TRUE;} bool check_partition_func_processor(void *int_arg) {return TRUE;}
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
...@@ -586,6 +589,7 @@ class Item_datefunc :public Item_temporal_func ...@@ -586,6 +589,7 @@ class Item_datefunc :public Item_temporal_func
Item_datefunc(THD *thd, Item *a): Item_temporal_func(thd, a) { } Item_datefunc(THD *thd, Item *a): Item_temporal_func(thd, a) { }
Item_datefunc(THD *thd, Item *a, Item *b): Item_temporal_func(thd, a, b) { } Item_datefunc(THD *thd, Item *a, Item *b): Item_temporal_func(thd, a, b) { }
enum_field_types field_type() const { return MYSQL_TYPE_DATE; } enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
const Type_handler *type_handler() const { return &type_handler_newdate; }
void fix_length_and_dec() void fix_length_and_dec()
{ {
fix_attributes_date(); fix_attributes_date();
...@@ -603,6 +607,7 @@ class Item_timefunc :public Item_temporal_func ...@@ -603,6 +607,7 @@ class Item_timefunc :public Item_temporal_func
Item_timefunc(THD *thd, Item *a, Item *b, Item *c): Item_timefunc(THD *thd, Item *a, Item *b, Item *c):
Item_temporal_func(thd, a, b ,c) {} Item_temporal_func(thd, a, b ,c) {}
enum_field_types field_type() const { return MYSQL_TYPE_TIME; } enum_field_types field_type() const { return MYSQL_TYPE_TIME; }
const Type_handler *type_handler() const { return &type_handler_time2; }
}; };
...@@ -614,6 +619,7 @@ class Item_datetimefunc :public Item_temporal_func ...@@ -614,6 +619,7 @@ class Item_datetimefunc :public Item_temporal_func
Item_datetimefunc(THD *thd, Item *a, Item *b, Item *c): Item_datetimefunc(THD *thd, Item *a, Item *b, Item *c):
Item_temporal_func(thd, a, b ,c) {} Item_temporal_func(thd, a, b ,c) {}
enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; } enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; }
const Type_handler *type_handler() const { return &type_handler_datetime2; }
}; };
...@@ -938,6 +944,10 @@ class Item_extract :public Item_int_func ...@@ -938,6 +944,10 @@ class Item_extract :public Item_int_func
Item_extract(THD *thd, interval_type type_arg, Item *a): Item_extract(THD *thd, interval_type type_arg, Item *a):
Item_int_func(thd, a), int_type(type_arg) {} Item_int_func(thd, a), int_type(type_arg) {}
enum_field_types field_type() const enum_field_types field_type() const
{
return Item_extract::type_handler()->field_type();
}
const Type_handler *type_handler() const
{ {
switch (int_type) { switch (int_type) {
case INTERVAL_YEAR: case INTERVAL_YEAR:
...@@ -957,16 +967,16 @@ class Item_extract :public Item_int_func ...@@ -957,16 +967,16 @@ class Item_extract :public Item_int_func
case INTERVAL_SECOND: case INTERVAL_SECOND:
case INTERVAL_MICROSECOND: case INTERVAL_MICROSECOND:
case INTERVAL_SECOND_MICROSECOND: case INTERVAL_SECOND_MICROSECOND:
return MYSQL_TYPE_LONG; return &type_handler_long;
case INTERVAL_DAY_MICROSECOND: case INTERVAL_DAY_MICROSECOND:
case INTERVAL_HOUR_MICROSECOND: case INTERVAL_HOUR_MICROSECOND:
case INTERVAL_MINUTE_MICROSECOND: case INTERVAL_MINUTE_MICROSECOND:
return MYSQL_TYPE_LONGLONG; return &type_handler_longlong;
case INTERVAL_LAST: case INTERVAL_LAST:
break; break;
} }
DBUG_ASSERT(0); DBUG_ASSERT(0);
return MYSQL_TYPE_LONGLONG; return &type_handler_longlong;
} }
longlong val_int(); longlong val_int();
enum Functype functype() const { return EXTRACT_FUNC; } enum Functype functype() const { return EXTRACT_FUNC; }
...@@ -1074,6 +1084,7 @@ class Item_date_typecast :public Item_temporal_typecast ...@@ -1074,6 +1084,7 @@ class Item_date_typecast :public Item_temporal_typecast
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date); bool get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date);
const char *cast_type() const { return "date"; } const char *cast_type() const { return "date"; }
enum_field_types field_type() const { return MYSQL_TYPE_DATE; } enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
const Type_handler *type_handler() const { return &type_handler_newdate; }
void fix_length_and_dec() void fix_length_and_dec()
{ {
args[0]->type_handler()->Item_date_typecast_fix_length_and_dec(this); args[0]->type_handler()->Item_date_typecast_fix_length_and_dec(this);
...@@ -1092,6 +1103,7 @@ class Item_time_typecast :public Item_temporal_typecast ...@@ -1092,6 +1103,7 @@ class Item_time_typecast :public Item_temporal_typecast
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date); bool get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date);
const char *cast_type() const { return "time"; } const char *cast_type() const { return "time"; }
enum_field_types field_type() const { return MYSQL_TYPE_TIME; } enum_field_types field_type() const { return MYSQL_TYPE_TIME; }
const Type_handler *type_handler() const { return &type_handler_time2; }
void fix_length_and_dec() void fix_length_and_dec()
{ {
args[0]->type_handler()->Item_time_typecast_fix_length_and_dec(this); args[0]->type_handler()->Item_time_typecast_fix_length_and_dec(this);
...@@ -1109,6 +1121,7 @@ class Item_datetime_typecast :public Item_temporal_typecast ...@@ -1109,6 +1121,7 @@ class Item_datetime_typecast :public Item_temporal_typecast
const char *func_name() const { return "cast_as_datetime"; } const char *func_name() const { return "cast_as_datetime"; }
const char *cast_type() const { return "datetime"; } const char *cast_type() const { return "datetime"; }
enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; } enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; }
const Type_handler *type_handler() const { return &type_handler_datetime2; }
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date); bool get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date);
void fix_length_and_dec() void fix_length_and_dec()
{ {
......
...@@ -309,6 +309,8 @@ class Item_sum_hybrid_simple : public Item_sum, ...@@ -309,6 +309,8 @@ class Item_sum_hybrid_simple : public Item_sum,
{ return Type_handler_hybrid_field_type::cmp_type(); } { return Type_handler_hybrid_field_type::cmp_type(); }
enum enum_field_types field_type() const enum enum_field_types field_type() const
{ return Type_handler_hybrid_field_type::field_type(); } { return Type_handler_hybrid_field_type::field_type(); }
const Type_handler *type_handler() const
{ return Type_handler_hybrid_field_type::type_handler(); }
void update_field(); void update_field();
Field *create_tmp_field(bool group, TABLE *table); Field *create_tmp_field(bool group, TABLE *table);
void clear() void clear()
...@@ -513,6 +515,7 @@ class Item_sum_percent_rank: public Item_sum_window_with_row_count ...@@ -513,6 +515,7 @@ class Item_sum_percent_rank: public Item_sum_window_with_row_count
bool add(); bool add();
enum Item_result result_type () const { return REAL_RESULT; } enum Item_result result_type () const { return REAL_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; } enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
const Type_handler *type_handler() const { return &type_handler_double; }
void fix_length_and_dec() void fix_length_and_dec()
{ {
...@@ -599,6 +602,7 @@ class Item_sum_cume_dist: public Item_sum_window_with_row_count ...@@ -599,6 +602,7 @@ class Item_sum_cume_dist: public Item_sum_window_with_row_count
void update_field() {} void update_field() {}
enum Item_result result_type () const { return REAL_RESULT; } enum Item_result result_type () const { return REAL_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; } enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
const Type_handler *type_handler() const { return &type_handler_double; }
void fix_length_and_dec() void fix_length_and_dec()
{ {
...@@ -676,6 +680,7 @@ class Item_sum_ntile : public Item_sum_window_with_row_count ...@@ -676,6 +680,7 @@ class Item_sum_ntile : public Item_sum_window_with_row_count
enum Item_result result_type () const { return INT_RESULT; } enum Item_result result_type () const { return INT_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; } enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
const Type_handler *type_handler() const { return &type_handler_longlong; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root) Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_sum_ntile>(thd, mem_root, this); } { return get_item_copy<Item_sum_ntile>(thd, mem_root, this); }
...@@ -804,6 +809,10 @@ class Item_window_func : public Item_func_or_sum ...@@ -804,6 +809,10 @@ class Item_window_func : public Item_func_or_sum
{ {
return ((Item_sum *) args[0])->field_type(); return ((Item_sum *) args[0])->field_type();
} }
const Type_handler *type_handler() const
{
return ((Item_sum *) args[0])->type_handler();
}
enum Item::Type type() const { return Item::WINDOW_FUNC_ITEM; } enum Item::Type type() const { return Item::WINDOW_FUNC_ITEM; }
private: private:
......
...@@ -48,6 +48,7 @@ class Item_proc :public Item ...@@ -48,6 +48,7 @@ class Item_proc :public Item
virtual void set(const char *str,uint length,CHARSET_INFO *cs)=0; virtual void set(const char *str,uint length,CHARSET_INFO *cs)=0;
virtual void set(longlong nr)=0; virtual void set(longlong nr)=0;
virtual enum_field_types field_type() const=0; virtual enum_field_types field_type() const=0;
const Type_handler *type_handler() const=0;
void set(const char *str) { set(str,(uint) strlen(str), default_charset()); } void set(const char *str) { set(str,(uint) strlen(str), default_charset()); }
void make_field(THD *thd, Send_field *tmp_field) void make_field(THD *thd, Send_field *tmp_field)
{ {
...@@ -74,6 +75,7 @@ class Item_proc_real :public Item_proc ...@@ -74,6 +75,7 @@ class Item_proc_real :public Item_proc
enum Item_result result_type () const { return REAL_RESULT; } enum Item_result result_type () const { return REAL_RESULT; }
enum Item_result cmp_type () const { return REAL_RESULT; } enum Item_result cmp_type () const { return REAL_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; } enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
const Type_handler *type_handler() const { return &type_handler_double; }
void set(double nr) { value=nr; } void set(double nr) { value=nr; }
void set(longlong nr) { value=(double) nr; } void set(longlong nr) { value=(double) nr; }
void set(const char *str,uint length,CHARSET_INFO *cs) void set(const char *str,uint length,CHARSET_INFO *cs)
...@@ -102,6 +104,7 @@ class Item_proc_int :public Item_proc ...@@ -102,6 +104,7 @@ class Item_proc_int :public Item_proc
enum Item_result result_type () const { return INT_RESULT; } enum Item_result result_type () const { return INT_RESULT; }
enum Item_result cmp_type () const { return INT_RESULT; } enum Item_result cmp_type () const { return INT_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; } enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
const Type_handler *type_handler() const { return &type_handler_longlong; }
void set(double nr) { value=(longlong) nr; } void set(double nr) { value=(longlong) nr; }
void set(longlong nr) { value=nr; } void set(longlong nr) { value=nr; }
void set(const char *str,uint length, CHARSET_INFO *cs) void set(const char *str,uint length, CHARSET_INFO *cs)
...@@ -122,6 +125,7 @@ class Item_proc_string :public Item_proc ...@@ -122,6 +125,7 @@ class Item_proc_string :public Item_proc
enum Item_result result_type () const { return STRING_RESULT; } enum Item_result result_type () const { return STRING_RESULT; }
enum Item_result cmp_type () const { return STRING_RESULT; } enum Item_result cmp_type () const { return STRING_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; } enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; }
const Type_handler *type_handler() const { return &type_handler_varchar; }
void set(double nr) { str_value.set_real(nr, 2, default_charset()); } void set(double nr) { str_value.set_real(nr, 2, default_charset()); }
void set(longlong nr) { str_value.set(nr, default_charset()); } void set(longlong nr) { str_value.set(nr, default_charset()); }
void set(const char *str, uint length, CHARSET_INFO *cs) void set(const char *str, uint length, CHARSET_INFO *cs)
......
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