diff options
author | Alexander Barkov <alexander.barkov@oracle.com> | 2011-04-08 17:15:23 +0400 |
---|---|---|
committer | Alexander Barkov <alexander.barkov@oracle.com> | 2011-04-08 17:15:23 +0400 |
commit | a1c762b9dfbf6bb85f1f06d1e7d07b3b38e5920a (patch) | |
tree | 2709dddaf34dda1e528467d7759bf2355f9f0503 /sql/item.cc | |
parent | 31e7450c608e38479b41da8e4e0fc7dad5d4246f (diff) | |
download | mariadb-git-a1c762b9dfbf6bb85f1f06d1e7d07b3b38e5920a.tar.gz |
Bug#11926811 / Bug#60625 Illegal mix of collations
Problem: comparison of a DATETIME sp variable and NOW()
led to Illegal mix of collations error when
character_set_connection=utf8.
Introduced by "WL#2649 Number-to-string conversions".
Error happened in Arg_comparator::set_compare_func(),
because the first argument was errouneously converted to utf8,
while the second argument was not.
Fix: separate agg_arg_charsets_for_comparison() into two functions:
- agg_arg_charsets_for_comparison() - for pure comparison,
when we don't need to return any string result and therefore
don't need to convert arguments to @@character_set_connection:
SELECT a = b;
- agg_arg_charsets_for_string_results_with_comparison() - when
we need to return a string result, but we also need to do
comparison internally: SELECT REPLACE(a,b,c)
If all arguments are numbers:
SELECT REPLACE(123,2,3) -> 133
we convert arguments to @@character_set_connection.
@ mysql-test/include/ctype_numconv.inc
@ mysql-test/r/ctype_binary.result
@ mysql-test/r/ctype_cp1251.result
@ mysql-test/r/ctype_latin1.result
@ mysql-test/r/ctype_ucs.result
@ mysql-test/r/ctype_utf8.result
Adding tests
@ sql/item.cc
@ sql/item.h
@ sql/item_func.cc
@ sql/item_func.h
@ sql/item_strfunc.cc
Introducing and using new function
agg_item_charsets_for_string_result_with_comparison() and
its Item_func wrapper agg_arg_charsets_for_string_result_with_comparison().
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/item.cc b/sql/item.cc index a1482a6d634..af3917c09c1 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1746,7 +1746,8 @@ bool agg_item_collations(DTCollation &c, const char *fname, } /* If all arguments where numbers, reset to @@collation_connection */ - if (c.derivation == DERIVATION_NUMERIC) + if (flags & MY_COLL_ALLOW_NUMERIC_CONV && + c.derivation == DERIVATION_NUMERIC) c.set(Item::default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_NUMERIC); return FALSE; |