Skip site navigation (1) Skip section navigation (2)

Re: Using backslash in query

From: Hannu Krosing <hannu(at)tm(dot)ee>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: michael(at)synchronicity(dot)com,"pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Using backslash in query
Date: 2003-10-04 08:20:09
Message-ID: 1065255609.2746.14.camel@fuji.krosing.net (view raw or flat)
Thread:
Lists: pgsql-hackers
Tom Lane kirjutas R, 03.10.2003 kell 18:34:
> Michael Brusser <michael(at)synchronicity(dot)com> writes:
> > But when I doubled the number of backslashes:
> >   SELECT smth. FROM  tbl WHERE situation LIKE '%\\\\%';
> > - it actually worked fine.
> 
> Backslash is special to both the string-literal parser and the LIKE code.
> So when you write the above, the pattern value that arrives at the LIKE
> processor has one less level of backslashing:
> 	%\\%
> and the LIKE processor interprets this as percent, a literal backslash,
> and another percent.

Regarding the dollar-quoting discussions -

Will we be able to write the above query as 

SELECT smth. FROM  tbl WHERE WHERE situation LIKE $$%\\%$$;

in 7.4 or is \ still special there ?

if it is then one \ in regex in plpython still needs to be entered as
\\\\\\\\ which has some geek coolness but would not be what I'd prefer
to do on a regular basis.

----------------
Hannu


In response to

Responses

pgsql-hackers by date

Next:From: Hannu KrosingDate: 2003-10-04 09:00:04
Subject: Re: [HACKERS] Index/Function organized table layout (from Re:
Previous:From: Hannu KrosingDate: 2003-10-04 08:09:49
Subject: Re: Dreaming About Redesigning SQL

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group