diff options
Diffstat (limited to 'sql/sql_type.h')
-rw-r--r-- | sql/sql_type.h | 64 |
1 files changed, 57 insertions, 7 deletions
diff --git a/sql/sql_type.h b/sql/sql_type.h index 5ce17447..b092433b 100644 --- a/sql/sql_type.h +++ b/sql/sql_type.h @@ -3836,6 +3836,16 @@ public: const Type_handler *res= type_handler_base(); return res ? res : this; } + /* + In 10.11.8 the semantics of this method has changed to the opposite. + It used to be called with the old data type handler as "this". + Now it's called with the new data type hander as "this". + To avoid problems during merges, the method name was renamed. + */ + virtual const Type_handler *type_handler_for_implicit_upgrade() const + { + return this; + } virtual const Type_handler *type_handler_for_comparison() const= 0; virtual const Type_handler *type_handler_for_native_format() const { @@ -3981,9 +3991,13 @@ public: virtual bool validate_implicit_default_value(THD *thd, const Column_definition &def) const; - // Automatic upgrade, e.g. for ALTER TABLE t1 FORCE - virtual void Column_definition_implicit_upgrade(Column_definition *c) const - { } + /* + Automatic upgrade, e.g. for REPAIR or ALTER TABLE t1 FORCE + - from the data type specified in old->type_handler() + - to the data type specified in "this" + */ + virtual void Column_definition_implicit_upgrade_to_this( + Column_definition *old) const; // Validate CHECK constraint after the parser virtual bool Column_definition_validate_check_constraint(THD *thd, Column_definition *c) @@ -5773,6 +5787,38 @@ public: }; +/* + The expression of this type reports itself as signed, + however it's known not to return negative values. + Items of this data type count only digits in Item::max_length, + without adding +1 for the sign. This allows expressions + of this type convert nicely to VARCHAR and DECIMAL. + For example, YEAR(now()) is: + - VARCHAR(4) in a string context + - DECIMAL(4,0) in a decimal context + - but INT(5) in an integer context +*/ +class Type_handler_long_ge0: public Type_handler_long +{ +public: + decimal_digits_t Item_decimal_precision(const Item *item) const override; + bool Item_func_signed_fix_length_and_dec(Item_func_signed *item) + const override; + bool Item_func_unsigned_fix_length_and_dec(Item_func_unsigned *item) + const override; + bool Item_func_abs_fix_length_and_dec(Item_func_abs *) const override; + bool Item_func_round_fix_length_and_dec(Item_func_round *) const override; + bool Item_sum_hybrid_fix_length_and_dec(Item_sum_hybrid *func) const override; + Field *make_table_field_from_def(TABLE_SHARE *share, + MEM_ROOT *mem_root, + const LEX_CSTRING *name, + const Record_addr &addr, + const Bit_addr &bit, + const Column_definition_attributes *attr, + uint32 flags) const override; +}; + + class Type_handler_ulong: public Type_handler_long { public: @@ -6188,7 +6234,8 @@ public: const Type_handler *type_handler_for_comparison() const override; int stored_field_cmp_to_item(THD *thd, Field *field, Item *item) const override; - void Column_definition_implicit_upgrade(Column_definition *c) const override; + void Column_definition_implicit_upgrade_to_this( + Column_definition *old) const override; bool Column_definition_fix_attributes(Column_definition *c) const override; bool Column_definition_attributes_frm_unpack(Column_definition_attributes *attr, @@ -6512,7 +6559,8 @@ public: const Type_cast_attributes &attr) const override; bool validate_implicit_default_value(THD *thd, const Column_definition &def) const override; - void Column_definition_implicit_upgrade(Column_definition *c) const override; + void Column_definition_implicit_upgrade_to_this( + Column_definition *old) const override; bool Column_definition_fix_attributes(Column_definition *c) const override; bool Column_definition_attributes_frm_unpack(Column_definition_attributes *attr, @@ -6650,7 +6698,8 @@ public: { return true; } - void Column_definition_implicit_upgrade(Column_definition *c) const override; + void Column_definition_implicit_upgrade_to_this( + Column_definition *old) const override; bool Column_definition_attributes_frm_unpack(Column_definition_attributes *attr, TABLE_SHARE *share, @@ -7000,6 +7049,7 @@ public: { return MYSQL_TYPE_VARCHAR; } + const Type_handler *type_handler_for_implicit_upgrade() const override; const Type_handler *type_handler_for_tmp_table(const Item *item) const override { return varstring_type_handler(item); @@ -7007,7 +7057,6 @@ public: uint32 max_display_length_for_field(const Conv_source &src) const override; void show_binlog_type(const Conv_source &src, const Field &dst, String *str) const override; - void Column_definition_implicit_upgrade(Column_definition *c) const override; bool Column_definition_fix_attributes(Column_definition *c) const override; bool Column_definition_prepare_stage2(Column_definition *c, handler *file, @@ -7607,6 +7656,7 @@ extern MYSQL_PLUGIN_IMPORT Named_type_handler<Type_handler_tiny> type_han extern MYSQL_PLUGIN_IMPORT Named_type_handler<Type_handler_short> type_handler_sshort; extern MYSQL_PLUGIN_IMPORT Named_type_handler<Type_handler_int24> type_handler_sint24; extern MYSQL_PLUGIN_IMPORT Named_type_handler<Type_handler_long> type_handler_slong; +extern MYSQL_PLUGIN_IMPORT Named_type_handler<Type_handler_long_ge0> type_handler_slong_ge0; extern MYSQL_PLUGIN_IMPORT Named_type_handler<Type_handler_longlong> type_handler_slonglong; extern Named_type_handler<Type_handler_utiny> type_handler_utiny; |