Re: BUG #4436: (E'\\' LIKE E'\\') => f

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Mathieu Fenniak <hjoiiv(at)mathieu(dot)fenniak(dot)net>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4436: (E'\\' LIKE E'\\') => f
Date: 2008-09-26 01:54:31
Message-ID: 4016.1222394071@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Bruce Momjian <bruce(at)momjian(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2008-09-26 03:31:17 Re: ERROR: unexpected data beyond EOF in block XXXXX of relation "file"
Previous Message austijc 2008-09-26 00:09:43 ERROR: unexpected data beyond EOF in block XXXXX of relation "file"