diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 1db31881607..94d3258aef2 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -1251,3 +1251,10 @@ a 2 10 drop table t1,t2; +CREATE TABLE t1 (s1 CHAR(5) COLLATE latin1_german1_ci, +s2 CHAR(5) COLLATE latin1_swedish_ci); +INSERT INTO t1 VALUES ('z','?'); +select * from t1 where s1 > (select max(s2) from t1); +ERROR HY000: Illegal mix of collations (latin1_german1_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '>' +select * from t1 where s1 > any (select max(s2) from t1); +drop table t1; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 28408bbf365..1359e1b5dda 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -853,3 +853,14 @@ insert into t3 values (1),(2),(10),(50); select a from t3 where t3.a in (select a from t1 where a <= 3 union select * from t2 where a <= 30); drop table t1,t2; +# +# collation test +# +CREATE TABLE t1 (s1 CHAR(5) COLLATE latin1_german1_ci, + s2 CHAR(5) COLLATE latin1_swedish_ci); +INSERT INTO t1 VALUES ('z','?'); +-- error 1265 +select * from t1 where s1 > (select max(s2) from t1); +-- error 1265 +select * from t1 where s1 > any (select max(s2) from t1); +drop table t1; diff --git a/sql/item.cc b/sql/item.cc index 17b0519b61c..7c9579416db 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1704,7 +1704,7 @@ void Item_cache_str::store(Item *item) str_value.copy(*value); value= &str_value; } - + collation.set(item->collation); } double Item_cache_str::val() { diff --git a/sql/item.h b/sql/item.h index 3412b43da44..9355b43f538 100644 --- a/sql/item.h +++ b/sql/item.h @@ -852,6 +852,7 @@ public: { value= item->val_int_result(); null_value= item->null_value; + collation.set(item->collation); } double val() { return (double) value; } longlong val_int() { return value; } @@ -869,6 +870,7 @@ public: { value= item->val_result(); null_value= item->null_value; + collation.set(item->collation); } double val() { return value; } longlong val_int() { return (longlong) (value+(value > 0 ? 0.5 : -0.5)); }