On Mon, May 07, 2001 at 03:01:28AM -0400, pgsql-bugs@postgresql.org wrote:
> Laszlo Kohl (lkohl@matavnet.hu) reports a bug with a severity of 2
> The lower the number the more severe it is.
>
> Short Description
> The ignored "_" character
>
> Long Description
> Hi,
>
> I am Laszlo from Hungary.
> I have some problem with PostgreSQL.
>
> Environment:
> PostgreSQL version: 7.0.3
> Server OS: RedHat 5.2 , Linux-Mandrake 7.2
> Client OS: RedHat 5.2 , Windows NT (pgAdmin) , Linux-Mandrake 7.2
>
> The problem:
> I create some users in database and then want to list them.
> The "_" character is ignored in query statement.
> The query: "select usename from pg_user where usename Like '%_u%' ;"
> produces the same result as the query:
> "select usename from pg_user where usename Like '%u%' ;"
Sure it's not bug, please read something about the 'like' operator
first, en example:
http://postgresql.wavefire.com/users-lounge/docs/7.1/user/functions-matching.html
If pattern does not contain percent signs or underscore, then the pattern
only represents the string itself; in that case LIKE acts like the equals
operator. An underscore (_) in pattern stands for (matches) any single
character; a percent sign (%) matches any string of zero or more
characters.
You must run:
... usename LIKE '%\\_u%'
Note two '\' must be used here because PostgreSQL parser first remove
and 'like' operator obtain second only.
Karel