diff options
author | unknown <bell@sanja.is.com.ua> | 2005-03-23 08:36:48 +0200 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2005-03-23 08:36:48 +0200 |
commit | 5a425250271f796e68514f9484a67df218ddb9d2 (patch) | |
tree | 1a44d0ad7fd7c6b39daf960d107346319e9f5e74 /sql/field.h | |
parent | 98eecc7b35f4da432b1388bbfd3e3f0cd63b49f5 (diff) | |
download | mariadb-git-5a425250271f796e68514f9484a67df218ddb9d2.tar.gz |
fixed union types merging and table related metadata (BUG#8824)
mysql-test/r/func_group.result:
new result
mysql-test/r/metadata.result:
new result
test of metadata of variables, unions and derived tables
mysql-test/r/union.result:
new results
test of union of enum
mysql-test/t/metadata.test:
test of metadata of variables, unions and derived tables
mysql-test/t/union.test:
test of union of enum
sql/field.cc:
Field type merging rules added
Fixed table name/alias returting for field made from temporary tables
sql/field.h:
removed unned field type reporting
sql/item.cc:
fixed bug in NEW_DATE type field creartion
replaced mechanism of merging types of UNION
sql/item.h:
replaced mechanism of merging types of UNION
sql/item_func.h:
new item type to make correct field type detection possible
sql/item_subselect.cc:
added table name parameter to prepare() to show right table alias for derived tables
sql/sql_derived.cc:
added table name parameter to prepare() to show right table alias for derived tables
sql/sql_lex.h:
added table name parameter to prepare() to show right table alias for derived tables
sql/sql_parse.cc:
made function for enum/set pack length calculation
sql/sql_prepare.cc:
added table name parameter to prepare() to show right table alias for derived tables
sql/sql_select.cc:
new temporary table field creation by Item_type_holder
fixed table alias for temporary table
sql/sql_union.cc:
added table name parameter to prepare() to show right table alias for derived tables
Diffstat (limited to 'sql/field.h')
-rw-r--r-- | sql/field.h | 48 |
1 files changed, 13 insertions, 35 deletions
diff --git a/sql/field.h b/sql/field.h index b5d88504939..5dc124aba35 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 */ @@ -75,17 +86,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 - }; utype unireg_check; uint32 field_length; // Length of field @@ -119,6 +119,8 @@ public: virtual String *val_str(String*,String *)=0; 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; } virtual bool eq_def(Field *field); virtual uint32 pack_length() const { return (uint32) field_length; } @@ -290,8 +292,6 @@ public: int cuted_increment); void set_datetime_warning(const uint level, const uint code, double nr, timestamp_type ts_type); - 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; friend bool reopen_table(THD *,struct st_table *,bool); @@ -398,7 +398,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; } }; @@ -430,7 +429,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; } }; @@ -467,7 +465,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; } }; @@ -499,7 +496,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; } }; @@ -536,7 +532,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; } }; @@ -576,7 +571,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 @@ -611,7 +605,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; } }; @@ -646,7 +639,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; } }; @@ -677,7 +669,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; } }; @@ -729,7 +720,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; }; @@ -753,7 +743,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; } }; @@ -786,7 +775,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 { @@ -818,7 +806,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; } }; @@ -853,7 +840,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; } }; @@ -891,7 +877,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; } }; @@ -937,7 +922,6 @@ public: enum_field_types real_type() const { return FIELD_TYPE_STRING; } bool has_charset(void) const { return charset() == &my_charset_bin ? FALSE : TRUE; } - field_cast_enum field_cast_type() { return FIELD_CAST_STRING; } }; @@ -986,7 +970,6 @@ public: enum_field_types real_type() const { return FIELD_TYPE_VAR_STRING; } bool has_charset(void) const { return charset() == &my_charset_bin ? FALSE : TRUE; } - field_cast_enum field_cast_type() { return FIELD_CAST_VARSTRING; } }; @@ -1081,7 +1064,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(); }; @@ -1111,7 +1093,6 @@ public: void get_key_image(char *buff,uint length, CHARSET_INFO *cs,imagetype type); void set_key_image(char *buff,uint length, CHARSET_INFO *cs); - field_cast_enum field_cast_type() { return FIELD_CAST_GEOM; } }; #endif /*HAVE_SPATIAL*/ @@ -1155,7 +1136,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; } }; @@ -1181,7 +1161,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; } }; @@ -1268,7 +1247,6 @@ int set_field_to_null(Field *field); int set_field_to_null_with_conversions(Field *field, bool no_conversions); bool test_if_int(const char *str, int length, const char *int_end, CHARSET_INFO *cs); -bool field_types_to_be_kept(enum_field_types field_type); /* The following are for the interface with the .frm file |