Re: Conflict between JSON_AGG and COPY - Mailing list pgsql-general

From David G. Johnston
Subject Re: Conflict between JSON_AGG and COPY
Date
Msg-id CAKFQuwZQpeEAT5XX+A3t1eUeoQLNtzJyPwMbNj8SX==xji7H=A@mail.gmail.com
Whole thread Raw
In response to Re: Conflict between JSON_AGG and COPY  (Adrian Klaver <adrian.klaver@aklaver.com>)
List pgsql-general
On Mon, Apr 9, 2018 at 7:14 AM, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
On 04/08/2018 08:44 PM, Đỗ Ngọc Trí Cường wrote:

Presently, COPY TO will never emit an octal or hex-digits backslash sequence, but it does use the other sequences listed above for those control characters.


The second query is for the old version of PostgreSQL (9.3 and previous) cause of they don't have JSON_AGG aggregate function. Since 9.4, we have "JSON_AGG" already. So I want to rewrite and reduce the length of the query. But it is don't work as I expected with command COPY.

​Actually, COPY FROM will interpret the newlines just fine.  The issue here is that most other programs that injects csv are not as intelligent and will look at the \n as content as opposed to a control character.  Those programs will, however, recognize an actual newline within the quoted field as being valid data: but it doesn't appear that COPY is capable outputting such.

David J.

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Conflict between JSON_AGG and COPY
Next
From: Thomas Poty
Date:
Subject: Re: algo for canceling a deadlocked transaction