mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-12588 Add Type_handler::type_handler_for_tmp_table() and Type_handler::type_handler_for_union()
1. Implementing the task according to the description: a. Adding Type_handler::type_handler_for_tmp_table(). b. Adding Type_handler::type_handler_for_union_table. c. Adding helper methods Type_handler::varstring_type_handler(const Item*), Type_handler::blob_type_handler(const Item*) d. Removing Item::make_string_field() and Item_func_group_concat::make_string_field(). They are not needed any more. e. Simplifying Item::tmp_table_field_from_field_type() to just two lines. f. Renaming Item_type_holder::make_field_by_type() and implementing virtual Item_type_holder::create_tmp_field() instead. The new implementation is also as simple as two lines. g. Adding a new virtual method Type_all_attributes::get_typelib(), to access to TYPELIB definitions for ENUM and SET columns. h. Simplifying the code branch for TIME_RESULT, DECIMAL_RESULT, STRING_RESULT in Item::create_tmp_field(). It's now just one line. i. Implementing Type_handler_enum::make_table_field() and Type_handler_set::make_table_field(). 2. Code simplification in Field_str constructor calls. a. Changing the "CHARSET_INFO *cs" argument in constuctors for Field_str and its descendants to "const DTCollation &collation". This is to avoid two step initialization: - setting Field_str::derivation and Field_str::repertoire to the default values first - then resetting them using: set_derivation(item->derivation, item->repertoire). b. Removing Field::set_derivation() c. Adding a new constructor DTCollation(CHARSET_INFO *cs), for the old code compatibility. 3. Changes in test results As a side effect some test results have changed, because in the old version Item::make_string_field() converted TINYBLOB to VARCHAR(255). Now TINYBLOB is preserved. a. sp-row.result This query: CREATE TABLE t1 AS SELECT tinyblob_sp_variable; Now preserves TINYBLOB as the data type. Before the patch a VARCHAR(255) was created. b. gis-debug.result This is a debug test, to make sure that + and - operators are commutative and non-commutative correspondingly. The exact data type is not really important. (But anyway, it now chooses a better data type that fits the result)
This commit is contained in:
@ -130,6 +130,21 @@ public:
|
||||
derivation= DERIVATION_NONE;
|
||||
repertoire= MY_REPERTOIRE_UNICODE30;
|
||||
}
|
||||
DTCollation(CHARSET_INFO *collation_arg)
|
||||
{
|
||||
/*
|
||||
This constructor version is used in combination with Field constructors,
|
||||
to pass "CHARSET_INFO" instead of the full DTCollation.
|
||||
Therefore, derivation is set to DERIVATION_IMPLICIT, which is the
|
||||
proper derivation for table fields.
|
||||
We should eventually remove all code pieces that pass "CHARSET_INFO"
|
||||
(e.g. in storage engine sources) and fix to pass the full DTCollation
|
||||
instead. Then, this constructor can be removed.
|
||||
*/
|
||||
collation= collation_arg;
|
||||
derivation= DERIVATION_IMPLICIT;
|
||||
repertoire= my_charset_repertoire(collation_arg);
|
||||
}
|
||||
DTCollation(CHARSET_INFO *collation_arg, Derivation derivation_arg)
|
||||
{
|
||||
collation= collation_arg;
|
||||
@ -332,6 +347,7 @@ public:
|
||||
datatype indepented method.
|
||||
*/
|
||||
virtual uint uint_geometry_type() const= 0;
|
||||
virtual TYPELIB *get_typelib() const { return NULL; }
|
||||
};
|
||||
|
||||
|
||||
@ -390,6 +406,15 @@ protected:
|
||||
public:
|
||||
static const Type_handler *blob_type_handler(uint max_octet_length);
|
||||
static const Type_handler *string_type_handler(uint max_octet_length);
|
||||
/**
|
||||
Return a string type handler for Item
|
||||
If too_big_for_varchar() returns a BLOB variant, according to length.
|
||||
If max_length > 0 create a VARCHAR(n)
|
||||
If max_length == 0 create a CHAR(0)
|
||||
@param item - the Item to get the handler to.
|
||||
*/
|
||||
static const Type_handler *varstring_type_handler(const Item *item);
|
||||
static const Type_handler *blob_type_handler(const Item *item);
|
||||
static const Type_handler *get_handler_by_field_type(enum_field_types type);
|
||||
static const Type_handler *get_handler_by_real_type(enum_field_types type);
|
||||
static const Type_handler *get_handler_by_cmp_type(Item_result type);
|
||||
@ -426,6 +451,14 @@ public:
|
||||
*/
|
||||
virtual bool is_param_long_data_type() const { return false; }
|
||||
virtual const Type_handler *type_handler_for_comparison() const= 0;
|
||||
virtual const Type_handler *type_handler_for_tmp_table(const Item *) const
|
||||
{
|
||||
return this;
|
||||
}
|
||||
virtual const Type_handler *type_handler_for_union(const Item *) const
|
||||
{
|
||||
return this;
|
||||
}
|
||||
virtual const Type_handler *cast_to_int_type_handler() const
|
||||
{
|
||||
return this;
|
||||
@ -1594,6 +1627,8 @@ public:
|
||||
virtual ~Type_handler_olddecimal() {}
|
||||
const Name name() const { return m_name_decimal; }
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_DECIMAL; }
|
||||
const Type_handler *type_handler_for_tmp_table(const Item *item) const;
|
||||
const Type_handler *type_handler_for_union(const Item *item) const;
|
||||
Field *make_conversion_table_field(TABLE *, uint metadata,
|
||||
const Field *target) const;
|
||||
Field *make_table_field(const LEX_CSTRING *name,
|
||||
@ -1627,6 +1662,8 @@ public:
|
||||
const Name name() const { return m_name_null; }
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_NULL; }
|
||||
const Type_handler *type_handler_for_comparison() const;
|
||||
const Type_handler *type_handler_for_tmp_table(const Item *item) const;
|
||||
const Type_handler *type_handler_for_union(const Item *) const;
|
||||
uint32 max_display_length(const Item *item) const { return 0; }
|
||||
Field *make_conversion_table_field(TABLE *, uint metadata,
|
||||
const Field *target) const;
|
||||
@ -1645,6 +1682,10 @@ public:
|
||||
const Name name() const { return m_name_char; }
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_STRING; }
|
||||
bool is_param_long_data_type() const { return true; }
|
||||
const Type_handler *type_handler_for_tmp_table(const Item *item) const
|
||||
{
|
||||
return varstring_type_handler(item);
|
||||
}
|
||||
Field *make_conversion_table_field(TABLE *, uint metadata,
|
||||
const Field *target) const;
|
||||
Field *make_table_field(const LEX_CSTRING *name,
|
||||
@ -1663,6 +1704,14 @@ public:
|
||||
const Name name() const { return m_name_var_string; }
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_VAR_STRING; }
|
||||
enum_field_types real_field_type() const { return MYSQL_TYPE_STRING; }
|
||||
const Type_handler *type_handler_for_tmp_table(const Item *item) const
|
||||
{
|
||||
return varstring_type_handler(item);
|
||||
}
|
||||
const Type_handler *type_handler_for_union(const Item *item) const
|
||||
{
|
||||
return varstring_type_handler(item);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -1673,6 +1722,14 @@ public:
|
||||
virtual ~Type_handler_varchar() {}
|
||||
const Name name() const { return m_name_varchar; }
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; }
|
||||
const Type_handler *type_handler_for_tmp_table(const Item *item) const
|
||||
{
|
||||
return varstring_type_handler(item);
|
||||
}
|
||||
const Type_handler *type_handler_for_union(const Item *item) const
|
||||
{
|
||||
return varstring_type_handler(item);
|
||||
}
|
||||
bool is_param_long_data_type() const { return true; }
|
||||
Field *make_conversion_table_field(TABLE *, uint metadata,
|
||||
const Field *target) const;
|
||||
@ -1687,6 +1744,14 @@ class Type_handler_blob_common: public Type_handler_string_result
|
||||
{
|
||||
public:
|
||||
virtual ~Type_handler_blob_common() { }
|
||||
const Type_handler *type_handler_for_tmp_table(const Item *item) const
|
||||
{
|
||||
return blob_type_handler(item);
|
||||
}
|
||||
const Type_handler *type_handler_for_union(const Item *item) const
|
||||
{
|
||||
return blob_type_handler(item);
|
||||
}
|
||||
bool subquery_type_allows_materialization(const Item *inner,
|
||||
const Item *outer) const
|
||||
{
|
||||
|
Reference in New Issue
Block a user