Re: = or LIKE ?

From: Jesper Krogh <jesper(at)krogh(dot)cc>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: = or LIKE ?
Date: 2009-02-15 19:20:18
Message-ID: 49986AF2.4010206@krogh.cc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Tom Lane wrote:
> Jesper Krogh <jesper(at)krogh(dot)cc> writes:
>> Shouldnt the like operator do the same as the = if there occours no
>> wildcards and stuff in the string?
>
> If there are also no escape characters, then yeah.
>
> FWIW, 8.4 will complain about this case:
>
> regression=# select E'\\' like E'\\';
> ERROR: LIKE pattern must not end with escape character

So I cannot rely on the like operator to behave correct if I'd like to
compare strings with backslashes (e.g. filepaths from MS Windows
filesystems)?

I actually get the same if it doesnt end with the slashes:
testdb=# select E'\\t' like E'\\t';
?column?
----------
f
(1 row)

testdb=# select E'\\t' = E'\\t';
?column?
----------
t
(1 row)

--
Jesper

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Jesper Krogh 2009-02-15 19:27:03 Re: = or LIKE ?
Previous Message Tom Lane 2009-02-15 18:42:40 Re: = or LIKE ?