diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item.cc | 10 | ||||
-rw-r--r-- | sql/item.h | 12 | ||||
-rw-r--r-- | sql/item_create.cc | 2 | ||||
-rw-r--r-- | sql/item_func.cc | 2 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 17 | ||||
-rw-r--r-- | sql/item_strfunc.h | 16 |
6 files changed, 36 insertions, 23 deletions
diff --git a/sql/item.cc b/sql/item.cc index 76cbaa99029..1293d2c94fe 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -384,7 +384,6 @@ void Item::split_sum_func2(THD *thd, Item **ref_pointer_array, */ bool DTCollation::aggregate(DTCollation &dt, uint flags) { - nagg++; if (!my_charset_same(collation, dt.collation)) { /* @@ -400,7 +399,6 @@ bool DTCollation::aggregate(DTCollation &dt, uint flags) else { set(dt); - strong= nagg; } } else if (dt.collation == &my_charset_bin) @@ -408,7 +406,6 @@ bool DTCollation::aggregate(DTCollation &dt, uint flags) if (dt.derivation <= derivation) { set(dt); - strong= nagg; } else ; // Do nothing @@ -424,20 +421,18 @@ bool DTCollation::aggregate(DTCollation &dt, uint flags) dt.collation->state & MY_CS_UNICODE) { set(dt); - strong= nagg; } else if ((flags & MY_COLL_ALLOW_COERCIBLE_CONV) && derivation < dt.derivation && - dt.derivation >= DERIVATION_COERCIBLE) + dt.derivation >= DERIVATION_SYSCONST) { // Do nothing; } else if ((flags & MY_COLL_ALLOW_COERCIBLE_CONV) && dt.derivation < derivation && - derivation >= DERIVATION_COERCIBLE) + derivation >= DERIVATION_SYSCONST) { set(dt); - strong= nagg; } else { @@ -453,7 +448,6 @@ bool DTCollation::aggregate(DTCollation &dt, uint flags) else if (dt.derivation < derivation) { set(dt); - strong= nagg; } else { diff --git a/sql/item.h b/sql/item.h index 2827be2d237..adc780677e1 100644 --- a/sql/item.h +++ b/sql/item.h @@ -31,8 +31,9 @@ void item_init(void); /* Init item functions */ enum Derivation { - DERIVATION_IGNORABLE= 4, - DERIVATION_COERCIBLE= 3, + DERIVATION_IGNORABLE= 5, + DERIVATION_COERCIBLE= 4, + DERIVATION_SYSCONST= 3, DERIVATION_IMPLICIT= 2, DERIVATION_NONE= 1, DERIVATION_EXPLICIT= 0 @@ -61,22 +62,16 @@ class DTCollation { public: CHARSET_INFO *collation; enum Derivation derivation; - uint nagg; // Total number of aggregated collations. - uint strong; // Number of the strongest collation. DTCollation() { collation= &my_charset_bin; derivation= DERIVATION_NONE; - nagg= 0; - strong= 0; } DTCollation(CHARSET_INFO *collation_arg, Derivation derivation_arg) { collation= collation_arg; derivation= derivation_arg; - nagg= 0; - strong= 0; } void set(DTCollation &dt) { @@ -102,6 +97,7 @@ public: case DERIVATION_IGNORABLE: return "IGNORABLE"; case DERIVATION_COERCIBLE: return "COERCIBLE"; case DERIVATION_IMPLICIT: return "IMPLICIT"; + case DERIVATION_SYSCONST: return "SYSCONST"; case DERIVATION_EXPLICIT: return "EXPLICIT"; case DERIVATION_NONE: return "NONE"; default: return "UNKNOWN"; diff --git a/sql/item_create.cc b/sql/item_create.cc index d959a6f393a..c0361c928be 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -441,7 +441,7 @@ Item *create_func_version(void) { return new Item_string(NullS,server_version, (uint) strlen(server_version), - system_charset_info, DERIVATION_IMPLICIT); + system_charset_info, DERIVATION_SYSCONST); } Item *create_func_weekday(Item* a) diff --git a/sql/item_func.cc b/sql/item_func.cc index 895740d2e5e..96250522c4a 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -79,8 +79,6 @@ bool Item_func::agg_arg_collations(DTCollation &c, Item **av, uint count, uint flags) { uint i; - c.nagg= 0; - c.strong= 0; c.set(av[0]->collation); for (i= 1; i < count; i++) { diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 0023d7b1f20..2f8d6dd822d 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1509,6 +1509,23 @@ String *Item_func_decode::val_str(String *str) } +Item *Item_func_sysconst::safe_charset_converter(CHARSET_INFO *tocs) +{ + Item_string *conv; + uint conv_errors; + String tmp, cstr, *ostr= val_str(&tmp); + cstr.copy(ostr->ptr(), ostr->length(), ostr->charset(), tocs, &conv_errors); + if (conv_errors || !(conv= new Item_string(cstr.ptr(), cstr.length(), + cstr.charset(), + collation.derivation))) + { + return NULL; + } + conv->str_value.copy(); + return conv; +} + + String *Item_func_database::val_str(String *str) { DBUG_ASSERT(fixed == 1); diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index c1c0969672c..0c3ed32fb68 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -337,10 +337,18 @@ public: }; -class Item_func_database :public Item_str_func +class Item_func_sysconst :public Item_str_func { public: - Item_func_database() { collation.set(system_charset_info,DERIVATION_IMPLICIT); } + Item_func_sysconst() + { collation.set(system_charset_info,DERIVATION_SYSCONST); } + Item *safe_charset_converter(CHARSET_INFO *tocs); +}; + +class Item_func_database :public Item_func_sysconst +{ +public: + Item_func_database() :Item_func_sysconst() {} String *val_str(String *); void fix_length_and_dec() { @@ -350,10 +358,10 @@ public: const char *func_name() const { return "database"; } }; -class Item_func_user :public Item_str_func +class Item_func_user :public Item_func_sysconst { public: - Item_func_user() { collation.set(system_charset_info, DERIVATION_IMPLICIT); } + Item_func_user() :Item_func_sysconst() {} String *val_str(String *); void fix_length_and_dec() { |