From a82e42fd133949b560790c9b74a4072f899baee4 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Mon, 17 Jun 2019 16:54:47 +0300 Subject: NFC: refactor Field::is_equal() and related stuff Make Field::is_equal() const and return bool as it's a naturally fitting type for it. Also it's agrument was narrowed to Column_definition. InnoDB can change type of some columns by itself. InnoDB-specific code used to reside in Field_xxx:is_equal() methods. Now engine-specific stuff was moved to a virtual methods of handler::can_convert{string,varstring,blob,geom}. These methods are called by Field::can_be_converted_by_engine() which is a double dispatch pattern. Some InnoDB-specific code still resides in compare_keys_but_name(). It should be moved from here someday to handler::compare_key_parts(...) or similar. IS_EQUAL_WITH_REINTERPRET_COMPATIBLE_CHARSET IS_EQUAL_WITH_REINTERPRET_COMPATIBLE_CHARSET_BUT_COLLATE: both was removed IS_EQUAL_NO, IS_EQUAL_YES are not needed now and should be removed along with deprecated handler::check_if_incompatible_data(). HA_EXTENDED_TYPES_CONVERSION: was removed as such logic is not needed now by server code. ALTER_COLUMN_EQUAL_PACK_LENGTH: was renamed to a more generic ALTER_COLUMN_TYPE_CHANGE_BY_ENGINE --- sql/handler.h | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) (limited to 'sql/handler.h') diff --git a/sql/handler.h b/sql/handler.h index 94e7ddef5b1..e144cbc6642 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -49,6 +49,11 @@ class Alter_info; class Virtual_column_info; class sequence_definition; class Rowid_filter; +class Field_string; +class Field_varstring; +class Field_blob; +class Field_geom; +class Column_definition; // the following is for checking tables @@ -321,10 +326,6 @@ enum enum_alter_inplace_result { /* Safe for online backup */ #define HA_CAN_ONLINE_BACKUPS (1ULL << 56) -/** whether every data field explicitly stores length -(holds for InnoDB ROW_FORMAT=REDUNDANT) */ -#define HA_EXTENDED_TYPES_CONVERSION (1ULL << 57) - /* Support native hash index */ #define HA_CAN_HASH_KEYS (1ULL << 58) #define HA_LAST_TABLE_FLAG HA_CAN_HASH_KEYS @@ -706,13 +707,9 @@ typedef ulonglong alter_table_operations; #define ALTER_VIRTUAL_COLUMN_TYPE (1ULL << 47) #define ALTER_STORED_COLUMN_TYPE (1ULL << 48) -/** - Change column datatype in such way that new type has compatible - packed representation with old type, so it is theoretically - possible to perform change by only updating data dictionary - without changing table rows. -*/ -#define ALTER_COLUMN_EQUAL_PACK_LENGTH (1ULL << 49) + +// Engine can handle type change by itself in ALGORITHM=INPLACE +#define ALTER_COLUMN_TYPE_CHANGE_BY_ENGINE (1ULL << 49) // Reorder column #define ALTER_STORED_COLUMN_ORDER (1ULL << 50) @@ -4815,6 +4812,32 @@ public: virtual bool is_clustering_key(uint index) { return false; } + /** + Some engines can perform column type conversion with ALGORITHM=INPLACE. + These functions check for such possibility. + Implementation could be based on Field_xxx::is_equal() + */ + virtual bool can_convert_string(const Field_string *field, + const Column_definition &new_type) const + { + return false; + } + virtual bool can_convert_varstring(const Field_varstring *field, + const Column_definition &new_type) const + { + return false; + } + virtual bool can_convert_blob(const Field_blob *field, + const Column_definition &new_type) const + { + return false; + } + virtual bool can_convert_geom(const Field_geom *field, + const Column_definition &new_type) const + { + return false; + } + protected: Handler_share *get_ha_share_ptr(); void set_ha_share_ptr(Handler_share *arg_ha_share); -- cgit v1.2.1