Re: BUG #15421: Error: LIKE pattern must not end with escape character - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #15421: Error: LIKE pattern must not end with escape character
Date
Msg-id 4710.1538748537@sss.pgh.pa.us
Whole thread Raw
In response to BUG #15421: Error: LIKE pattern must not end with escape character  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
=?utf-8?q?PG_Bug_reporting_form?= <noreply@postgresql.org> writes:
> If I try to query the table with LIKE statement:
> SELECT COUNT(id) AS "records_found" FROM "tmp" WHERE lower("tmp"."name")
> LIKE 't\' I get the error "Error: LIKE pattern must not end with escape
> character".
> If I try to query the statement SELECT COUNT(id) AS "records_found" FROM
> "tmp" WHERE lower("tmp"."name") LIKE 'rs\' and others that do not match any
> records, there are no errors at all.

Yeah, the pattern is wrong, but the error is only detected if scanning of
the pattern reaches the end, which it won't if the match always fails
before that.

This has been complained of several times before, but it's something
that doesn't seem worth taking any performance hit for.  It's possible
that something along the lines of what I sketched in
https://www.postgresql.org/message-id/28169.1489781085@sss.pgh.pa.us
would be close enough to zero net cost to be OK.  Nobody's pursued it
though.

            regards, tom lane


pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #15420: Server crash. Segmentation fault when parsing xml file
Next
From: Sergey Mirvoda
Date:
Subject: Re: BUG #15420: Server crash. Segmentation fault when parsing xml file