From c5e6941e75454a01953ff542ceda7e4aeb1c22ae Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 10 Nov 2004 14:05:28 +0400 Subject: 1. When mixing NULL to a character string, the result takes its charset/collation attributes from the character string, e.g. SELECT func(NULL, _latin2'string') now returns a latin2 result. This is done by introducing a new derivation (aka coercibility) level DERIVATION_IGNORABLE, which is used with Item_null. 2. 'Pure' NULL is now BINARY(0), not CHAR(0). I.e. NULL is now more typeless. mysql-test/r/metadata.result: Fixing test results: CHAR(0) -> BINARY(0) for NULLs mysql-test/r/null.result: Testing mixing NULL with a character string with a number of functions. mysql-test/r/ps_2myisam.result: Fixing test results: CHAR(0) -> BINARY(0) for NULLs mysql-test/r/ps_3innodb.result: Fixing test results: CHAR(0) -> BINARY(0) for NULLs mysql-test/r/ps_4heap.result: Fixing test results: CHAR(0) -> BINARY(0) for NULLs mysql-test/r/ps_5merge.result: Fixing test results: CHAR(0) -> BINARY(0) for NULLs mysql-test/r/ps_6bdb.result: Fixing test results: CHAR(0) -> BINARY(0) for NULLs mysql-test/r/ps_7ndb.result: Fixing test results: CHAR(0) -> BINARY(0) for NULLs mysql-test/t/null.test: Testing mixing NULL with a character string with a number of functions. sql/item.cc: New derivation level. sql/item.h: New derivation level. --- sql/item.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sql/item.h') diff --git a/sql/item.h b/sql/item.h index fea3aa010a8..547577a7ee0 100644 --- a/sql/item.h +++ b/sql/item.h @@ -31,6 +31,7 @@ void item_init(void); /* Init item functions */ enum Derivation { + DERIVATION_IGNORABLE= 4, DERIVATION_COERCIBLE= 3, DERIVATION_IMPLICIT= 2, DERIVATION_NONE= 1, @@ -98,6 +99,7 @@ public: { switch(derivation) { + case DERIVATION_IGNORABLE: return "IGNORABLE"; case DERIVATION_COERCIBLE: return "COERCIBLE"; case DERIVATION_IMPLICIT: return "IMPLICIT"; case DERIVATION_EXPLICIT: return "EXPLICIT"; @@ -440,6 +442,7 @@ public: max_length= 0; name= name_par ? name_par : (char*) "NULL"; fixed= 1; + collation.set(&my_charset_bin, DERIVATION_IGNORABLE); } enum Type type() const { return NULL_ITEM; } bool eq(const Item *item, bool binary_cmp) const; -- cgit v1.2.1 From 2e6fb936e8ad2ab2dcd26176640a9d43ee7abc26 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 11 Nov 2004 21:39:35 +0300 Subject: Rename: Item::val -> Item::val_real(). sql/filesort.cc: val -> val_real sql/item.cc: val -> val_real sql/item.h: val -> val_real sql/item_buff.cc: val -> val_real sql/item_cmpfunc.cc: val -> val_real sql/item_cmpfunc.h: val -> val_real sql/item_func.cc: val -> val_real sql/item_func.h: val -> val_real sql/item_geofunc.cc: val -> val_real sql/item_geofunc.h: val -> val_real sql/item_row.h: val -> val_real sql/item_strfunc.cc: val -> val_real sql/item_strfunc.h: val -> val_real sql/item_subselect.cc: val -> val_real sql/item_subselect.h: val -> val_real sql/item_sum.cc: val -> val_real sql/item_sum.h: val -> val_real sql/item_timefunc.h: val -> val_real sql/item_uniq.h: val -> val_real sql/procedure.h: val -> val_real sql/sp_head.cc: val -> val_real sql/sql_analyse.cc: val -> val_real sql/sql_class.cc: val -> val_real sql/sql_select.cc: val -> val_real --- sql/item.h | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'sql/item.h') diff --git a/sql/item.h b/sql/item.h index 93c396b95b0..329c25073ee 100644 --- a/sql/item.h +++ b/sql/item.h @@ -186,7 +186,7 @@ public: virtual enum_field_types field_type() const; virtual enum Type type() const =0; /* valXXX methods must return NULL or 0 or 0.0 if null_value is set. */ - virtual double val()=0; + virtual double val_real()=0; virtual longlong val_int()=0; /* Return string representation of this item object. @@ -217,7 +217,7 @@ public: virtual Field *get_tmp_table_field() { return 0; } virtual Field *tmp_table_field(TABLE *t_arg) { return 0; } virtual const char *full_name() const { return name ? name : "???"; } - virtual double val_result() { return val(); } + virtual double val_result() { return val_real(); } virtual longlong val_int_result() { return val_int(); } virtual String *str_result(String* tmp) { return val_str(tmp); } /* bit map of tables used by item */ @@ -362,10 +362,10 @@ public: // the item in the frame enum Type type() const; - inline double val() + inline double val_real() { Item *it= this_item(); - double ret= it->val(); + double ret= it->val_real(); Item::null_value= it->null_value; return ret; } @@ -526,7 +526,7 @@ public: Item_field(Field *field); enum Type type() const { return FIELD_ITEM; } bool eq(const Item *item, bool binary_cmp) const; - double val(); + double val_real(); longlong val_int(); String *val_str(String*); double val_result(); @@ -580,7 +580,7 @@ public: } enum Type type() const { return NULL_ITEM; } bool eq(const Item *item, bool binary_cmp) const; - double val(); + double val_real(); longlong val_int(); String *val_str(String *str); int save_in_field(Field *field, bool no_conversions); @@ -669,7 +669,7 @@ public: enum Type type() const { return item_type; } enum_field_types field_type() const { return param_type; } - double val(); + double val_real(); longlong val_int(); String *val_str(String*); bool get_time(TIME *tm); @@ -726,7 +726,7 @@ public: enum Item_result result_type () const { return INT_RESULT; } enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; } longlong val_int() { DBUG_ASSERT(fixed == 1); return value; } - double val() { DBUG_ASSERT(fixed == 1); return (double) value; } + double val_real() { DBUG_ASSERT(fixed == 1); return (double) value; } String *val_str(String*); int save_in_field(Field *field, bool no_conversions); bool basic_const_item() const { return 1; } @@ -755,7 +755,7 @@ public: Item_uint(const char *str_arg, uint length); Item_uint(uint32 i) :Item_int((longlong) i, 10) { unsigned_flag= 1; } - double val() + double val_real() { DBUG_ASSERT(fixed == 1); return ulonglong2double((ulonglong)value); } String *val_str(String*); Item *new_item() { return new Item_uint(name,max_length); } @@ -784,7 +784,7 @@ public: int save_in_field(Field *field, bool no_conversions); enum Type type() const { return REAL_ITEM; } enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; } - double val() { DBUG_ASSERT(fixed == 1); return value; } + double val_real() { DBUG_ASSERT(fixed == 1); return value; } longlong val_int() { DBUG_ASSERT(fixed == 1); @@ -855,7 +855,7 @@ public: fixed= 1; } enum Type type() const { return STRING_ITEM; } - double val() + double val_real() { DBUG_ASSERT(fixed == 1); int err; @@ -945,7 +945,7 @@ class Item_varbinary :public Item public: Item_varbinary(const char *str,uint str_length); enum Type type() const { return VARBIN_ITEM; } - double val() + double val_real() { DBUG_ASSERT(fixed == 1); return (double) Item_varbinary::val_int(); } longlong val_int(); bool basic_const_item() const { return 1; } @@ -997,7 +997,7 @@ public: enum Type type() const { return REF_ITEM; } bool eq(const Item *item, bool binary_cmp) const { return ref && (*ref)->eq(item, binary_cmp); } - double val() + double val_real() { double tmp=(*ref)->val_result(); null_value=(*ref)->null_value; @@ -1062,7 +1062,7 @@ public: Item_ref_null_helper(Item_in_subselect* master, Item **item, const char *table_name_par, const char *field_name_par): Item_ref(item, table_name_par, field_name_par), owner(master) {} - double val(); + double val_real(); longlong val_int(); String* val_str(String* s); bool get_date(TIME *ltime, uint fuzzydate); @@ -1130,7 +1130,7 @@ public: enum Type type() const { return COPY_STR_ITEM; } enum Item_result result_type () const { return STRING_RESULT; } enum_field_types field_type() const { return cached_field_type; } - double val() + double val_real() { int err; return (null_value ? 0.0 : @@ -1358,7 +1358,7 @@ public: Item_cache_int(): Item_cache() {} void store(Item *item); - double val() { DBUG_ASSERT(fixed == 1); return (double) value; } + double val_real() { DBUG_ASSERT(fixed == 1); return (double) value; } longlong val_int() { DBUG_ASSERT(fixed == 1); return value; } String* val_str(String *str) { @@ -1376,7 +1376,7 @@ public: Item_cache_real(): Item_cache() {} void store(Item *item); - double val() { DBUG_ASSERT(fixed == 1); return value; } + double val_real() { DBUG_ASSERT(fixed == 1); return value; } longlong val_int() { DBUG_ASSERT(fixed == 1); @@ -1398,7 +1398,7 @@ public: Item_cache_str(): Item_cache() { } void store(Item *item); - double val(); + double val_real(); longlong val_int(); String* val_str(String *) { DBUG_ASSERT(fixed == 1); return value; } enum Item_result result_type() const { return STRING_RESULT; } @@ -1430,7 +1430,7 @@ public: { illegal_method_call((const char*)"make_field"); }; - double val() + double val_real() { illegal_method_call((const char*)"val"); return 0; @@ -1481,7 +1481,7 @@ public: Item_result result_type () const { return item_type; } enum Type type() const { return TYPE_HOLDER; } - double val(); + double val_real(); longlong val_int(); String *val_str(String*); bool join_types(THD *thd, Item *); -- cgit v1.2.1