@@ -1221,7 +1221,7 @@ class Field: public Value_source
1221
1221
void make_sort_key (uchar *buff, uint length);
1222
1222
virtual void make_field (Send_field *);
1223
1223
virtual void sort_string (uchar *buff,uint length)=0;
1224
- virtual bool optimize_range (uint idx, uint part);
1224
+ virtual bool optimize_range (uint idx, uint part) const ;
1225
1225
virtual void free () {}
1226
1226
virtual Field *make_new_field (MEM_ROOT *root, TABLE *new_table,
1227
1227
bool keep_type);
@@ -1678,9 +1678,6 @@ class Field_num :public Field {
1678
1678
!((flags & UNSIGNED_FLAG) && !(from->flags & UNSIGNED_FLAG)) &&
1679
1679
decimals () == from->decimals ();
1680
1680
}
1681
- int store_decimal (const my_decimal *);
1682
- my_decimal *val_decimal (my_decimal *);
1683
- bool val_bool () { return val_int () != 0 ; }
1684
1681
uint is_equal (Create_field *new_field);
1685
1682
uint row_pack_length () const { return pack_length (); }
1686
1683
uint32 pack_length_from_metadata (uint field_metadata) {
@@ -1689,12 +1686,10 @@ class Field_num :public Field {
1689
1686
field_metadata, length));
1690
1687
return length;
1691
1688
}
1692
- int store_time_dec (const MYSQL_TIME *ltime, uint dec);
1693
1689
double pos_in_interval (Field *min, Field *max)
1694
1690
{
1695
1691
return pos_in_interval_val_real (min, max);
1696
1692
}
1697
- bool get_date (MYSQL_TIME *ltime, ulonglong fuzzydate);
1698
1693
};
1699
1694
1700
1695
@@ -1954,15 +1949,35 @@ class Field_new_decimal :public Field_num {
1954
1949
};
1955
1950
1956
1951
1957
- class Field_tiny :public Field_num {
1952
+ class Field_int :public Field_num
1953
+ {
1954
+ protected:
1955
+ String *val_str_from_long (String *val_buffer, uint max_char_length,
1956
+ int radix, long nr);
1957
+ public:
1958
+ Field_int (uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
1959
+ uchar null_bit_arg, enum utype unireg_check_arg,
1960
+ const LEX_CSTRING *field_name_arg, bool zero_arg, bool unsigned_arg)
1961
+ :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
1962
+ unireg_check_arg, field_name_arg, 0 , zero_arg, unsigned_arg)
1963
+ {}
1964
+ int store_decimal (const my_decimal *);
1965
+ my_decimal *val_decimal (my_decimal *);
1966
+ bool val_bool () { return val_int () != 0 ; }
1967
+ int store_time_dec (const MYSQL_TIME *ltime, uint dec);
1968
+ bool get_date (MYSQL_TIME *ltime, ulonglong fuzzydate);
1969
+ };
1970
+
1971
+
1972
+ class Field_tiny :public Field_int
1973
+ {
1958
1974
public:
1959
1975
Field_tiny (uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
1960
1976
uchar null_bit_arg,
1961
1977
enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
1962
1978
bool zero_arg, bool unsigned_arg)
1963
- :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
1964
- unireg_check_arg, field_name_arg,
1965
- 0 , zero_arg,unsigned_arg)
1979
+ :Field_int(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
1980
+ unireg_check_arg, field_name_arg, zero_arg, unsigned_arg)
1966
1981
{}
1967
1982
const Type_handler *type_handler () const { return &type_handler_tiny; }
1968
1983
enum ha_base_keytype key_type () const
@@ -1998,21 +2013,21 @@ class Field_tiny :public Field_num {
1998
2013
};
1999
2014
2000
2015
2001
- class Field_short :public Field_num {
2016
+ class Field_short :public Field_int
2017
+ {
2002
2018
public:
2003
2019
Field_short (uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
2004
2020
uchar null_bit_arg,
2005
2021
enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
2006
2022
bool zero_arg, bool unsigned_arg)
2007
- :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
2008
- unireg_check_arg, field_name_arg,
2009
- 0 , zero_arg,unsigned_arg)
2023
+ :Field_int(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
2024
+ unireg_check_arg, field_name_arg, zero_arg, unsigned_arg)
2010
2025
{}
2011
2026
Field_short (uint32 len_arg,bool maybe_null_arg,
2012
2027
const LEX_CSTRING *field_name_arg,
2013
2028
bool unsigned_arg)
2014
- :Field_num ((uchar*) 0 , len_arg, maybe_null_arg ? (uchar*) " " : 0 ,0 ,
2015
- NONE, field_name_arg, 0 , 0 , unsigned_arg)
2029
+ :Field_int ((uchar*) 0 , len_arg, maybe_null_arg ? (uchar*) " " : 0 ,0 ,
2030
+ NONE, field_name_arg, 0 , unsigned_arg)
2016
2031
{}
2017
2032
const Type_handler *type_handler () const { return &type_handler_short; }
2018
2033
enum ha_base_keytype key_type () const
@@ -2039,15 +2054,15 @@ class Field_short :public Field_num {
2039
2054
{ return unpack_int16 (to, from, from_end); }
2040
2055
};
2041
2056
2042
- class Field_medium :public Field_num {
2057
+ class Field_medium :public Field_int
2058
+ {
2043
2059
public:
2044
2060
Field_medium (uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
2045
2061
uchar null_bit_arg,
2046
2062
enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
2047
2063
bool zero_arg, bool unsigned_arg)
2048
- :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
2049
- unireg_check_arg, field_name_arg,
2050
- 0 , zero_arg,unsigned_arg)
2064
+ :Field_int(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
2065
+ unireg_check_arg, field_name_arg, zero_arg, unsigned_arg)
2051
2066
{}
2052
2067
const Type_handler *type_handler () const { return &type_handler_int24; }
2053
2068
enum ha_base_keytype key_type () const
@@ -2073,21 +2088,21 @@ class Field_medium :public Field_num {
2073
2088
};
2074
2089
2075
2090
2076
- class Field_long :public Field_num {
2091
+ class Field_long :public Field_int
2092
+ {
2077
2093
public:
2078
2094
Field_long (uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
2079
2095
uchar null_bit_arg,
2080
2096
enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
2081
2097
bool zero_arg, bool unsigned_arg)
2082
- :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
2083
- unireg_check_arg, field_name_arg,
2084
- 0 , zero_arg,unsigned_arg)
2098
+ :Field_int(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
2099
+ unireg_check_arg, field_name_arg, zero_arg, unsigned_arg)
2085
2100
{}
2086
2101
Field_long (uint32 len_arg,bool maybe_null_arg,
2087
2102
const LEX_CSTRING *field_name_arg,
2088
2103
bool unsigned_arg)
2089
- :Field_num ((uchar*) 0 , len_arg, maybe_null_arg ? (uchar*) " " : 0 ,0 ,
2090
- NONE, field_name_arg,0 , 0 , unsigned_arg)
2104
+ :Field_int ((uchar*) 0 , len_arg, maybe_null_arg ? (uchar*) " " : 0 ,0 ,
2105
+ NONE, field_name_arg, 0 , unsigned_arg)
2091
2106
{}
2092
2107
const Type_handler *type_handler () const { return &type_handler_long; }
2093
2108
enum ha_base_keytype key_type () const
@@ -2119,21 +2134,21 @@ class Field_long :public Field_num {
2119
2134
};
2120
2135
2121
2136
2122
- class Field_longlong :public Field_num {
2137
+ class Field_longlong :public Field_int
2138
+ {
2123
2139
public:
2124
2140
Field_longlong (uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
2125
2141
uchar null_bit_arg,
2126
2142
enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
2127
2143
bool zero_arg, bool unsigned_arg)
2128
- :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
2129
- unireg_check_arg, field_name_arg,
2130
- 0 , zero_arg,unsigned_arg)
2144
+ :Field_int(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
2145
+ unireg_check_arg, field_name_arg, zero_arg, unsigned_arg)
2131
2146
{}
2132
2147
Field_longlong (uint32 len_arg,bool maybe_null_arg,
2133
2148
const LEX_CSTRING *field_name_arg,
2134
2149
bool unsigned_arg)
2135
- :Field_num ((uchar*) 0 , len_arg, maybe_null_arg ? (uchar*) " " : 0 ,0 ,
2136
- NONE, field_name_arg,0 , 0 , unsigned_arg)
2150
+ :Field_int ((uchar*) 0 , len_arg, maybe_null_arg ? (uchar*) " " : 0 ,0 ,
2151
+ NONE, field_name_arg, 0 , unsigned_arg)
2137
2152
{}
2138
2153
const Type_handler *type_handler () const { return &type_handler_longlong; }
2139
2154
enum ha_base_keytype key_type () const
@@ -3807,7 +3822,7 @@ class Field_enum :public Field_str {
3807
3822
{ return (field_metadata & 0x00ff ); }
3808
3823
uint row_pack_length () const { return pack_length (); }
3809
3824
virtual bool zero_pack () const { return 0 ; }
3810
- bool optimize_range (uint idx, uint part) { return 0 ; }
3825
+ bool optimize_range (uint idx, uint part) const { return 0 ; }
3811
3826
bool eq_def (const Field *field) const ;
3812
3827
bool has_charset (void ) const { return TRUE ; }
3813
3828
/* enum and set are sorted as integers */
0 commit comments