#At file:///home/gluh/MySQL/mysql-5.0-bug-41627/ based on revid:zhenxing.he@stripped
2767 Sergey Glukhov 2009-03-06
Bug#41627 Illegal mix of collations in LEAST / GREATEST / CASE
Don't throw an error after checking the first and the second arguments.
Continue with checking the third and higher arguments and if some of
them is stronger according to coercibility rules,
then this argument's collation is set as result collation.
@ mysql-test/r/ctype_collate.result
test result
@ mysql-test/t/ctype_collate.test
test case
@ sql/item.cc
Don't throw an error after checking the first and the second arguments.
Continue with checking the third and higher arguments and if some of
them is stronger according to coercibility rules,
then this argument's collation is set as result collation.
modified:
mysql-test/r/ctype_collate.result
mysql-test/t/ctype_collate.test
sql/item.cc
=== modified file 'mysql-test/r/ctype_collate.result'
--- a/mysql-test/r/ctype_collate.result 2007-09-20 08:54:46 +0000
+++ b/mysql-test/r/ctype_collate.result 2009-03-06 11:45:35 +0000
@@ -611,3 +611,22 @@ check table t1 extended;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
+select least(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci);
+least(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci)
+a
+create table t1
+select least(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci) as f1;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` varchar(1) character set latin5 NOT NULL default ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select case _latin1'a' when _latin2'b' then 1 when _latin5'c' collate
+latin5_turkish_ci then 2 else 3 end;
+case _latin1'a' when _latin2'b' then 1 when _latin5'c' collate
+latin5_turkish_ci then 2 else 3 end
+3
+select concat(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci);
+concat(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci)
+abc
=== modified file 'mysql-test/t/ctype_collate.test'
--- a/mysql-test/t/ctype_collate.test 2007-07-08 21:23:33 +0000
+++ b/mysql-test/t/ctype_collate.test 2009-03-06 11:45:35 +0000
@@ -229,3 +229,17 @@ insert into t1 set a=0x6c;
insert into t1 set a=0x4c98;
check table t1 extended;
drop table t1;
+
+#
+# Bug#41627 Illegal mix of collations in LEAST / GREATEST / CASE
+#
+select least(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci);
+create table t1
+select least(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci) as f1;
+show create table t1;
+drop table t1;
+
+select case _latin1'a' when _latin2'b' then 1 when _latin5'c' collate
+latin5_turkish_ci then 2 else 3 end;
+
+select concat(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci);
=== modified file 'sql/item.cc'
--- a/sql/item.cc 2009-02-20 09:42:35 +0000
+++ b/sql/item.cc 2009-03-06 11:45:35 +0000
@@ -1498,7 +1498,8 @@ bool DTCollation::aggregate(DTCollation
else
{
// Cannot apply conversion
- set(0, DERIVATION_NONE, 0);
+ set(&my_charset_bin, DERIVATION_NONE,
+ (dt.repertoire|repertoire));
return 1;
}
}
@@ -1581,15 +1582,31 @@ bool agg_item_collations(DTCollation &c,
{
uint i;
Item **arg;
+ bool unknown_cs= 0;
+
c.set(av[0]->collation);
for (i= 1, arg= &av[item_sep]; i < count; i++, arg++)
{
if (c.aggregate((*arg)->collation, flags))
{
+ if (c.derivation == DERIVATION_NONE &&
+ c.collation == &my_charset_bin)
+ {
+ unknown_cs= 1;
+ continue;
+ }
my_coll_agg_error(av, count, fname, item_sep);
return TRUE;
}
}
+
+ if (unknown_cs &&
+ c.derivation != DERIVATION_EXPLICIT)
+ {
+ my_coll_agg_error(av, count, fname, item_sep);
+ return TRUE;
+ }
+
if ((flags & MY_COLL_DISALLOW_NONE) &&
c.derivation == DERIVATION_NONE)
{
Attachment: [text/bzr-bundle] bzr/sergey.glukhov@sun.com-20090306114535-obha5vzo8dm7d1dl.bundle
| Thread |
|---|
| • bzr commit into mysql-5.0-bugteam branch (Sergey.Glukhov:2767)Bug#41627 | Sergey Glukhov | 6 Mar |