Re: Inserting string with a " into an array using {} syntax ... possible?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bill Moran <wmoran(at)potentialtech(dot)com>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Inserting string with a " into an array using {} syntax ... possible?
Date: 2009-03-13 20:20:05
Message-ID: 4809.1236975605@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bill Moran <wmoran(at)potentialtech(dot)com> writes:
> In response to Alvaro Herrera <alvherre(at)commandprompt(dot)com>:
>> Actually this one is good. It gets the backslashes in the output because the "
>> need to be escaped there too ('cause it's an array). But if you output a
>> single element, they are not there:

> Bizarre, but it passes my other tests as well, so I'll have to accept
> it as correct ... just seems wrong somehow.

Well, the point is that the array output subroutine re-applies the
escaping, so that what it outputs will be acceptable to array input too
(modulo extra escaping for string literals of course, but dump and
reload via COPY is the driving consideration here). This is all
explained under "Array Input and Output Syntax":
http://www.postgresql.org/docs/8.3/static/arrays.html#AEN6156

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Glen Parker 2009-03-13 20:48:48 Re: I don't want to back up index files
Previous Message Jeremy Harris 2009-03-13 20:14:17 Re: I don't want to back up index files