From 9e3562d77326dd81103428a243869c84f84551b3 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 4 Aug 2005 15:25:03 +0500 Subject: [PATCH 1/2] grant.result, grant.test: fixing tests accordingly item.cc: Bug #10892 user variables not auto cast for comparisons When mixing strings with different character sets, and coercibility is the same, we allow conversion if one character set is superset for other character set. sql/item.cc: Bug #10892 user variables not auto cast for comparisons When mixing strings with different character sets, and coercibility is the same, we allow conversion if one character set is superset for other character set. mysql-test/t/grant.test: fixing tests accordingly mysql-test/r/grant.result: fixing tests accordingly --- mysql-test/r/grant.result | 3 +++ mysql-test/t/grant.test | 7 +++++++ sql/item.cc | 10 ++++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index e9e1d4cd620..a50293752ec 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -440,3 +440,6 @@ insert into tables_priv values ('','test_db','mysqltest_1','test_table','test_gr flush privileges; delete from tables_priv where host = '' and user = 'mysqltest_1'; flush privileges; +set @user123="non-existent"; +select * from mysql.db where user=@user123; +Host Db User Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Grant_priv References_priv Index_priv Alter_priv Create_tmp_table_priv Lock_tables_priv diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index 50255d515e0..b0de62e679c 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -402,4 +402,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 84dbc382a52..41cda365750 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -455,14 +455,16 @@ 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) + derivation <= dt.derivation && + collation->state & MY_CS_UNICODE && + !(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.derivation <= derivation && + dt.collation->state & MY_CS_UNICODE && + !(collation->state & MY_CS_UNICODE)) { set(dt); } From b9ffa4dbab1b5fa40a0a6277cf07bdb1665ece63 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 8 Aug 2005 16:20:46 +0500 Subject: [PATCH 2/2] item.cc: After review fix sql/item.cc: After review fix --- sql/item.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sql/item.cc b/sql/item.cc index 41cda365750..b3d2932acf6 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -455,16 +455,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 && - !(dt.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 && - !(collation->state & MY_CS_UNICODE)) + (dt.derivation < derivation || + (dt.derivation == derivation && + !(collation->state & MY_CS_UNICODE)))) { set(dt); }