mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge branch '10.3' into 10.4
This commit is contained in:
245
sql/sql_type.h
245
sql/sql_type.h
@ -73,6 +73,7 @@ class handler;
|
||||
struct Schema_specification_st;
|
||||
struct TABLE;
|
||||
struct SORT_FIELD_ATTR;
|
||||
class Vers_history_point;
|
||||
|
||||
|
||||
/**
|
||||
@ -618,7 +619,6 @@ public:
|
||||
{
|
||||
*this= other;
|
||||
}
|
||||
void set(const Field *field);
|
||||
uint32 max_char_length() const
|
||||
{ return max_length / collation.collation->mbmaxlen; }
|
||||
void fix_length_and_charset(uint32 max_char_length_arg, CHARSET_INFO *cs)
|
||||
@ -951,6 +951,74 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class Information_schema_numeric_attributes
|
||||
{
|
||||
enum enum_attr
|
||||
{
|
||||
ATTR_NONE= 0,
|
||||
ATTR_PRECISION= 1,
|
||||
ATTR_SCALE= 2,
|
||||
ATTR_PRECISION_AND_SCALE= (ATTR_PRECISION|ATTR_SCALE)
|
||||
};
|
||||
uint m_precision;
|
||||
uint m_scale;
|
||||
enum_attr m_available_attributes;
|
||||
public:
|
||||
Information_schema_numeric_attributes()
|
||||
:m_precision(0), m_scale(0),
|
||||
m_available_attributes(ATTR_NONE)
|
||||
{ }
|
||||
Information_schema_numeric_attributes(uint precision)
|
||||
:m_precision(precision), m_scale(0),
|
||||
m_available_attributes(ATTR_PRECISION)
|
||||
{ }
|
||||
Information_schema_numeric_attributes(uint precision, uint scale)
|
||||
:m_precision(precision), m_scale(scale),
|
||||
m_available_attributes(ATTR_PRECISION_AND_SCALE)
|
||||
{ }
|
||||
bool has_precision() const { return m_available_attributes & ATTR_PRECISION; }
|
||||
bool has_scale() const { return m_available_attributes & ATTR_SCALE; }
|
||||
uint precision() const
|
||||
{
|
||||
DBUG_ASSERT(has_precision());
|
||||
return (uint) m_precision;
|
||||
}
|
||||
uint scale() const
|
||||
{
|
||||
DBUG_ASSERT(has_scale());
|
||||
return (uint) m_scale;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Information_schema_character_attributes
|
||||
{
|
||||
uint32 m_octet_length;
|
||||
uint32 m_char_length;
|
||||
bool m_is_set;
|
||||
public:
|
||||
Information_schema_character_attributes()
|
||||
:m_octet_length(0), m_char_length(0), m_is_set(false)
|
||||
{ }
|
||||
Information_schema_character_attributes(uint32 octet_length,
|
||||
uint32 char_length)
|
||||
:m_octet_length(octet_length), m_char_length(char_length), m_is_set(true)
|
||||
{ }
|
||||
bool has_octet_length() const { return m_is_set; }
|
||||
bool has_char_length() const { return m_is_set; }
|
||||
uint32 octet_length() const
|
||||
{
|
||||
DBUG_ASSERT(has_octet_length());
|
||||
return m_octet_length;
|
||||
}
|
||||
uint char_length() const
|
||||
{
|
||||
DBUG_ASSERT(has_char_length());
|
||||
return m_char_length;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Type_handler
|
||||
{
|
||||
protected:
|
||||
@ -1430,6 +1498,9 @@ public:
|
||||
Item_func_div_fix_length_and_dec(Item_func_div *func) const= 0;
|
||||
virtual bool
|
||||
Item_func_mod_fix_length_and_dec(Item_func_mod *func) const= 0;
|
||||
|
||||
virtual bool
|
||||
Vers_history_point_resolve_unit(THD *thd, Vers_history_point *point) const;
|
||||
};
|
||||
|
||||
|
||||
@ -1932,6 +2003,131 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class Type_limits_int
|
||||
{
|
||||
private:
|
||||
uint32 m_precision;
|
||||
uint32 m_char_length;
|
||||
public:
|
||||
Type_limits_int(uint32 prec, uint32 nchars)
|
||||
:m_precision(prec), m_char_length(nchars)
|
||||
{ }
|
||||
uint32 precision() const { return m_precision; }
|
||||
uint32 char_length() const { return m_char_length; }
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
UNDIGNED TINYINT: 0..255 digits=3 nchars=3
|
||||
SIGNED TINYINT : -128..127 digits=3 nchars=4
|
||||
*/
|
||||
class Type_limits_uint8: public Type_limits_int
|
||||
{
|
||||
public:
|
||||
Type_limits_uint8()
|
||||
:Type_limits_int(MAX_TINYINT_WIDTH, MAX_TINYINT_WIDTH)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
class Type_limits_sint8: public Type_limits_int
|
||||
{
|
||||
public:
|
||||
Type_limits_sint8()
|
||||
:Type_limits_int(MAX_TINYINT_WIDTH, MAX_TINYINT_WIDTH + 1)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
UNDIGNED SMALLINT: 0..65535 digits=5 nchars=5
|
||||
SIGNED SMALLINT: -32768..32767 digits=5 nchars=6
|
||||
*/
|
||||
class Type_limits_uint16: public Type_limits_int
|
||||
{
|
||||
public:
|
||||
Type_limits_uint16()
|
||||
:Type_limits_int(MAX_SMALLINT_WIDTH, MAX_SMALLINT_WIDTH)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
class Type_limits_sint16: public Type_limits_int
|
||||
{
|
||||
public:
|
||||
Type_limits_sint16()
|
||||
:Type_limits_int(MAX_SMALLINT_WIDTH, MAX_SMALLINT_WIDTH + 1)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
MEDIUMINT UNSIGNED 0 .. 16777215 digits=8 char_length=8
|
||||
MEDIUMINT SIGNED: -8388608 .. 8388607 digits=7 char_length=8
|
||||
*/
|
||||
class Type_limits_uint24: public Type_limits_int
|
||||
{
|
||||
public:
|
||||
Type_limits_uint24()
|
||||
:Type_limits_int(MAX_MEDIUMINT_WIDTH, MAX_MEDIUMINT_WIDTH)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
class Type_limits_sint24: public Type_limits_int
|
||||
{
|
||||
public:
|
||||
Type_limits_sint24()
|
||||
:Type_limits_int(MAX_MEDIUMINT_WIDTH - 1, MAX_MEDIUMINT_WIDTH)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
UNSIGNED INT: 0..4294967295 digits=10 nchars=10
|
||||
SIGNED INT: -2147483648..2147483647 digits=10 nchars=11
|
||||
*/
|
||||
class Type_limits_uint32: public Type_limits_int
|
||||
{
|
||||
public:
|
||||
Type_limits_uint32()
|
||||
:Type_limits_int(MAX_INT_WIDTH, MAX_INT_WIDTH)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
|
||||
class Type_limits_sint32: public Type_limits_int
|
||||
{
|
||||
public:
|
||||
Type_limits_sint32()
|
||||
:Type_limits_int(MAX_INT_WIDTH, MAX_INT_WIDTH + 1)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
UNSIGNED BIGINT: 0..18446744073709551615 digits=20 nchars=20
|
||||
SIGNED BIGINT: -9223372036854775808..9223372036854775807 digits=19 nchars=20
|
||||
*/
|
||||
class Type_limits_uint64: public Type_limits_int
|
||||
{
|
||||
public:
|
||||
Type_limits_uint64(): Type_limits_int(MAX_BIGINT_WIDTH, MAX_BIGINT_WIDTH)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
class Type_limits_sint64: public Type_limits_int
|
||||
{
|
||||
public:
|
||||
Type_limits_sint64()
|
||||
:Type_limits_int(MAX_BIGINT_WIDTH - 1, MAX_BIGINT_WIDTH)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
|
||||
class Type_handler_int_result: public Type_handler_numeric
|
||||
{
|
||||
public:
|
||||
@ -2007,6 +2203,10 @@ class Type_handler_general_purpose_int: public Type_handler_int_result
|
||||
{
|
||||
public:
|
||||
bool type_can_have_auto_increment_attribute() const { return true; }
|
||||
virtual const Type_limits_int *
|
||||
type_limits_int_by_unsigned_flag(bool unsigned_flag) const= 0;
|
||||
uint32 max_display_length(const Item *item) const;
|
||||
bool Vers_history_point_resolve_unit(THD *thd, Vers_history_point *p) const;
|
||||
};
|
||||
|
||||
|
||||
@ -2076,6 +2276,7 @@ public:
|
||||
bool Item_func_mul_fix_length_and_dec(Item_func_mul *) const;
|
||||
bool Item_func_div_fix_length_and_dec(Item_func_div *) const;
|
||||
bool Item_func_mod_fix_length_and_dec(Item_func_mod *) const;
|
||||
bool Vers_history_point_resolve_unit(THD *thd, Vers_history_point *p) const;
|
||||
};
|
||||
|
||||
|
||||
@ -2200,6 +2401,7 @@ class Type_handler_general_purpose_string: public Type_handler_string_result
|
||||
{
|
||||
public:
|
||||
bool is_general_purpose_string_type() const { return true; }
|
||||
bool Vers_history_point_resolve_unit(THD *thd, Vers_history_point *p) const;
|
||||
};
|
||||
|
||||
|
||||
@ -2226,11 +2428,16 @@ public:
|
||||
class Type_handler_tiny: public Type_handler_general_purpose_int
|
||||
{
|
||||
static const Name m_name_tiny;
|
||||
static const Type_limits_int m_limits_sint8;
|
||||
static const Type_limits_int m_limits_uint8;
|
||||
public:
|
||||
virtual ~Type_handler_tiny() {}
|
||||
const Name name() const { return m_name_tiny; }
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_TINY; }
|
||||
uint32 max_display_length(const Item *item) const { return 4; }
|
||||
const Type_limits_int *type_limits_int_by_unsigned_flag(bool unsigned_fl) const
|
||||
{
|
||||
return unsigned_fl ? &m_limits_uint8 : &m_limits_sint8;
|
||||
}
|
||||
uint32 calc_pack_length(uint32 length) const { return 1; }
|
||||
bool Item_send(Item *item, Protocol *protocol, st_value *buf) const
|
||||
{
|
||||
@ -2262,6 +2469,8 @@ public:
|
||||
class Type_handler_short: public Type_handler_general_purpose_int
|
||||
{
|
||||
static const Name m_name_short;
|
||||
static const Type_limits_int m_limits_sint16;
|
||||
static const Type_limits_int m_limits_uint16;
|
||||
public:
|
||||
virtual ~Type_handler_short() {}
|
||||
const Name name() const { return m_name_short; }
|
||||
@ -2270,7 +2479,10 @@ public:
|
||||
{
|
||||
return Item_send_short(item, protocol, buf);
|
||||
}
|
||||
uint32 max_display_length(const Item *item) const { return 6; }
|
||||
const Type_limits_int *type_limits_int_by_unsigned_flag(bool unsigned_fl) const
|
||||
{
|
||||
return unsigned_fl ? &m_limits_uint16 : &m_limits_sint16;
|
||||
}
|
||||
uint32 calc_pack_length(uint32 length) const { return 2; }
|
||||
Field *make_conversion_table_field(TABLE *TABLE, uint metadata,
|
||||
const Field *target) const;
|
||||
@ -2298,13 +2510,15 @@ public:
|
||||
class Type_handler_long: public Type_handler_general_purpose_int
|
||||
{
|
||||
static const Name m_name_int;
|
||||
static const Type_limits_int m_limits_sint32;
|
||||
static const Type_limits_int m_limits_uint32;
|
||||
public:
|
||||
virtual ~Type_handler_long() {}
|
||||
const Name name() const { return m_name_int; }
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_LONG; }
|
||||
uint32 max_display_length(const Item *item) const
|
||||
const Type_limits_int *type_limits_int_by_unsigned_flag(bool unsigned_fl) const
|
||||
{
|
||||
return MY_INT32_NUM_DECIMAL_DIGITS;
|
||||
return unsigned_fl ? &m_limits_uint32 : &m_limits_sint32;
|
||||
}
|
||||
uint32 calc_pack_length(uint32 length) const { return 4; }
|
||||
bool Item_send(Item *item, Protocol *protocol, st_value *buf) const
|
||||
@ -2347,11 +2561,16 @@ public:
|
||||
class Type_handler_longlong: public Type_handler_general_purpose_int
|
||||
{
|
||||
static const Name m_name_longlong;
|
||||
static const Type_limits_int m_limits_sint64;
|
||||
static const Type_limits_int m_limits_uint64;
|
||||
public:
|
||||
virtual ~Type_handler_longlong() {}
|
||||
const Name name() const { return m_name_longlong; }
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
|
||||
uint32 max_display_length(const Item *item) const { return 20; }
|
||||
const Type_limits_int *type_limits_int_by_unsigned_flag(bool unsigned_fl) const
|
||||
{
|
||||
return unsigned_fl ? &m_limits_uint64 : &m_limits_sint64;
|
||||
}
|
||||
uint32 calc_pack_length(uint32 length) const { return 8; }
|
||||
Item *create_typecast_item(THD *thd, Item *item,
|
||||
const Type_cast_attributes &attr) const;
|
||||
@ -2398,6 +2617,8 @@ public:
|
||||
class Type_handler_int24: public Type_handler_general_purpose_int
|
||||
{
|
||||
static const Name m_name_mediumint;
|
||||
static const Type_limits_int m_limits_sint24;
|
||||
static const Type_limits_int m_limits_uint24;
|
||||
public:
|
||||
virtual ~Type_handler_int24() {}
|
||||
const Name name() const { return m_name_mediumint; }
|
||||
@ -2406,7 +2627,10 @@ public:
|
||||
{
|
||||
return Item_send_long(item, protocol, buf);
|
||||
}
|
||||
uint32 max_display_length(const Item *item) const { return 8; }
|
||||
const Type_limits_int *type_limits_int_by_unsigned_flag(bool unsigned_fl) const
|
||||
{
|
||||
return unsigned_fl ? &m_limits_uint24 : &m_limits_sint24;
|
||||
}
|
||||
uint32 calc_pack_length(uint32 length) const { return 3; }
|
||||
Field *make_conversion_table_field(TABLE *, uint metadata,
|
||||
const Field *target) const;
|
||||
@ -2509,6 +2733,7 @@ public:
|
||||
const Bit_addr &bit,
|
||||
const Column_definition_attributes *attr,
|
||||
uint32 flags) const;
|
||||
bool Vers_history_point_resolve_unit(THD *thd, Vers_history_point *p) const;
|
||||
};
|
||||
|
||||
|
||||
@ -3455,6 +3680,7 @@ public:
|
||||
const;
|
||||
void Item_param_set_param_func(Item_param *param,
|
||||
uchar **pos, ulong len) const;
|
||||
bool Vers_history_point_resolve_unit(THD *thd, Vers_history_point *p) const;
|
||||
};
|
||||
|
||||
|
||||
@ -3534,16 +3760,15 @@ public:
|
||||
class Type_handler_hybrid_field_type
|
||||
{
|
||||
const Type_handler *m_type_handler;
|
||||
bool m_vers_trx_id;
|
||||
bool aggregate_for_min_max(const Type_handler *other);
|
||||
|
||||
public:
|
||||
Type_handler_hybrid_field_type();
|
||||
Type_handler_hybrid_field_type(const Type_handler *handler)
|
||||
:m_type_handler(handler), m_vers_trx_id(false)
|
||||
:m_type_handler(handler)
|
||||
{ }
|
||||
Type_handler_hybrid_field_type(const Type_handler_hybrid_field_type *other)
|
||||
:m_type_handler(other->m_type_handler), m_vers_trx_id(other->m_vers_trx_id)
|
||||
:m_type_handler(other->m_type_handler)
|
||||
{ }
|
||||
void swap(Type_handler_hybrid_field_type &other)
|
||||
{
|
||||
|
Reference in New Issue
Block a user