Re: BUG #15421: Error: LIKE pattern must not end with escape character

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pavel(at)bnovo(dot)ru
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #15421: Error: LIKE pattern must not end with escape character
Date: 2018-10-05 14:08:57
Message-ID: 4710.1538748537@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

=?utf-8?q?PG_Bug_reporting_form?= <noreply(at)postgresql(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Sergey Mirvoda 2018-10-05 14:33:44 Re: BUG #15420: Server crash. Segmentation fault when parsing xml file
Previous Message Tom Lane 2018-10-05 14:00:18 Re: BUG #15420: Server crash. Segmentation fault when parsing xml file