Description.

The bug is about selecting binary varchar fields and consists in erratic
behaviour of these fields in combination with OR. When executing a SELECT
statement with an ORed WHERE-clause such that the two basic clauses each
select a differently cased variant of one (binary varchar) term, only the
first is returned, although both are in the table.

The funny thing is that this only holds when you have *two* clauses with one
OR. With more ORs, the bug disappears.

Concretely:

<screenshot>
mysql> desc terms;
+-------------+---------------------+------+-----+---------+-------+
| Field       | Type                | Null | Key | Default | Extra |
+-------------+---------------------+------+-----+---------+-------+
| term        | varchar(200) binary |      | PRI |         |       |
| corpus_id   | decimal(15,0)       |      | PRI | 0       |       |
| frequency   | decimal(15,0)       |      |     | 0       |       |
| weight      | float               | YES  |     | NULL    |       |
| n_documents | decimal(15,0)       |      |     | 0       |       |
+-------------+---------------------+------+-----+---------+-------+
5 rows in set (0.00 sec)

mysql> select * from terms where term = 'bank' OR term = 'Bank';
+------+-----------+-----------+--------+-------------+
| term | corpus_id | frequency | weight | n_documents |
+------+-----------+-----------+--------+-------------+
| bank |         2 |       128 |   NULL |          75 |
+------+-----------+-----------+--------+-------------+
1 row in set (0.00 sec)

mysql> select * from terms where term = 'Bank' OR term = 'bank';
+------+-----------+-----------+--------+-------------+
| term | corpus_id | frequency | weight | n_documents |
+------+-----------+-----------+--------+-------------+
| Bank |         2 |       176 |   NULL |          99 |
+------+-----------+-----------+--------+-------------+
1 row in set (0.01 sec)

mysql> select * from terms where term = 'bank' OR term = 'Bank' OR term =
'banks' or term = 'Banks';

+-------+-----------+-----------+--------+-------------+
| term  | corpus_id | frequency | weight | n_documents |
+-------+-----------+-----------+--------+-------------+
| Bank  |         2 |       176 |   NULL |          99 |
| Banks |         2 |        18 |   NULL |          11 |
| bank  |         2 |       128 |   NULL |          75 |
| banks |         2 |       176 |   NULL |          66 |
+-------+-----------+-----------+--------+-------------+
4 rows in set (0.00 sec)

mysql> 
<\screenshot>

(The client on a WinNT machine (mysql  Ver 9.37 Distrib 3.22.29, for
Win95/Win98 (i586))).

Submitter ID: Jan Voskuil

Organization: SmartHaven, www.smarthaven.com

MySql support: none

Synopsis: Binary varchar fields behave erratically under ORed select-clauses
with respect to casing.

Release: mysql-3.23.32 (Source distribution)

Environment: Linux Redhat 7

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to