mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
MDEV-12713 Define virtual type_handler() for all Item classes
This commit is contained in:
36
sql/item.h
36
sql/item.h
@@ -729,10 +729,7 @@ public:
|
||||
}
|
||||
virtual bool eq(const Item *, bool binary_cmp) const;
|
||||
virtual enum_field_types field_type() const= 0;
|
||||
virtual const Type_handler *type_handler() const
|
||||
{
|
||||
return Type_handler::get_handler_by_field_type(field_type());
|
||||
}
|
||||
virtual const Type_handler *type_handler() const= 0;
|
||||
const Type_handler *type_handler_for_comparison() const
|
||||
{
|
||||
return type_handler()->type_handler_for_comparison();
|
||||
@@ -759,6 +756,10 @@ public:
|
||||
{
|
||||
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.
|
||||
This method is used in data type aggregation for UNION, e.g.:
|
||||
@@ -2395,6 +2396,7 @@ public:
|
||||
inline enum Type type() const;
|
||||
inline Item_result result_type() const;
|
||||
enum_field_types field_type() const { return this_item()->field_type(); }
|
||||
const Type_handler *type_handler() const { return this_item()->type_handler(); }
|
||||
|
||||
public:
|
||||
/*
|
||||
@@ -2456,6 +2458,11 @@ public:
|
||||
bool is_null();
|
||||
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
|
||||
{
|
||||
return value_item->field_type();
|
||||
@@ -2617,6 +2624,11 @@ public:
|
||||
my_decimal *val_decimal(my_decimal *dec) { return field->val_decimal(dec); }
|
||||
void make_field(THD *thd, Send_field *tmp_field);
|
||||
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)
|
||||
{ return get_item_copy<Item_ident_for_show>(thd, mem_root, this); }
|
||||
};
|
||||
@@ -2916,6 +2928,7 @@ public:
|
||||
bool send(Protocol *protocol, st_value *buffer);
|
||||
enum Item_result result_type () const { return STRING_RESULT; }
|
||||
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; }
|
||||
Item *clone_item(THD *thd);
|
||||
bool is_null() { return 1; }
|
||||
@@ -3332,6 +3345,7 @@ public:
|
||||
enum Type type() const { return DECIMAL_ITEM; }
|
||||
enum Item_result result_type () const { return DECIMAL_RESULT; }
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; }
|
||||
const Type_handler *type_handler() const { return &type_handler_newdecimal; }
|
||||
longlong val_int();
|
||||
double val_real();
|
||||
String *val_str(String*);
|
||||
@@ -3373,6 +3387,7 @@ public:
|
||||
int save_in_field(Field *field, bool no_conversions);
|
||||
enum Type type() const { return REAL_ITEM; }
|
||||
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; }
|
||||
longlong val_int()
|
||||
{
|
||||
@@ -3513,6 +3528,7 @@ public:
|
||||
int save_in_field(Field *field, bool no_conversions);
|
||||
enum Item_result result_type () const { return STRING_RESULT; }
|
||||
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 eq(const Item *item, bool binary_cmp) const
|
||||
{
|
||||
@@ -3698,6 +3714,10 @@ public:
|
||||
date_time_field_type(field_type_arg)
|
||||
{ decimals= 0; }
|
||||
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 @@ public:
|
||||
enum Type type() const { return VARBIN_ITEM; }
|
||||
enum Item_result result_type () const { return STRING_RESULT; }
|
||||
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)
|
||||
{
|
||||
return const_charset_converter(thd, tocs, true);
|
||||
@@ -3964,6 +3985,7 @@ public:
|
||||
maybe_null= !ltime->month || !ltime->day;
|
||||
}
|
||||
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);
|
||||
Item *clone_item(THD *thd);
|
||||
bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date);
|
||||
@@ -3985,6 +4007,7 @@ public:
|
||||
fixed= 1;
|
||||
}
|
||||
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);
|
||||
Item *clone_item(THD *thd);
|
||||
bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date);
|
||||
@@ -4008,6 +4031,7 @@ public:
|
||||
maybe_null= !ltime->month || !ltime->day;
|
||||
}
|
||||
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);
|
||||
Item *clone_item(THD *thd);
|
||||
bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date);
|
||||
@@ -4323,6 +4347,7 @@ public:
|
||||
{ return (*ref)->setup_fast_field_copier(field); }
|
||||
enum Item_result result_type () const { return (*ref)->result_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
|
||||
{ return (*ref)->real_type_handler(); }
|
||||
Field *get_tmp_table_field()
|
||||
@@ -4618,6 +4643,7 @@ public:
|
||||
orig_item->fix_after_pullout(new_parent, &orig_item);
|
||||
}
|
||||
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_field_types field_type() const { return orig_item->field_type(); }
|
||||
table_map used_tables() const { return orig_item->used_tables(); }
|
||||
@@ -5011,7 +5037,7 @@ protected:
|
||||
null_value=maybe_null=item->maybe_null;
|
||||
Type_std_attributes::set(item);
|
||||
name= item->name;
|
||||
set_handler_by_field_type(item->field_type());
|
||||
set_handler(item->type_handler());
|
||||
fixed= item->fixed;
|
||||
}
|
||||
|
||||
|
||||
@@ -1014,7 +1014,7 @@ protected:
|
||||
void cache_type_info(const Item *source, bool maybe_null_arg)
|
||||
{
|
||||
Type_std_attributes::set(source);
|
||||
set_handler_by_field_type(source->field_type());
|
||||
set_handler(source->type_handler());
|
||||
maybe_null= maybe_null_arg;
|
||||
}
|
||||
|
||||
@@ -2767,7 +2767,6 @@ public:
|
||||
Item *transform(THD *thd, Item_transformer transformer, uchar *arg);
|
||||
void traverse_cond(Cond_traverser, void *arg, traverse_order order);
|
||||
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 *compile(THD *thd, Item_analyzer analyzer, uchar **arg_p,
|
||||
Item_transformer transformer, uchar *arg_t);
|
||||
|
||||
@@ -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())
|
||||
{
|
||||
@@ -5625,16 +5625,16 @@ enum_field_types Item_func_get_system_var::field_type() const
|
||||
case SHOW_ULONG:
|
||||
case SHOW_ULONGLONG:
|
||||
case SHOW_HA_ROWS:
|
||||
return MYSQL_TYPE_LONGLONG;
|
||||
return &type_handler_longlong;
|
||||
case SHOW_CHAR:
|
||||
case SHOW_CHAR_PTR:
|
||||
case SHOW_LEX_STRING:
|
||||
return MYSQL_TYPE_VARCHAR;
|
||||
return &type_handler_varchar;
|
||||
case SHOW_DOUBLE:
|
||||
return MYSQL_TYPE_DOUBLE;
|
||||
return &type_handler_double;
|
||||
default:
|
||||
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
|
||||
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_func_sp::result_type() const
|
||||
{
|
||||
|
||||
@@ -372,6 +372,7 @@ public:
|
||||
{ DBUG_ASSERT(fixed == 1); return (longlong) rint(val_real()); }
|
||||
enum Item_result result_type () const { return REAL_RESULT; }
|
||||
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()
|
||||
{ decimals= NOT_FIXED_DEC; max_length= float_length(decimals); }
|
||||
};
|
||||
@@ -737,6 +738,7 @@ public:
|
||||
String *val_str(String*str);
|
||||
enum Item_result result_type () const { return INT_RESULT; }
|
||||
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() {}
|
||||
};
|
||||
|
||||
@@ -909,6 +911,7 @@ public:
|
||||
my_decimal *val_decimal(my_decimal*);
|
||||
enum Item_result result_type () const { return DECIMAL_RESULT; }
|
||||
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()
|
||||
{
|
||||
@@ -932,7 +935,6 @@ public:
|
||||
max_length= (uint32) len;
|
||||
}
|
||||
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()
|
||||
{
|
||||
@@ -1546,6 +1548,7 @@ public:
|
||||
bool const_item() const { return 0; }
|
||||
Item_result result_type() const { return args[0]->result_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()
|
||||
{
|
||||
collation= args[0]->collation;
|
||||
@@ -1953,6 +1956,7 @@ class Item_func_udf_float :public Item_udf_func
|
||||
double val_real();
|
||||
String *val_str(String *str);
|
||||
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(); }
|
||||
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
|
||||
{ return get_item_copy<Item_func_udf_float>(thd, mem_root, this); }
|
||||
@@ -1972,6 +1976,7 @@ public:
|
||||
String *val_str(String *str);
|
||||
enum Item_result result_type () const { return INT_RESULT; }
|
||||
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; }
|
||||
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
|
||||
{ return get_item_copy<Item_func_udf_int>(thd, mem_root, this); }
|
||||
@@ -1991,6 +1996,7 @@ public:
|
||||
String *val_str(String *str);
|
||||
enum Item_result result_type () const { return DECIMAL_RESULT; }
|
||||
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(); }
|
||||
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
|
||||
{ return get_item_copy<Item_func_udf_decimal>(thd, mem_root, this); }
|
||||
@@ -2031,6 +2037,7 @@ public:
|
||||
}
|
||||
enum Item_result result_type () const { return STRING_RESULT; }
|
||||
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();
|
||||
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
|
||||
{ return get_item_copy<Item_func_udf_str>(thd, mem_root, this); }
|
||||
@@ -2360,6 +2367,7 @@ public:
|
||||
void load_data_print(THD *thd, String *str);
|
||||
void load_data_set_null_value(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; }
|
||||
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
|
||||
{ return get_item_copy<Item_user_var_as_out_param>(thd, mem_root, this); }
|
||||
@@ -2396,7 +2404,11 @@ public:
|
||||
bool const_item() const { return true; }
|
||||
table_map used_tables() const { return 0; }
|
||||
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();
|
||||
longlong val_int();
|
||||
String* val_str(String*);
|
||||
@@ -2658,6 +2670,8 @@ public:
|
||||
|
||||
enum enum_field_types field_type() const;
|
||||
|
||||
const Type_handler *type_handler() const;
|
||||
|
||||
Field *create_field_for_create_select(TABLE *table)
|
||||
{
|
||||
return result_type() != STRING_RESULT ?
|
||||
@@ -2843,6 +2857,7 @@ public:
|
||||
const char *func_name() const { return "last_value"; }
|
||||
table_map not_null_tables() const { return 0; }
|
||||
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; }
|
||||
void evaluate_sideeffects();
|
||||
void update_used_tables()
|
||||
|
||||
@@ -40,6 +40,7 @@ public:
|
||||
Item_geometry_func(THD *thd, List<Item> &list): Item_str_func(thd, list) {}
|
||||
void fix_length_and_dec();
|
||||
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
|
||||
@@ -101,6 +102,7 @@ public:
|
||||
const char *func_name() const { return "st_aswkb"; }
|
||||
String *val_str(String *);
|
||||
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)
|
||||
{ return get_item_copy<Item_func_as_wkb>(thd, mem_root, this); }
|
||||
};
|
||||
|
||||
@@ -66,6 +66,7 @@ public:
|
||||
my_decimal *val_decimal(my_decimal *);
|
||||
enum Item_result result_type () const { return STRING_RESULT; }
|
||||
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();
|
||||
bool fix_fields(THD *thd, Item **ref);
|
||||
void update_null_value()
|
||||
|
||||
@@ -398,6 +398,7 @@ public:
|
||||
|
||||
enum Item_result result_type() const { return INT_RESULT;}
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
|
||||
const Type_handler *type_handler() const { return &type_handler_longlong; }
|
||||
longlong val_int();
|
||||
double val_real();
|
||||
String *val_str(String*);
|
||||
|
||||
@@ -750,6 +750,7 @@ public:
|
||||
my_decimal *val_decimal(my_decimal *);
|
||||
enum Item_result result_type () const { return INT_RESULT; }
|
||||
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; maybe_null=null_value=0; }
|
||||
};
|
||||
@@ -982,6 +983,7 @@ public:
|
||||
Field *create_tmp_field(bool group, TABLE *table);
|
||||
enum Item_result result_type () const { return REAL_RESULT; }
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE;}
|
||||
const Type_handler *type_handler() const { return &type_handler_double; }
|
||||
void cleanup()
|
||||
{
|
||||
count= 0;
|
||||
@@ -1265,6 +1267,7 @@ public:
|
||||
{ }
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
|
||||
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(); }
|
||||
my_decimal *val_decimal(my_decimal *dec) { return val_decimal_from_real(dec); }
|
||||
String *val_str(String *str) { return val_string_from_real(str); }
|
||||
@@ -1286,6 +1289,7 @@ public:
|
||||
{ }
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; }
|
||||
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(); }
|
||||
longlong val_int() { return val_int_from_decimal(); }
|
||||
String *val_str(String *str) { return val_string_from_decimal(str); }
|
||||
@@ -1311,6 +1315,7 @@ public:
|
||||
{ return val_decimal_from_real(dec_buf); }
|
||||
bool is_null() { update_null_value(); return null_value; }
|
||||
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; }
|
||||
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
|
||||
{ return get_item_copy<Item_variance_field>(thd, mem_root, this); }
|
||||
@@ -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 cmp_type () const { return REAL_RESULT; }
|
||||
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(); }
|
||||
Item *copy_or_same(THD* thd);
|
||||
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
|
||||
@@ -1435,6 +1441,7 @@ public:
|
||||
my_decimal *val_decimal(my_decimal *);
|
||||
enum Item_result result_type () const { return INT_RESULT; }
|
||||
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; }
|
||||
Item *copy_or_same(THD* thd);
|
||||
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
|
||||
@@ -1477,6 +1484,7 @@ public:
|
||||
my_decimal *val_decimal(my_decimal *dec);
|
||||
enum Item_result result_type () const { return STRING_RESULT; }
|
||||
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();
|
||||
Item *copy_or_same(THD* thd);
|
||||
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
|
||||
@@ -1499,6 +1507,7 @@ public:
|
||||
my_decimal *val_decimal(my_decimal *);
|
||||
enum Item_result result_type () const { return DECIMAL_RESULT; }
|
||||
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(); }
|
||||
Item *copy_or_same(THD* thd);
|
||||
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
|
||||
@@ -1650,11 +1659,14 @@ public:
|
||||
virtual Item_result result_type () const { return STRING_RESULT; }
|
||||
virtual Item_result cmp_type () const { return STRING_RESULT; }
|
||||
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())
|
||||
return MYSQL_TYPE_BLOB;
|
||||
else
|
||||
return MYSQL_TYPE_VARCHAR;
|
||||
return &type_handler_blob;
|
||||
return &type_handler_varchar;
|
||||
}
|
||||
void clear();
|
||||
bool add();
|
||||
|
||||
@@ -157,6 +157,7 @@ public:
|
||||
const char *func_name() const { return "month"; }
|
||||
enum Item_result result_type () const { return INT_RESULT; }
|
||||
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;
|
||||
@@ -407,6 +408,7 @@ public:
|
||||
}
|
||||
enum Item_result result_type () const { return INT_RESULT; }
|
||||
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;
|
||||
@@ -432,6 +434,7 @@ class Item_func_dayname :public Item_func_weekday
|
||||
String *val_str(String *str);
|
||||
enum Item_result result_type () const { return STRING_RESULT; }
|
||||
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();
|
||||
bool check_partition_func_processor(void *int_arg) {return TRUE;}
|
||||
bool check_vcol_func_processor(void *arg)
|
||||
@@ -586,6 +589,7 @@ public:
|
||||
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) { }
|
||||
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()
|
||||
{
|
||||
fix_attributes_date();
|
||||
@@ -603,6 +607,7 @@ public:
|
||||
Item_timefunc(THD *thd, Item *a, Item *b, Item *c):
|
||||
Item_temporal_func(thd, a, b ,c) {}
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_TIME; }
|
||||
const Type_handler *type_handler() const { return &type_handler_time2; }
|
||||
};
|
||||
|
||||
|
||||
@@ -614,6 +619,7 @@ public:
|
||||
Item_datetimefunc(THD *thd, Item *a, Item *b, Item *c):
|
||||
Item_temporal_func(thd, a, b ,c) {}
|
||||
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
|
||||
Item_extract(THD *thd, interval_type type_arg, Item *a):
|
||||
Item_int_func(thd, a), int_type(type_arg) {}
|
||||
enum_field_types field_type() const
|
||||
{
|
||||
return Item_extract::type_handler()->field_type();
|
||||
}
|
||||
const Type_handler *type_handler() const
|
||||
{
|
||||
switch (int_type) {
|
||||
case INTERVAL_YEAR:
|
||||
@@ -957,16 +967,16 @@ class Item_extract :public Item_int_func
|
||||
case INTERVAL_SECOND:
|
||||
case INTERVAL_MICROSECOND:
|
||||
case INTERVAL_SECOND_MICROSECOND:
|
||||
return MYSQL_TYPE_LONG;
|
||||
return &type_handler_long;
|
||||
case INTERVAL_DAY_MICROSECOND:
|
||||
case INTERVAL_HOUR_MICROSECOND:
|
||||
case INTERVAL_MINUTE_MICROSECOND:
|
||||
return MYSQL_TYPE_LONGLONG;
|
||||
return &type_handler_longlong;
|
||||
case INTERVAL_LAST:
|
||||
break;
|
||||
}
|
||||
DBUG_ASSERT(0);
|
||||
return MYSQL_TYPE_LONGLONG;
|
||||
return &type_handler_longlong;
|
||||
}
|
||||
longlong val_int();
|
||||
enum Functype functype() const { return EXTRACT_FUNC; }
|
||||
@@ -1074,6 +1084,7 @@ public:
|
||||
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date);
|
||||
const char *cast_type() const { return "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()
|
||||
{
|
||||
args[0]->type_handler()->Item_date_typecast_fix_length_and_dec(this);
|
||||
@@ -1092,6 +1103,7 @@ public:
|
||||
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date);
|
||||
const char *cast_type() const { return "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()
|
||||
{
|
||||
args[0]->type_handler()->Item_time_typecast_fix_length_and_dec(this);
|
||||
@@ -1109,6 +1121,7 @@ public:
|
||||
const char *func_name() const { return "cast_as_datetime"; }
|
||||
const char *cast_type() const { return "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);
|
||||
void fix_length_and_dec()
|
||||
{
|
||||
|
||||
@@ -309,6 +309,8 @@ class Item_sum_hybrid_simple : public Item_sum,
|
||||
{ return Type_handler_hybrid_field_type::cmp_type(); }
|
||||
enum enum_field_types field_type() const
|
||||
{ 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();
|
||||
Field *create_tmp_field(bool group, TABLE *table);
|
||||
void clear()
|
||||
@@ -513,6 +515,7 @@ class Item_sum_percent_rank: public Item_sum_window_with_row_count
|
||||
bool add();
|
||||
enum Item_result result_type () const { return REAL_RESULT; }
|
||||
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()
|
||||
{
|
||||
@@ -599,6 +602,7 @@ class Item_sum_cume_dist: public Item_sum_window_with_row_count
|
||||
void update_field() {}
|
||||
enum Item_result result_type () const { return REAL_RESULT; }
|
||||
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()
|
||||
{
|
||||
@@ -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_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)
|
||||
{ return get_item_copy<Item_sum_ntile>(thd, mem_root, this); }
|
||||
@@ -804,6 +809,10 @@ public:
|
||||
{
|
||||
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; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -48,6 +48,7 @@ public:
|
||||
virtual void set(const char *str,uint length,CHARSET_INFO *cs)=0;
|
||||
virtual void set(longlong nr)=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 make_field(THD *thd, Send_field *tmp_field)
|
||||
{
|
||||
@@ -74,6 +75,7 @@ public:
|
||||
enum Item_result result_type () const { return REAL_RESULT; }
|
||||
enum Item_result cmp_type () const { return REAL_RESULT; }
|
||||
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(longlong nr) { value=(double) nr; }
|
||||
void set(const char *str,uint length,CHARSET_INFO *cs)
|
||||
@@ -102,6 +104,7 @@ public:
|
||||
enum Item_result result_type () const { return INT_RESULT; }
|
||||
enum Item_result cmp_type () const { return INT_RESULT; }
|
||||
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(longlong nr) { value=nr; }
|
||||
void set(const char *str,uint length, CHARSET_INFO *cs)
|
||||
@@ -122,6 +125,7 @@ public:
|
||||
enum Item_result result_type () const { return STRING_RESULT; }
|
||||
enum Item_result cmp_type () const { return STRING_RESULT; }
|
||||
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(longlong nr) { str_value.set(nr, default_charset()); }
|
||||
void set(const char *str, uint length, CHARSET_INFO *cs)
|
||||
|
||||
Reference in New Issue
Block a user