diff options
author | unknown <bell@sanja.is.com.ua> | 2005-03-31 10:39:48 +0300 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2005-03-31 10:39:48 +0300 |
commit | 8a898a0b72ad14b87608c84f6b775eb586a070a2 (patch) | |
tree | f46f9a882d5aee1bf10b26d0a45bd5280198b309 /sql/field.h | |
parent | 3a44dcd1a3b8b9e23200c3527bb43850ffdb8ece (diff) | |
parent | 30c85129548f7d8267fab809a723672161c6fce9 (diff) | |
download | mariadb-git-8a898a0b72ad14b87608c84f6b775eb586a070a2.tar.gz |
merge 4.1->5.0
mysql-test/r/group_by.result:
Auto merged
mysql-test/r/metadata.result:
Auto merged
mysql-test/r/union.result:
Auto merged
mysql-test/t/union.test:
Auto merged
sql/item.h:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_select.cc:
Auto merged
support-files/mysql.server.sh:
Auto merged
Diffstat (limited to 'sql/field.h')
-rw-r--r-- | sql/field.h | 49 |
1 files changed, 13 insertions, 36 deletions
diff --git a/sql/field.h b/sql/field.h index 16fa4a58d0c..84d5027dc96 100644 --- a/sql/field.h +++ b/sql/field.h @@ -31,6 +31,17 @@ class Protocol; struct st_cache_field; void field_conv(Field *to,Field *from); +inline uint get_enum_pack_length(int elements) +{ + return elements < 256 ? 1 : 2; +} + +inline uint get_set_pack_length(int elements) +{ + uint len= (elements + 7) / 8; + return len > 4 ? 8 : len; +} + class Field { Field(const Item &); /* Prevent use of these */ @@ -71,18 +82,6 @@ public: GEOM_GEOMETRYCOLLECTION = 7 }; enum imagetype { itRAW, itMBR}; - enum field_cast_enum - { - FIELD_CAST_STOP, FIELD_CAST_DECIMAL, FIELD_CAST_TINY, FIELD_CAST_SHORT, - FIELD_CAST_MEDIUM, FIELD_CAST_LONG, FIELD_CAST_LONGLONG, - FIELD_CAST_FLOAT, FIELD_CAST_DOUBLE, - FIELD_CAST_NULL, - FIELD_CAST_TIMESTAMP, FIELD_CAST_YEAR, FIELD_CAST_DATE, FIELD_CAST_NEWDATE, - FIELD_CAST_TIME, FIELD_CAST_DATETIME, - FIELD_CAST_STRING, FIELD_CAST_VARSTRING, FIELD_CAST_BLOB, - FIELD_CAST_GEOM, FIELD_CAST_ENUM, FIELD_CAST_SET, FIELD_CAST_BIT, - FIELD_CAST_NEWDECIMAL - }; utype unireg_check; uint32 field_length; // Length of field @@ -119,6 +118,8 @@ public: String *val_int_as_str(String *val_buffer, my_bool unsigned_flag); virtual Item_result result_type () const=0; virtual Item_result cmp_type () const { return result_type(); } + static enum_field_types field_type_merge(enum_field_types, enum_field_types); + static Item_result result_merge_type(enum_field_types); bool eq(Field *field) { return (ptr == field->ptr && null_ptr == field->null_ptr && @@ -296,8 +297,6 @@ public: return (op_result == E_DEC_OVERFLOW); } int warn_if_overflow(int op_result); - virtual field_cast_enum field_cast_type()= 0; - bool field_cast_compatible(field_cast_enum type); /* maximum possible display length */ virtual uint32 max_length()= 0; /* length of field value symbolic representation (in bytes) */ @@ -432,7 +431,6 @@ public: bool zero_pack() const { return 0; } void sql_type(String &str) const; uint32 max_length() { return field_length; } - field_cast_enum field_cast_type() { return FIELD_CAST_DECIMAL; } }; @@ -504,7 +502,6 @@ public: uint32 pack_length() const { return 1; } void sql_type(String &str) const; uint32 max_length() { return 4; } - field_cast_enum field_cast_type() { return FIELD_CAST_TINY; } }; @@ -541,7 +538,6 @@ public: uint32 pack_length() const { return 2; } void sql_type(String &str) const; uint32 max_length() { return 6; } - field_cast_enum field_cast_type() { return FIELD_CAST_SHORT; } }; @@ -573,7 +569,6 @@ public: uint32 pack_length() const { return 3; } void sql_type(String &str) const; uint32 max_length() { return 8; } - field_cast_enum field_cast_type() { return FIELD_CAST_MEDIUM; } }; @@ -610,7 +605,6 @@ public: uint32 pack_length() const { return 4; } void sql_type(String &str) const; uint32 max_length() { return 11; } - field_cast_enum field_cast_type() { return FIELD_CAST_LONG; } }; @@ -650,7 +644,6 @@ public: void sql_type(String &str) const; bool can_be_compared_as_longlong() const { return TRUE; } uint32 max_length() { return 20; } - field_cast_enum field_cast_type() { return FIELD_CAST_LONGLONG; } }; #endif @@ -686,7 +679,6 @@ public: uint32 pack_length() const { return sizeof(float); } void sql_type(String &str) const; uint32 max_length() { return 24; } - field_cast_enum field_cast_type() { return FIELD_CAST_FLOAT; } }; @@ -721,7 +713,6 @@ public: uint32 pack_length() const { return sizeof(double); } void sql_type(String &str) const; uint32 max_length() { return 53; } - field_cast_enum field_cast_type() { return FIELD_CAST_DOUBLE; } }; @@ -754,7 +745,6 @@ public: void sql_type(String &str) const; uint size_of() const { return sizeof(*this); } uint32 max_length() { return 4; } - field_cast_enum field_cast_type() { return FIELD_CAST_NULL; } }; @@ -806,7 +796,6 @@ public: } bool get_date(TIME *ltime,uint fuzzydate); bool get_time(TIME *ltime); - field_cast_enum field_cast_type() { return FIELD_CAST_TIMESTAMP; } timestamp_auto_set_type get_auto_set_type() const; }; @@ -830,7 +819,6 @@ public: bool send_binary(Protocol *protocol); void sql_type(String &str) const; bool can_be_compared_as_longlong() const { return TRUE; } - field_cast_enum field_cast_type() { return FIELD_CAST_YEAR; } }; @@ -863,7 +851,6 @@ public: void sql_type(String &str) const; bool can_be_compared_as_longlong() const { return TRUE; } bool zero_pack() const { return 1; } - field_cast_enum field_cast_type() { return FIELD_CAST_DATE; } }; class Field_newdate :public Field_str { @@ -895,7 +882,6 @@ public: bool zero_pack() const { return 1; } bool get_date(TIME *ltime,uint fuzzydate); bool get_time(TIME *ltime); - field_cast_enum field_cast_type() { return FIELD_CAST_NEWDATE; } }; @@ -931,7 +917,6 @@ public: void sql_type(String &str) const; bool can_be_compared_as_longlong() const { return TRUE; } bool zero_pack() const { return 1; } - field_cast_enum field_cast_type() { return FIELD_CAST_TIME; } }; @@ -969,7 +954,6 @@ public: bool zero_pack() const { return 1; } bool get_date(TIME *ltime,uint fuzzydate); bool get_time(TIME *ltime); - field_cast_enum field_cast_type() { return FIELD_CAST_DATETIME; } }; @@ -1019,7 +1003,6 @@ public: bool has_charset(void) const { return charset() == &my_charset_bin ? FALSE : TRUE; } field_cast_enum field_cast_type() { return FIELD_CAST_STRING; } - Field *new_field(MEM_ROOT *root, struct st_table *new_table); }; @@ -1085,7 +1068,6 @@ public: enum_field_types real_type() const { return MYSQL_TYPE_VARCHAR; } bool has_charset(void) const { return charset() == &my_charset_bin ? FALSE : TRUE; } - field_cast_enum field_cast_type() { return FIELD_CAST_VARSTRING; } Field *new_field(MEM_ROOT *root, struct st_table *new_table); Field *new_key_field(MEM_ROOT *root, struct st_table *new_table, char *new_ptr, uchar *new_null_ptr, @@ -1183,7 +1165,6 @@ public: uint size_of() const { return sizeof(*this); } bool has_charset(void) const { return charset() == &my_charset_bin ? FALSE : TRUE; } - field_cast_enum field_cast_type() { return FIELD_CAST_BLOB; } uint32 max_length(); }; @@ -1213,7 +1194,6 @@ public: int store(longlong nr) { return 1; } int store_decimal(const my_decimal *) { return 1; } void get_key_image(char *buff,uint length,imagetype type); - field_cast_enum field_cast_type() { return FIELD_CAST_GEOM; } }; #endif /*HAVE_SPATIAL*/ @@ -1258,7 +1238,6 @@ public: bool has_charset(void) const { return TRUE; } /* enum and set are sorted as integers */ CHARSET_INFO *sort_charset(void) const { return &my_charset_bin; } - field_cast_enum field_cast_type() { return FIELD_CAST_ENUM; } }; @@ -1284,7 +1263,6 @@ public: void sql_type(String &str) const; enum_field_types real_type() const { return FIELD_TYPE_SET; } bool has_charset(void) const { return TRUE; } - field_cast_enum field_cast_type() { return FIELD_CAST_SET; } }; @@ -1424,7 +1402,6 @@ enum_field_types get_blob_type_from_length(ulong length); uint32 calc_pack_length(enum_field_types type,uint32 length); int set_field_to_null(Field *field); int set_field_to_null_with_conversions(Field *field, bool no_conversions); -bool field_types_to_be_kept(enum_field_types field_type); /* The following are for the interface with the .frm file |