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

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: (view raw, whole thread or download thread mbox)
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

pgsql-bugs by date

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

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