At 11:28 AM -0500 4/26/1999, Harald Fuchs wrote:
>Hi,
>I think I have found a bug in MySQL (3.21.33b, for pc-linux-gnu on
>i686, if that should matter):
>
>mysql> create table foo (bar varchar(20));
>Query OK, 0 rows affected (0.00 sec)
>
>mysql> insert into foo values ('aaa\\bbb');
>Query OK, 1 row affected (0.00 sec)
> # Need to duplicate backslash since \b is a backspace, but we
>really
> # want `aaa backslash bbb'
>mysql> select * from foo where bar like 'aaa%';
>+---------+
>| bar |
>+---------+
>| aaa\bbb |
>+---------+
>1 row in set (0.00 sec)
> # Fine!
>mysql> select * from foo where bar like 'aaa\b%';
>Empty set (0.00 sec)
> # Mhm - maybe we need to escape the backslash again?
>mysql> select * from foo where bar like 'aaa\\b%';
>Empty set (0.00 sec)
> # This is a bug, I think ...
>mysql> select * from foo where bar like 'aaa_b%';
>+---------+
>| bar |
>+---------+
>| aaa\bbb |
>+---------+
>1 row in set (0.00 sec)
> # ... because this works
mysql> select * from foo where bar like 'aaa\\\\bbb';
+---------+
| bar |
+---------+
| aaa\bbb |
+---------+
1 row in set (0.01 sec)
The backslashes are stripped once by the parser, and another time
when the pattern match is done, leaving a single backslash to be
matched.
--
Paul DuBois, paul@stripped
Northern League Chronicles: http://www.snake.net/nl/