Commit ea679c88 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-19377 Replace Virtual_column_info::field_type to Type_handler

parent 0cbc9306
...@@ -10572,7 +10572,7 @@ bool Column_definition::check(THD *thd) ...@@ -10572,7 +10572,7 @@ bool Column_definition::check(THD *thd)
if (vcol_info) if (vcol_info)
{ {
DBUG_ASSERT(vcol_info->expr); DBUG_ASSERT(vcol_info->expr);
vcol_info->set_field_type(real_field_type()); vcol_info->set_handler(type_handler());
if (check_expression(vcol_info, &field_name, vcol_info->stored_in_db if (check_expression(vcol_info, &field_name, vcol_info->stored_in_db
? VCOL_GENERATED_STORED : VCOL_GENERATED_VIRTUAL)) ? VCOL_GENERATED_STORED : VCOL_GENERATED_VIRTUAL))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
......
...@@ -524,7 +524,8 @@ static inline const char *vcol_type_name(enum_vcol_info_type type) ...@@ -524,7 +524,8 @@ static inline const char *vcol_type_name(enum_vcol_info_type type)
- whether the field is used in a partitioning expression - whether the field is used in a partitioning expression
*/ */
class Virtual_column_info: public Sql_alloc class Virtual_column_info: public Sql_alloc,
private Type_handler_hybrid_field_type
{ {
private: private:
enum_vcol_info_type vcol_type; /* Virtual column expression type */ enum_vcol_info_type vcol_type; /* Virtual column expression type */
...@@ -532,7 +533,6 @@ class Virtual_column_info: public Sql_alloc ...@@ -532,7 +533,6 @@ class Virtual_column_info: public Sql_alloc
The following data is only updated by the parser and read The following data is only updated by the parser and read
when a Create_field object is created/initialized. when a Create_field object is created/initialized.
*/ */
enum_field_types field_type; /* Real field type*/
/* Flag indicating that the field used in a partitioning expression */ /* Flag indicating that the field used in a partitioning expression */
bool in_partitioning_expr; bool in_partitioning_expr;
...@@ -546,8 +546,8 @@ class Virtual_column_info: public Sql_alloc ...@@ -546,8 +546,8 @@ class Virtual_column_info: public Sql_alloc
uint flags; uint flags;
Virtual_column_info() Virtual_column_info()
: vcol_type((enum_vcol_info_type)VCOL_TYPE_NONE), :Type_handler_hybrid_field_type(&type_handler_null),
field_type((enum enum_field_types)MYSQL_TYPE_VIRTUAL), vcol_type((enum_vcol_info_type)VCOL_TYPE_NONE),
in_partitioning_expr(FALSE), stored_in_db(FALSE), in_partitioning_expr(FALSE), stored_in_db(FALSE),
utf8(TRUE), expr(NULL), flags(0) utf8(TRUE), expr(NULL), flags(0)
{ {
...@@ -568,14 +568,11 @@ class Virtual_column_info: public Sql_alloc ...@@ -568,14 +568,11 @@ class Virtual_column_info: public Sql_alloc
DBUG_ASSERT(vcol_type != VCOL_TYPE_NONE); DBUG_ASSERT(vcol_type != VCOL_TYPE_NONE);
return vcol_type_name(vcol_type); return vcol_type_name(vcol_type);
} }
enum_field_types get_real_type() const void set_handler(const Type_handler *handler)
{
return field_type;
}
void set_field_type(enum_field_types fld_type)
{ {
/* Calling this function can only be done once. */ /* Calling this function can only be done once. */
field_type= fld_type; DBUG_ASSERT(type_handler() == &type_handler_null);
Type_handler_hybrid_field_type::set_handler(handler);
} }
bool is_stored() const bool is_stored() const
{ {
......
...@@ -7130,7 +7130,7 @@ bool fix_escape_item(THD *thd, Item *escape_item, String *tmp_str, ...@@ -7130,7 +7130,7 @@ bool fix_escape_item(THD *thd, Item *escape_item, String *tmp_str,
inline bool Virtual_column_info::is_equal(const Virtual_column_info* vcol) const inline bool Virtual_column_info::is_equal(const Virtual_column_info* vcol) const
{ {
return field_type == vcol->get_real_type() return type_handler() == vcol->type_handler()
&& stored_in_db == vcol->is_stored() && stored_in_db == vcol->is_stored()
&& expr->eq(vcol->expr, true); && expr->eq(vcol->expr, true);
} }
......
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