diff options
-rw-r--r-- | myisam/mi_key.c | 4 | ||||
-rw-r--r-- | myisam/mi_search.c | 8 | ||||
-rw-r--r-- | mysql-test/r/select.result | 20 | ||||
-rw-r--r-- | mysql-test/t/select.test | 16 | ||||
-rw-r--r-- | sql/sql_string.cc | 8 |
5 files changed, 46 insertions, 10 deletions
diff --git a/myisam/mi_key.c b/myisam/mi_key.c index 58318697e57..766ecf334b6 100644 --- a/myisam/mi_key.c +++ b/myisam/mi_key.c @@ -62,7 +62,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, end=pos+length; if (type != HA_KEYTYPE_NUM) { - while (end > pos && (end[-1] == ' ' || end[-1] == '\t')) + while (end > pos && end[-1] == ' ') end--; } else @@ -186,7 +186,7 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, end=pos+length; if (type != HA_KEYTYPE_NUM) { - while (end > pos && (end[-1] == ' ' || end[-1] == '\t')) + while (end > pos && end[-1] == ' ') end--; } else diff --git a/myisam/mi_search.c b/myisam/mi_search.c index 82004c6f172..c6ee18a8477 100644 --- a/myisam/mi_search.c +++ b/myisam/mi_search.c @@ -795,9 +795,9 @@ int _mi_key_cmp(register MI_KEYSEG *keyseg, register uchar *a, uint length=(uint) (end-a), a_length=length, b_length=length; if (!(nextflag & SEARCH_PREFIX)) { - while (a_length && (a[a_length-1] == ' ' || a[a_length-1] == '\t')) + while (a_length && a[a_length-1] == ' ') a_length--; - while (b_length && (b[b_length-1] == ' ' || b[b_length-1] == '\t')) + while (b_length && b[b_length-1] == ' ') b_length--; } if (piks && @@ -849,9 +849,9 @@ int _mi_key_cmp(register MI_KEYSEG *keyseg, register uchar *a, if (!(nextflag & (SEARCH_PREFIX | SEARCH_UPDATE))) { - while (a_length && (a[a_length-1] == ' ' || a[a_length-1] == '\t')) + while (a_length && a[a_length-1] == ' ') a_length--; - while (b_length && (b[b_length-1] == ' ' || b[b_length-1] == '\t')) + while (b_length && b[b_length-1] == ' ') b_length--; } if (piks && diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 9cc5ad76ff0..206fa507615 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2307,3 +2307,23 @@ left join t4 on id3 = id4 where id2 = 1 or id4 = 1; id1 id2 id3 id4 id44 1 1 NULL NULL NULL drop table t1,t2,t3,t4; +create table t1(s varchar(10) not null); +create table t2(s varchar(10) not null primary key); +create table t3(s varchar(10) not null primary key); +insert into t1 values ('one\t'), ('two\t'); +insert into t2 values ('one\r'), ('two\t'); +insert into t3 values ('one '), ('two\t'); +select * from t1 where s = 'one'; +s +select * from t2 where s = 'one'; +s +select * from t3 where s = 'one'; +s +one +select * from t1,t2 where t1.s = t2.s; +s s +two two +select * from t2,t3 where t2.s = t3.s; +s s +two two +drop table t1, t2, t3; diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 3e23fa1a3f2..7cb157f194e 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -1858,3 +1858,19 @@ left join t4 on id3 = id4 where id2 = 1 or id4 = 1; drop table t1,t2,t3,t4; +# +# Bug #2298 +# + +create table t1(s varchar(10) not null); +create table t2(s varchar(10) not null primary key); +create table t3(s varchar(10) not null primary key); +insert into t1 values ('one\t'), ('two\t'); +insert into t2 values ('one\r'), ('two\t'); +insert into t3 values ('one '), ('two\t'); +select * from t1 where s = 'one'; +select * from t2 where s = 'one'; +select * from t3 where s = 'one'; +select * from t1,t2 where t1.s = t2.s; +select * from t2,t3 where t2.s = t3.s; +drop table t1, t2, t3; diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 2dcda2d40c2..658cd6d2411 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -467,9 +467,9 @@ int sortcmp(const String *x,const String *y) if (use_strcoll(default_charset_info)) { #ifndef CMP_ENDSPACE - while (x_len && isspace(s[x_len-1])) + while (x_len && s[x_len-1] == ' ') x_len--; - while (y_len && isspace(t[y_len-1])) + while (y_len && t[y_len-1] == ' ') y_len--; #endif return my_strnncoll(default_charset_info, @@ -493,14 +493,14 @@ int sortcmp(const String *x,const String *y) { const char *end=t+y_len; for (; t != end ; t++) - if (!isspace(*t)) + if (*t != ' ') return -1; } else { const char *end=s+x_len; for (; s != end ; s++) - if (!isspace(*s)) + if (*s != ' ') return 1; } return 0; |