Re: BUG #4436: (E'\\' LIKE E'\\') => f - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #4436: (E'\\' LIKE E'\\') => f
Date
Msg-id 10530.1222286454@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #4436: (E'\\' LIKE E'\\') => f  (Bruce Momjian <bruce@momjian.us>)
Responses Re: BUG #4436: (E'\\' LIKE E'\\') => f
List pgsql-bugs
Bruce Momjian <bruce@momjian.us> writes:
> Mathieu Fenniak wrote:
>> I noticed that (SELECT E'\\' LIKE E'\\') returns false,

> I believe this is caused because backslash is the default escape
> character for LIKE, so you need:
>     test=> SELECT E'\\' LIKE E'\\\\';

Yeah.  The given case is actually an invalid LIKE pattern.  I wonder
whether we should make LIKE throw error for an invalid pattern.
You get an error for the corresponding case in regex:

regression=# select E'\\' ~ E'\\';
ERROR:  invalid regular expression: invalid escape \ sequence

but IIRC the LIKE code just silently ignores a trailing escape
character.

            regards, tom lane

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Postgres won't start and doesn't generate any messages.
Next
From: "Joshua Tolley"
Date:
Subject: Incorrect "invalid AM/PM string" error from to_timestamp