Problem with do_quote_ident() - Mailing list pgsql-hackers

From Bruce Momjian
Subject Problem with do_quote_ident()
Date
Msg-id 200203272054.g2RKsdM22367@candle.pha.pa.us
Whole thread Raw
Responses Re: Problem with do_quote_ident()  (Jan Wieck <janwieck@yahoo.com>)
List pgsql-hackers
I see in quote.c::do_quote_ident():
*cp2++ = '"';while (len-- > 0){    if (*cp1 == '"')        *cp2++ = '"';    if (*cp1 == '\\')        *cp2++ = '\\';
*cp2++= *cp1++;}*cp2++ = '"';
 

I am confused by the backslash handling. In my tests, a backslash in a
double-quoted string does not require two backslashes:test=> create user "a\d";CREATE USERtest=> select usename,
length(usename)from pg_user; usename  | length ----------+-------- a\d      |      3
 

This is because a double-quote in a double-quoted string is entered as
"", not \".

Is it adding another backslash because it assumes the result will appear
in another quoted string?

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


pgsql-hackers by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: RI triggers and schemas
Next
From: Jan Wieck
Date:
Subject: Re: Problem with do_quote_ident()