diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-11-13 23:03:48 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-11-13 23:03:48 +0100 |
commit | 4157185f241f1583729020ba67064db0391aaa3d (patch) | |
tree | f0662e17995b49d92ed706a33c894485a67678fe /sql/opt_sum.cc | |
parent | c155890af90ec75555fa485387a0cf11120175a6 (diff) | |
parent | bdd883ed9a68ff1e82528cc6b33316d98894cfd2 (diff) | |
download | mariadb-git-4157185f241f1583729020ba67064db0391aaa3d.tar.gz |
10.0-base merge
Diffstat (limited to 'sql/opt_sum.cc')
-rw-r--r-- | sql/opt_sum.cc | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index b8d39057ba8..d4fc458c948 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -479,6 +479,24 @@ int opt_sum_query(THD *thd, } +/* + Check if both item1 and item2 are strings, and item1 has fewer characters + than item2. +*/ + +static bool check_item1_shorter_item2(Item *item1, Item *item2) +{ + if (item1->cmp_type() == STRING_RESULT && + item2->cmp_type() == STRING_RESULT) + { + int len1= item1->max_length / item1->collation.collation->mbmaxlen; + int len2= item2->max_length / item2->collation.collation->mbmaxlen; + return len1 < len2; + } + return false; /* When the check is not applicable, it means "not bigger" */ +} + + /** Test if the predicate compares a field with constants. @@ -509,7 +527,7 @@ bool simple_pred(Item_func *func_item, Item **args, bool *inv_order) if (!(item= it++)) return 0; args[0]= item->real_item(); - if (args[0]->max_length < args[1]->max_length) + if (check_item1_shorter_item2(args[0], args[1])) return 0; if (it++) return 0; @@ -544,7 +562,7 @@ bool simple_pred(Item_func *func_item, Item **args, bool *inv_order) } else return 0; - if (args[0]->max_length < args[1]->max_length) + if (check_item1_shorter_item2(args[0], args[1])) return 0; break; case 3: @@ -559,7 +577,7 @@ bool simple_pred(Item_func *func_item, Item **args, bool *inv_order) if (!item->const_item()) return 0; args[i]= item; - if (args[0]->max_length < args[i]->max_length) + if (check_item1_shorter_item2(args[0], args[1])) return 0; } } |