Bug #480: problem with LIKE pattern matches involving % and \_ - Mailing list pgsql-bugs

From pgsql-bugs@postgresql.org
Subject Bug #480: problem with LIKE pattern matches involving % and \_
Date
Msg-id 200110120926.f9C9QwS09501@postgresql.org
Whole thread Raw
Responses Re: Bug #480: problem with LIKE pattern matches involving  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Re: Bug #480: problem with LIKE pattern matches involving % and \_  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Tom Cross (decius@whack.org) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
problem with LIKE pattern matches involving % and \_

Long Description
The following pattern matches do not work:

LIKE '%\_%'
LIKE '%\_'
LIKE '\_%'

They seem to match everything even if it does not contain an underscore. There seems to be no problem if another
character 
is involved somehow, such as LIKE '\_b%'

I'm running 7.1.3...



Sample Code
somedatabase=# select * from tom;
   stuff
-----------
 blah
 blah_
 _blah
 blah_blah
(4 rows)

somedatabase=# select * from tom where stuff LIKE '%\_%';
   stuff
-----------
 blah
 blah_
 _blah
 blah_blah
(4 rows)

somedatabase=# select * from tom where stuff LIKE '\_%';
   stuff
-----------
 blah
 blah_
 _blah
 blah_blah
(4 rows)

somedatabase=# select * from tom where stuff LIKE '%h\_%';
  stuff
-----------
 blah_
 blah_blah
(2 rows)


No file was uploaded with this report

pgsql-bugs by date:

Previous
From: Lee Kindness
Date:
Subject: ecpg - GRANT bug
Next
From: Bruce Momjian
Date:
Subject: Re: [tim@perdue.net: Re: mysql2pgsql tool]