diff options
author | jimw@mysql.com <> | 2005-01-28 17:18:35 -0800 |
---|---|---|
committer | jimw@mysql.com <> | 2005-01-28 17:18:35 -0800 |
commit | 691cd6c50dde4d583c2bfd7cfc16cb1a80ed5782 (patch) | |
tree | b8a1d55380d40a9795bcd517a40e07dc79b2460d | |
parent | bcf1cb0f234719bf225458b84f42ce0069e4405f (diff) | |
download | mariadb-git-691cd6c50dde4d583c2bfd7cfc16cb1a80ed5782.tar.gz |
Fix error in string comparisons with CHAR(31) against the space-padding
of strings of unequal length. (Bug #8134)
-rw-r--r-- | mysql-test/r/compare.result | 3 | ||||
-rw-r--r-- | mysql-test/t/compare.test | 3 | ||||
-rw-r--r-- | strings/ctype-simple.c | 2 |
3 files changed, 7 insertions, 1 deletions
diff --git a/mysql-test/r/compare.result b/mysql-test/r/compare.result index bf8a5106044..49ec2dd85cc 100644 --- a/mysql-test/r/compare.result +++ b/mysql-test/r/compare.result @@ -36,3 +36,6 @@ hex(a) STRCMP(a,'a') STRCMP(a,'a ') 6109 -1 -1 61 0 0 DROP TABLE t1; +SELECT CHAR(31) = '', '' = CHAR(31); +CHAR(31) = '' '' = CHAR(31) +0 0 diff --git a/mysql-test/t/compare.test b/mysql-test/t/compare.test index b0cef48dd3f..e3c042e608a 100644 --- a/mysql-test/t/compare.test +++ b/mysql-test/t/compare.test @@ -30,3 +30,6 @@ CREATE TABLE t1 (a char(10) not null); INSERT INTO t1 VALUES ('a'),('a\0'),('a\t'),('a '); SELECT hex(a),STRCMP(a,'a'), STRCMP(a,'a ') FROM t1; DROP TABLE t1; + +# Bug #8134: Comparison against CHAR(31) at end of string +SELECT CHAR(31) = '', '' = CHAR(31); diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 5bfa9e52595..4dc6a1be27b 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -153,7 +153,7 @@ int my_strnncollsp_simple(CHARSET_INFO * cs, const uchar *a, uint a_length, /* put shorter key in s */ a_length= b_length; a= b; - swap= -1; /* swap sign of result */ + swap= -1^1; /* swap sign of result */ } for (end= a + a_length-length; a < end ; a++) { |