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

Re: [HACKERS] escape character \

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: sferac(at)proxy(dot)bazzanese(dot)com (Jose' Soares Da Silva)
Cc: pgsql/questions(at)postgreSQL(dot)org, pgsql-hackers(at)postgreSQL(dot)org, sferac(at)bo(dot)nettuno(dot)it
Subject: Re: [HACKERS] escape character \
Date: 1998-04-27 03:34:25
Message-ID: 199804270334.XAA20328@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
> 
> Seems there's a bug using ESCAPE character (\) on LIKE clause:
> 
> prova=> create table tmp ( a text);
> CREATE
> prova=> insert into tmp values('\\');
> INSERT 178729 1
> prova=> select * from tmp where a = '\\';
> a
> --
> \\
> (1 row)
> 
> prova=> select * from tmp where a like '%\\%';
> a
> -
> (0 rows)
> 
> prova=> select * from tmp where a like '%\\\\%';
> a
> --
> \\
> (1 row)
> 
> -- how many \ do I have to use? 1, 2, 3, 4 or 5 ???
> 
> prova=> select * from tmp where a like '%\\\\\%';
> a
> --
> \\
> (1 row)
>                                                   Jose'

The problem is that that \\ is need to input a backslash, and we support
\ to escape special characters like %, so \\\\ is need to test for a
backslash in a LIKE.  Is this not standard?  I suppose not.  Should we
remove the special use of \ in LIKE?  Comments?


-- 
Bruce Momjian                          |  830 Blythe Avenue
maillist(at)candle(dot)pha(dot)pa(dot)us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)

In response to

Responses

pgsql-hackers by date

Next:From: Bruce MomjianDate: 1998-04-27 03:43:10
Subject: Re: [HACKERS] Bug or Short between my brain and the keyboard?
Previous:From: Bruce MomjianDate: 1998-04-27 03:21:09
Subject: Re: [HACKERS] Agregates in update?

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