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

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: pavel(at)bnovo(dot)ru
Subject: BUG #15421: Error: LIKE pattern must not end with escape character
Date: 2018-10-05 13:11:43
Message-ID: 15421-6e32dfa391cfae4a@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 15421
Logged by: Pavel Shapovalov
Email address: pavel(at)bnovo(dot)ru
PostgreSQL version: 9.4.19
Operating system: Linux (4.9.0-4-amd64 #1 SMP Debian 4.9.65-3+deb9u)
Description:

Schema:
CREATE TABLE public.tmp (
id integer NOT NULL,
name text
);

Test data:
INSERT INTO tmp VALUES(1, 'test')

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". The same situation is for statement SELECT COUNT(id) AS
"records_found" FROM "tmp" WHERE lower("tmp"."name") LIKE 'te\' and others
if the LIKE pattern matches the beginning of the name field in any record.

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.

This behaviour is not clear from the documentation. Is it a bug or
undocumented feature?

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrew Gierth 2018-10-05 13:22:37 Re: BUG #15420: Server crash. Segmentation fault when parsing xml file
Previous Message Pavel Stehule 2018-10-05 12:44:58 Re: BUG #15420: Server crash. Segmentation fault when parsing xml file