From: | Jan Wieck <janwieck(at)yahoo(dot)com> |
---|---|
To: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Problem with do_quote_ident() |
Date: | 2002-03-27 21:18:38 |
Message-ID: | 200203272118.g2RLIc227802@saturn.janwieck.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Bruce Momjian wrote:
> 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 USER
> test=> 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?
I would say it is adding another backslash because it is a
bug. If you use quote_ident() in a plpgsql procedure to
build querystrings for EXECUTE (and you should do it that
way), then it'll no handle identifiers that contain
backslashes correctly.
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
From | Date | Subject | |
---|---|---|---|
Next Message | Nicolas Bazin | 2002-03-27 22:34:53 | Re: build of 7.2.1 on SCO Openserver and Unixware 7.1.1 |
Previous Message | Bruce Momjian | 2002-03-27 20:54:39 | Problem with do_quote_ident() |