Bug #8815 Wrong string comparsion for cp1250_czech_cs collation
Submitted: 25 Feb 2005 19:46 Modified: 8 Apr 2005 6:47
Reporter: Gleb Paharenko Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1.10 OS:Linux (Linux)
Assigned to: CPU Architecture:Any

[25 Feb 2005 19:46] Gleb Paharenko
Description:
Hello

I think we have a wrong string comparsion in cp1250_czech_cs collation
Because result is different from cp1251_general_cs, utf8_bin and other xxx_xxx_cs collations. It is just  case sensitive, and the empty string shouldn't depend on country and  all case
sensitive collations should give the same results.

How to repeat:

mysql> create table ts(t1 varchar(5),t2 varchar(5)) default charset=cp1250 collate=cp1250_czech_cs;
Query OK, 0 rows affected (0.06 sec)

mysql> insert into ts values('a',''),('b',' ');
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> select t2 =''   from ts;
+--------+
| t2 ='' |
+--------+
|      0 |
|      0 |
+--------+

And for other case sensivite collation it give another results

mysql> create table tt(t1 varchar(5),t2 varchar(5)) default charset=cp1251 collate=cp1250_general_cs;

mysql> insert into tt values('a',''),('b',' ');
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> select t2 =''   from tt;
+--------+
| t2 ='' |
+--------+
|      1 |
|      1 |
+--------+

Suggested fix:

Fix comparing of the empty strings.
[26 Feb 2005 1:40] MySQL Verification Team
Did you able for to run the second sample:

create table tt(t1 varchar(5),t2 varchar(5)) default charset=cp1251
collate=cp1250_general_cs;

I only find collate=cp1251_general_cs as valid one.

Thank you in advance.
[26 Feb 2005 14:21] Gleb Paharenko
Hi.
I was unable to create such table because, really, there wasn't such collation cp1250_general_cs for character set cp1251(I think you wanted to write cp1250? ).
I used cp1251 character set and cp1251_general_cs collation only as example for case
sensitive collation. My idea was that empty string comparsion is wrong for cp1250_czech_cs,
which is just national case sensitive czech collation. I think that comparsion of empty strings should be the  same for all   national collations, and really shouldn't depend on anything.
[26 Feb 2005 14:27] Gleb Paharenko
I want to underline, that the problem is in cp1250_czech_cs collation. Empty string doesn't
equal to ''. See:
create table cz(a varchar(5)) default charset=cp1250 collate=cp1250_czech_cs;
mysql> insert into tz values('');
mysql> select a='' from cz;
+------+
| a='' |
+------+
|    0 |
+------+

We inserted '', but selecting a='' returns 0! (should return 1)
[7 Mar 2005 8:33] Gleb Paharenko
Does the status change to Open After I'd added comments?
[7 Apr 2005 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[8 Apr 2005 6:47] Gleb Paharenko
Wow! Why is it "No FeedBack"?