From cfa78c2645d3a0c3eaf02a256f63d2d284ed2b3b Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 18 Feb 2005 16:10:12 +0400 Subject: [PATCH] Bug #7878 with utf_general_ci, equals (=) has problem with accent insensitivity Backporting Monty's fix for 5.0 into 4.1. --- include/my_base.h | 1 + myisam/mi_rnext_same.c | 8 ++++++-- mysql-test/r/ctype_latin1_de.result | 12 ++++++++++++ mysql-test/t/ctype_latin1_de.test | 16 ++++++++++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/include/my_base.h b/include/my_base.h index 7290d0da09b..d702ec45140 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -340,6 +340,7 @@ enum ha_base_keytype { #define HA_STATE_BUFF_SAVED 512 /* If current keybuff is info->buff */ #define HA_STATE_ROW_CHANGED 1024 /* To invalide ROW cache */ #define HA_STATE_EXTEND_BLOCK 2048 +#define HA_STATE_RNEXT_SAME 4096 /* rnext_same was called */ enum en_fieldtype { FIELD_LAST=-1,FIELD_NORMAL,FIELD_SKIP_ENDSPACE,FIELD_SKIP_PRESPACE, diff --git a/myisam/mi_rnext_same.c b/myisam/mi_rnext_same.c index a50c578e081..06408f57a3f 100644 --- a/myisam/mi_rnext_same.c +++ b/myisam/mi_rnext_same.c @@ -57,7 +57,11 @@ int mi_rnext_same(MI_INFO *info, byte *buf) #endif case HA_KEY_ALG_BTREE: default: - memcpy(info->lastkey2,info->lastkey,info->last_rkey_length); + if (!(info->update & HA_STATE_RNEXT_SAME)) + { + /* First rnext_same; Store old key */ + memcpy(info->lastkey2,info->lastkey,info->last_rkey_length); + } for (;;) { if ((error=_mi_search_next(info,keyinfo,info->lastkey, @@ -81,7 +85,7 @@ int mi_rnext_same(MI_INFO *info, byte *buf) rw_unlock(&info->s->key_root_lock[inx]); /* Don't clear if database-changed */ info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); - info->update|= HA_STATE_NEXT_FOUND; + info->update|= HA_STATE_NEXT_FOUND | HA_STATE_RNEXT_SAME; if (error) { diff --git a/mysql-test/r/ctype_latin1_de.result b/mysql-test/r/ctype_latin1_de.result index 6df9d963498..f57d8c191bf 100644 --- a/mysql-test/r/ctype_latin1_de.result +++ b/mysql-test/r/ctype_latin1_de.result @@ -326,3 +326,15 @@ latin1_german2_ci 6109 latin1_german2_ci 61 latin1_german2_ci 6120 drop table t1; +SET NAMES latin1; +CREATE TABLE t1 ( +col1 varchar(255) NOT NULL default '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 collate latin1_german2_ci; +INSERT INTO t1 VALUES ('ß'),('ss'),('ss'); +ALTER TABLE t1 ADD KEY ifword(col1); +SELECT * FROM t1 WHERE col1='ß' ORDER BY col1, BINARY col1; +col1 +ss +ss +ß +DROP TABLE t1; diff --git a/mysql-test/t/ctype_latin1_de.test b/mysql-test/t/ctype_latin1_de.test index ce4fdc4e3c9..512ae88a445 100644 --- a/mysql-test/t/ctype_latin1_de.test +++ b/mysql-test/t/ctype_latin1_de.test @@ -116,3 +116,19 @@ SELECT FIELD('ue',s1), FIELD(' DROP TABLE t1; -- source include/ctype_filesort.inc + +# +# Bug#7878 with utf8_general_ci, equals (=) has problem with +# accent insensitivity. +# Although originally this problem was found with UTF8 character set, +# '=' behaved wrong for latin1_german2_ci as well. +# Let's check it does not work incorrect anymore. +# +SET NAMES latin1; +CREATE TABLE t1 ( + col1 varchar(255) NOT NULL default '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 collate latin1_german2_ci; +INSERT INTO t1 VALUES ('ß'),('ss'),('ss'); +ALTER TABLE t1 ADD KEY ifword(col1); +SELECT * FROM t1 WHERE col1='ß' ORDER BY col1, BINARY col1; +DROP TABLE t1;