From 5eb393973f59364915a4cc9a7387f560d7453c5b Mon Sep 17 00:00:00 2001 From: "acurtis@pcgem.rdg.cyberkinetica.com" <> Date: Mon, 7 Mar 2005 13:37:10 +0000 Subject: [PATCH 1/5] Bug#6776 Failure to delete rows from mysql.func table caused by missing charset conversion for index read by pk. --- sql/sql_udf.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 0bb8ac8a28b..6566e327a9e 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -493,8 +493,11 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name) tables.real_name= tables.alias= (char*) "func"; if (!(table = open_ltable(thd,&tables,TL_WRITE))) goto err; - if (!table->file->index_read_idx(table->record[0],0,(byte*) udf_name->str, - (uint) udf_name->length, + table->field[0]->store(udf_name.str, udf_name.length, system_charset_info); + table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS); + if (!table->file->index_read_idx(table->record[0], 0, + (byte*) table->field[0]->ptr, + table->key_info[0].key_length HA_READ_KEY_EXACT)) { int error; From 0998ec4264c802b9ff8b0237bb7790923523e5d6 Mon Sep 17 00:00:00 2001 From: "acurtis@xiphis.org" <> Date: Sat, 9 Apr 2005 00:21:51 +0100 Subject: [PATCH 2/5] Fix typos in Bug#6776 --- sql/sql_udf.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 19df1a85565..661bf6e8197 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -526,11 +526,11 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name) tables.real_name= tables.alias= (char*) "func"; if (!(table = open_ltable(thd,&tables,TL_WRITE))) goto err; - table->field[0]->store(udf_name.str, udf_name.length, system_charset_info); + table->field[0]->store(udf_name->str, udf_name->length, system_charset_info); table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS); if (!table->file->index_read_idx(table->record[0], 0, (byte*) table->field[0]->ptr, - table->key_info[0].key_length + table->key_info[0].key_length, HA_READ_KEY_EXACT)) { int error; From 16e186779f270bf9877938d20acdcebbee0d2e38 Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Sun, 10 Apr 2005 12:40:33 +0500 Subject: [PATCH 3/5] ctype_collate.result, ctype_collate.test, union.result, union.test: fixing tests accordingly item.cc: Allow mixing non-binary collation and binary collation even if coercibility is the same. For easier 4.0 -> 4.1 migrating. --- mysql-test/r/ctype_collate.result | 13 +++++++++++++ mysql-test/r/union.result | 2 +- mysql-test/t/ctype_collate.test | 12 ++++++++++++ mysql-test/t/union.test | 2 +- sql/item.cc | 11 ++++++++++- 5 files changed, 37 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/ctype_collate.result b/mysql-test/r/ctype_collate.result index bc77e9c2362..cdf890f2c6c 100644 --- a/mysql-test/r/ctype_collate.result +++ b/mysql-test/r/ctype_collate.result @@ -535,6 +535,19 @@ s2 CHAR(5) COLLATE latin1_swedish_ci); SELECT * FROM t1 WHERE s1 = s2; ERROR HY000: Illegal mix of collations (latin1_german1_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '=' DROP TABLE t1; +CREATE TABLE t1 +(s1 CHAR(5) COLLATE latin1_german1_ci, +s2 CHAR(5) COLLATE latin1_swedish_ci, +s3 CHAR(5) COLLATE latin1_bin); +INSERT INTO t1 VALUES ('a','A','A'); +SELECT * FROM t1 WHERE s1 = s2; +ERROR HY000: Illegal mix of collations (latin1_german1_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '=' +SELECT * FROM t1 WHERE s1 = s3; +s1 s2 s3 +SELECT * FROM t1 WHERE s2 = s3; +s1 s2 s3 +a A A +DROP TABLE t1; SET NAMES latin1; CREATE TABLE t1 (s1 char(10) COLLATE latin1_german1_ci, diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 96baf36d151..c140ecd26e1 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -1103,7 +1103,7 @@ count(*) drop table t1; create table t2 ( a char character set latin1 collate latin1_swedish_ci, -b char character set latin1 collate latin1_bin); +b char character set latin1 collate latin1_german1_ci); create table t1 as (select a from t2) union (select b from t2); diff --git a/mysql-test/t/ctype_collate.test b/mysql-test/t/ctype_collate.test index 3599beeacc4..b65067a36cf 100644 --- a/mysql-test/t/ctype_collate.test +++ b/mysql-test/t/ctype_collate.test @@ -158,6 +158,18 @@ SELECT * FROM t1 WHERE s1 = s2; DROP TABLE t1; +CREATE TABLE t1 +(s1 CHAR(5) COLLATE latin1_german1_ci, + s2 CHAR(5) COLLATE latin1_swedish_ci, + s3 CHAR(5) COLLATE latin1_bin); +INSERT INTO t1 VALUES ('a','A','A'); +--error 1267 +SELECT * FROM t1 WHERE s1 = s2; +SELECT * FROM t1 WHERE s1 = s3; +SELECT * FROM t1 WHERE s2 = s3; +DROP TABLE t1; + + # # Test that optimizer doesn't use indexes with wrong collation # diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 94cbd71c00c..b0446e1ea4a 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -641,7 +641,7 @@ drop table t1; create table t2 ( a char character set latin1 collate latin1_swedish_ci, -b char character set latin1 collate latin1_bin); +b char character set latin1 collate latin1_german1_ci); --error 1271 create table t1 as (select a from t2) union diff --git a/sql/item.cc b/sql/item.cc index 3b87e5ee2cf..ffde92c4214 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -474,8 +474,17 @@ bool DTCollation::aggregate(DTCollation &dt, uint flags) set(0, DERIVATION_NONE); return 1; } + if (collation->state & MY_CS_BINSORT) + { + return 0; + } + else if (dt.collation->state & MY_CS_BINSORT) + { + set(dt); + return 0; + } CHARSET_INFO *bin= get_charset_by_csname(collation->csname, - MY_CS_BINSORT,MYF(0)); + MY_CS_BINSORT,MYF(0)); set(bin, DERIVATION_NONE); } } From 06e36472741258f89f58be90a94bf66ad45bb32c Mon Sep 17 00:00:00 2001 From: "dlenev@mysql.com" <> Date: Mon, 11 Apr 2005 00:30:23 +0400 Subject: [PATCH 4/5] Fix for bug #9796 "Query Cache caches queries with CURRENT_USER() function". We should not cache queries using CURRENT_USER() function as we do it for some other functions, e.g. USER() function. --- mysql-test/r/query_cache.result | 2 ++ mysql-test/t/query_cache.test | 1 + sql/item_create.cc | 1 + 3 files changed, 4 insertions(+) diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result index 85fe77b1f10..a472a1b75c0 100644 --- a/mysql-test/r/query_cache.result +++ b/mysql-test/r/query_cache.result @@ -299,6 +299,8 @@ select UNIX_TIMESTAMP() from t1; UNIX_TIMESTAMP() select USER() from t1; USER() +select CURRENT_USER() from t1; +CURRENT_USER() select benchmark(1,1) from t1; benchmark(1,1) show status like "Qcache_queries_in_cache"; diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test index 61fbadde1e1..89a9707a237 100644 --- a/mysql-test/t/query_cache.test +++ b/mysql-test/t/query_cache.test @@ -182,6 +182,7 @@ select LAST_INSERT_ID() from t1; select RAND() from t1; select UNIX_TIMESTAMP() from t1; select USER() from t1; +select CURRENT_USER() from t1; select benchmark(1,1) from t1; show status like "Qcache_queries_in_cache"; # diff --git a/sql/item_create.cc b/sql/item_create.cc index 6809d6892b0..877e63047d6 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -297,6 +297,7 @@ Item *create_func_current_user() char buff[HOSTNAME_LENGTH+USERNAME_LENGTH+2]; uint length; + thd->safe_to_cache_query= 0; length= (uint) (strxmov(buff, thd->priv_user, "@", thd->priv_host, NullS) - buff); return new Item_string(NullS, thd->memdup(buff, length), length); From 831a6124833e4c2e5f52f166ce82ab43bd56624d Mon Sep 17 00:00:00 2001 From: "dlenev@brandersnatch.localdomain" <> Date: Mon, 11 Apr 2005 10:44:48 +0400 Subject: [PATCH 5/5] Merging fix for bug #9796 "Query Cache caches queries with CURRENT_USER() function" into 4.1 tree. --- sql/item_create.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/item_create.cc b/sql/item_create.cc index 4b313d49466..2b12a1310b9 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -306,7 +306,7 @@ Item *create_func_current_user() char buff[HOSTNAME_LENGTH+USERNAME_LENGTH+2]; uint length; - thd->safe_to_cache_query= 0; + thd->lex->safe_to_cache_query= 0; length= (uint) (strxmov(buff, thd->priv_user, "@", thd->priv_host, NullS) - buff); return new Item_string(NullS, thd->memdup(buff, length), length,