Re: LIKE predicate and '\' character - Mailing list pgsql-hackers

From Stephan Szabo
Subject Re: LIKE predicate and '\' character
Date
Msg-id 20011107092052.M49204-100000@megazone23.bigpanda.com
Whole thread Raw
In response to LIKE predicate and '\' character  ("Andy Hallam" <ahm@exel.co.uk>)
List pgsql-hackers
On Wed, 7 Nov 2001, Andy Hallam wrote:

> PostgreSQL - 7.1.3  (installed on Linux 2.4.2-2)
> PSQLODBC.DLL - 07.01.0007
> Visual C++ - 6.0
>
> I sent a previous mail with regard to using the '\' (backslash) character in
> an SQL SELECT statement.
> The outcome was that postgres does not escape the '\' itself - I need to do
> it myself before submitting the SQL - fair enough, I now do this.
>
> i.e
> instead of
>     mydb=# SELECT * FROM users WHERE id = 'WORKGROUP\me';
> I now do
>     mydb=# SELECT * FROM users WHERE id = 'WORKGROUP\\me';
>
> BUT, if I use the LIKE predicate I have to escape the escape.
>
> i.e
>     mydb=# SELECT * FROM users WHERE id LIKE 'WORKGROUP\\\\me';
>
>
> Now this must be treated as a bug.

Postgres *also* treats \ as the default LIKE escape character.
Use LIKE '<string>' ESCAPE '' (or some other character if
you want to use the like escaping for %, etc).




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: LIKE predicate and '\' character
Next
From: Tom Lane
Date:
Subject: Re: performance problem with 3-column indexes