Re: The ignored "_" character

From: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
To: lkohl(at)matavnet(dot)hu, pgsql-bugs(at)postgresql(dot)org
Subject: Re: The ignored "_" character
Date: 2001-05-07 08:12:53
Message-ID: 20010507101253.A194@ara.zf.jcu.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, May 07, 2001 at 03:01:28AM -0400, pgsql-bugs(at)postgresql(dot)org wrote:
> Laszlo Kohl (lkohl(at)matavnet(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2001-05-07 15:28:52 Re: POSTGRESQL BUG REPORT
Previous Message pgsql-bugs 2001-05-07 07:01:28 The ignored "_" character