Skip site navigation (1) Skip section navigation (2)

Bug #480: problem with LIKE pattern matches involving % and \_

From: pgsql-bugs(at)postgresql(dot)org
To: pgsql-bugs(at)postgresql(dot)org
Subject: Bug #480: problem with LIKE pattern matches involving % and \_
Date: 2001-10-12 09:26:58
Message-ID: 200110120926.f9C9QwS09501@postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugs
Tom Cross (decius(at)whack(dot)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


Responses

pgsql-bugs by date

Next:From: Max FoninDate: 2001-10-12 11:50:03
Subject: Re: [tim@perdue.net: Re: mysql2pgsql tool]
Previous:From: Thomas LockhartDate: 2001-10-12 05:35:42
Subject: Re: Bug #463: Make 'infinity' work with type 'date'

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group