Re: Proper quoting of \e ? - Mailing list pgsql-sql

From Joe Conway
Subject Re: Proper quoting of \e ?
Date
Msg-id 3CC82D65.9010809@joeconway.com
Whole thread Raw
In response to Proper quoting of \e ?  (Helge Kreutzmann <kreutzm@itp.uni-hannover.de>)
List pgsql-sql
Helge Kreutzmann wrote:
> Well, the "\" is part of the strings to be outputed, so I did not
> intend to quota anything. If I replace \ to \\ in my first query, I
> get also no result.
> 

I think you need 4 '\'s:

test=# create table written_by(title text);
CREATE
test=# insert into written_by values('An equation of state {\\em \\\`a 
la} Carnahan-Starling');
INSERT 16661 1
test=# select * from written_by;                        title
----------------------------------------------------- An equation of state {\em \`a la} Carnahan-Starling
(1 row)

test=# SELECT title from written_by where title like 'An equation of 
state {\\\\e%';                        title
----------------------------------------------------- An equation of state {\em \`a la} Carnahan-Starling
(1 row)


This is because the string literal parser reduces '\\\\' to '\\', and 
then the backend function which implements LIKE interprets '\\' as '\'.

HTH,

Joe






pgsql-sql by date:

Previous
From: Helge Kreutzmann
Date:
Subject: Re: Proper quoting of \e ?
Next
From: David Stanaway
Date:
Subject: Re: SELECT in a function != SELECT ?