Re: BUG #15084: Invalid LIKE pattern not always reported

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: tudorb(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: BUG #15084: Invalid LIKE pattern not always reported
Date: 2018-02-23 20:43:30
Message-ID: CAKFQuwbBwjn5KeDOYm-6_uOn_WWyj0ptsGLO-kqVtiei2h6AAw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Feb 23, 2018 at 1:29 PM, PG Bug reporting form <
noreply(at)postgresql(dot)org> wrote:

> The following bug has been logged on the website:
>
> Bug reference: 15084
> Logged by: Tudor Bosman
> Email address: tudorb(at)gmail(dot)com
> PostgreSQL version: 9.5.11
> Operating system: Ubuntu 16.04
> Description:
>
> PostgreSQL will not always detect an invalid LIKE pattern (one that ends
> with a backslash).
>
> Example:
>
> tudor=# select 'foo' like 'foo\';
> ?column?
> ----------
> f
> (1 row)
>
> tudor=# select 'foobar' like 'foo\';
> ERROR: LIKE pattern must not end with escape character
>
> This probably happens because the pattern is only parsed lazily (as
> needed);
> if PostgreSQL detects that a match is impossible, it doesn't even look at
> the rest of the pattern.
>
> Still, it would be nice for error reporting to be consistent.
>

​Last March (Bug# 14512) Tom Lane thought a performant solution was
possible though it was never committed.

https://www.postgresql.org/message-id/28169.1489781085%40sss.pgh.pa.us

I'm still +1 if it can be done without hurting performance on patterns that
do match - a compile-time failure here is desirable.

Full thread here:

https://www.postgresql.org/message-id/flat/20170124172505(dot)1431(dot)56735%40wrigleys(dot)postgresql(dot)org#20170124172505(dot)1431(dot)56735(at)wrigleys(dot)postgresql(dot)org

David J.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2018-02-23 20:51:41 Re: BUG #15084: Invalid LIKE pattern not always reported
Previous Message PG Bug reporting form 2018-02-23 20:29:15 BUG #15084: Invalid LIKE pattern not always reported