diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index 05094b295899b639e3288584561127b71bc63d62..635c7a3f4e7d6b427799f05411734f45a9573b14 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -480,4 +480,11 @@ flush privileges; delete from tables_priv where host = '' and user = 'mysqltest_1'; flush privileges; +# +# Bug #10892 user variables not auto cast for comparisons +# Check that we don't get illegal mix of collations +# +set @user123="non-existent"; +select * from mysql.db where user=@user123; + # End of 4.1 tests diff --git a/sql/item.cc b/sql/item.cc index 25a12bc2d67b3c44573bd750e9bec24fa043b583..ae4cbadc01e444e092d6a474a2285c692b84a3e0 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1016,14 +1016,18 @@ bool DTCollation::aggregate(DTCollation &dt, uint flags) ; // Do nothing } else if ((flags & MY_COLL_ALLOW_SUPERSET_CONV) && - derivation < dt.derivation && - collation->state & MY_CS_UNICODE) + collation->state & MY_CS_UNICODE && + (derivation < dt.derivation || + (derivation == dt.derivation && + !(dt.collation->state & MY_CS_UNICODE)))) { // Do nothing } else if ((flags & MY_COLL_ALLOW_SUPERSET_CONV) && - dt.derivation < derivation && - dt.collation->state & MY_CS_UNICODE) + dt.collation->state & MY_CS_UNICODE && + (dt.derivation < derivation || + (dt.derivation == derivation && + !(collation->state & MY_CS_UNICODE)))) { set(dt); }