pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #15084: Invalid LIKE pattern not always reported
3+ messages / 3 participants
[nested] [flat]

* BUG #15084: Invalid LIKE pattern not always reported
@ 2018-02-23 20:29 PG Bug reporting form <noreply@postgresql.org>
  2018-02-23 20:43 ` Re: BUG #15084: Invalid LIKE pattern not always reported David G. Johnston <david.g.johnston@gmail.com>
  2018-02-23 20:51 ` Re: BUG #15084: Invalid LIKE pattern not always reported Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 3+ messages in thread

From: PG Bug reporting form @ 2018-02-23 20:29 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: tudorb@gmail.com

The following bug has been logged on the website:

Bug reference:      15084
Logged by:          Tudor Bosman
Email address:      tudorb@gmail.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.

Thanks,
-Tudor.



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #15084: Invalid LIKE pattern not always reported
  2018-02-23 20:29 BUG #15084: Invalid LIKE pattern not always reported PG Bug reporting form <noreply@postgresql.org>
@ 2018-02-23 20:43 ` David G. Johnston <david.g.johnston@gmail.com>
  1 sibling, 0 replies; 3+ messages in thread

From: David G. Johnston @ 2018-02-23 20:43 UTC (permalink / raw)
  To: tudorb@gmail.com, pgsql-bugs@lists.postgresql.org, Tom Lane <tgl@sss.pgh.pa.us>

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

> The following bug has been logged on the website:
>
> Bug reference:      15084
> Logged by:          Tudor Bosman
> Email address:      tudorb@gmail.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.1431.56735%40wrigleys.postgresql.org#20170...

David J.

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #15084: Invalid LIKE pattern not always reported
  2018-02-23 20:29 BUG #15084: Invalid LIKE pattern not always reported PG Bug reporting form <noreply@postgresql.org>
@ 2018-02-23 20:51 ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 2018-02-23 20:51 UTC (permalink / raw)
  To: tudorb@gmail.com; +Cc: pgsql-bugs@lists.postgresql.org

=?utf-8?q?PG_Bug_reporting_form?= <noreply@postgresql.org> writes:
> PostgreSQL will not always detect an invalid LIKE pattern (one that ends
> with a backslash).
> 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.

Yeah, exactly.

> Still, it would be nice for error reporting to be consistent.

This has been discussed before, but nobody could see how to do it without
taking a performance hit (ie, doing a full scan of the pattern before
doing any actual work).  It didn't seem worth that.

It occurs to me that we could make the behavior more consistent by
redefining a trailing backslash as something we silently ignore, instead
of raising an error.  Not sure if that's an improvement, though.

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2018-02-23 20:51 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-02-23 20:29 BUG #15084: Invalid LIKE pattern not always reported PG Bug reporting form <noreply@postgresql.org>
2018-02-23 20:43 ` David G. Johnston <david.g.johnston@gmail.com>
2018-02-23 20:51 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox