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 4016.1222394071@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #4436: (E'\\' LIKE E'\\') => f  (Bruce Momjian <bruce@momjian.us>)
List pgsql-bugs
Bruce Momjian <bruce@momjian.us> writes:
> Tom Lane wrote:
>> Yeah.  The given case is actually an invalid LIKE pattern.  I wonder
>> whether we should make LIKE throw error for an invalid pattern.

> Yes, I think we should throw an error;  the original query looked odd to
> me too.

A quick check in the standard supports the idea of throwing an error.
In fact, SQL92 saith

             ii) If there is not a partitioning of the string P into sub-
                 strings such that each substring has length 1 or 2, no
                 substring of length 1 is the escape character E, and each
                 substring of length 2 is the escape character E followed by
                 either the escape character E, an <underscore> character,
                 or the <percent> character, then an exception condition is
                 raised: data exception-invalid escape sequence.

which not only requires E to not be the last character, but says that
it's a bug to escape anything but % _ or the escape character.  That
last part is too anal for me, but it does seem we're on safe ground to
throw error for escape with nothing to escape.  I'll go make it so.

            regards, tom lane

pgsql-bugs by date:

Previous
From: "Alex Hunsaker"
Date:
Subject: Re: Incorrect "invalid AM/PM string" error from to_timestamp
Next
From: austijc
Date:
Subject: ERROR: unexpected data beyond EOF in block XXXXX of relation "file"