Re: Proper quoting of \e ?

From: Joe Conway <mail(at)joeconway(dot)com>
To: Helge Kreutzmann <kreutzm(at)itp(dot)uni-hannover(dot)de>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Proper quoting of \e ?
Date: 2002-04-25 16:23:01
Message-ID: 3CC82D65.9010809@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message David Stanaway 2002-04-25 16:46:31 Re: SELECT in a function != SELECT ?
Previous Message Helge Kreutzmann 2002-04-25 15:57:18 Re: Proper quoting of \e ?