diff options
author | mkindahl@dl145h.mysql.com <> | 2007-08-03 18:59:16 +0200 |
---|---|---|
committer | mkindahl@dl145h.mysql.com <> | 2007-08-03 18:59:16 +0200 |
commit | ea9848094a77f233f13f8f815b1f348ffc73b30d (patch) | |
tree | 2634f506d2b962f13e24f0f80211983257503072 /sql/item.cc | |
parent | 0d9301585bb076ef85c0cb91c7999148a41d0804 (diff) | |
parent | 7754da28f980b1da80e3db8abc7ff8b0e3c70008 (diff) | |
download | mariadb-git-ea9848094a77f233f13f8f815b1f348ffc73b30d.tar.gz |
Merge mkindahl@bk-internal.mysql.com:/home/bk/mysql-5.0-rpl
into dl145h.mysql.com:/data0/mkindahl/mysql-5.0-2team
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/sql/item.cc b/sql/item.cc index 9612fbc5243..c99946ac9d2 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1327,6 +1327,25 @@ void Item::split_sum_func2(THD *thd, Item **ref_pointer_array, } +static bool +left_is_superset(DTCollation *left, DTCollation *right) +{ + /* Allow convert to Unicode */ + if (left->collation->state & MY_CS_UNICODE && + (left->derivation < right->derivation || + (left->derivation == right->derivation && + !(right->collation->state & MY_CS_UNICODE)))) + return TRUE; + /* Allow convert from ASCII */ + if (right->repertoire == MY_REPERTOIRE_ASCII && + (left->derivation < right->derivation || + (left->derivation == right->derivation && + !(left->repertoire == MY_REPERTOIRE_ASCII)))) + return TRUE; + /* Disallow conversion otherwise */ + return FALSE; +} + /* Aggregate two collations together taking into account their coercibility (aka derivation): @@ -1391,18 +1410,12 @@ bool DTCollation::aggregate(DTCollation &dt, uint flags) ; // Do nothing } else if ((flags & MY_COLL_ALLOW_SUPERSET_CONV) && - collation->state & MY_CS_UNICODE && - (derivation < dt.derivation || - (derivation == dt.derivation && - !(dt.collation->state & MY_CS_UNICODE)))) + left_is_superset(this, &dt)) { // Do nothing } else if ((flags & MY_COLL_ALLOW_SUPERSET_CONV) && - dt.collation->state & MY_CS_UNICODE && - (dt.derivation < derivation || - (dt.derivation == derivation && - !(collation->state & MY_CS_UNICODE)))) + left_is_superset(&dt, this)) { set(dt); } @@ -1421,7 +1434,7 @@ bool DTCollation::aggregate(DTCollation &dt, uint flags) else { // Cannot apply conversion - set(0, DERIVATION_NONE); + set(0, DERIVATION_NONE, 0); return 1; } } @@ -1443,8 +1456,8 @@ bool DTCollation::aggregate(DTCollation &dt, uint flags) { if (derivation == DERIVATION_EXPLICIT) { - set(0, DERIVATION_NONE); - return 1; + set(0, DERIVATION_NONE, 0); + return 1; } if (collation->state & MY_CS_BINSORT) return 0; @@ -1458,6 +1471,7 @@ bool DTCollation::aggregate(DTCollation &dt, uint flags) set(bin, DERIVATION_NONE); } } + repertoire|= dt.repertoire; return 0; } @@ -1597,12 +1611,16 @@ bool agg_item_charsets(DTCollation &coll, const char *fname, { Item* conv; uint32 dummy_offset; - if (!String::needs_conversion(0, coll.collation, - (*arg)->collation.collation, + if (!String::needs_conversion(0, (*arg)->collation.collation, + coll.collation, &dummy_offset)) continue; - if (!(conv= (*arg)->safe_charset_converter(coll.collation))) + if (!(conv= (*arg)->safe_charset_converter(coll.collation)) && + ((*arg)->collation.repertoire == MY_REPERTOIRE_ASCII)) + conv= new Item_func_conv_charset(*arg, coll.collation, 1); + + if (!conv) { if (nargs >=2 && nargs <= 3) { |