From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Đỗ Ngọc Trí Cường <dntcuong@digi-texx.vn>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: Conflict between JSON_AGG and COPY
Date: Mon, 9 Apr 2018 07:14:45 -0700
Message-ID: <089767b9-d84c-498f-6ad7-412e054d592a@aklaver.com> (raw)
In-Reply-To: <688939859.13457181.1523245447673.JavaMail.zimbra@digi-texx.vn>
References: <152647427.13167958.1523097853639.JavaMail.zimbra@digi-texx.vn>
<fe1c7756-e724-63a7-b200-b2361689b924@aklaver.com>
<688939859.13457181.1523245447673.JavaMail.zimbra@digi-texx.vn>
On 04/08/2018 08:44 PM, Đỗ Ngọc Trí Cường wrote:
> Dear Arian Klaver,
>
> I think there is a misunderstood here.
>
> I think that I quite understand how is the second query run.
>
> The question I asked here is why exporting data, which is generated by a
> query "JSON_AGG" , with command "COPY". The data contain "\n" as 2
> characters instead of "new line" character.
https://www.postgresql.org/docs/10/static/sql-copy.html
File Formats
Text Format
"
\n Newline (ASCII 10)
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.
...
COPY TO will terminate each row with a Unix-style newline (“\n”).
"
>
> 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.
>
> Thank you and best regards,
>
>
> Đỗ Ngọc Trí*Cường*(Mr.) | *Software Development Department*| +84 28 3715
> 5325
--
Adrian Klaver
adrian.klaver@aklaver.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, dntcuong@digi-texx.vn
Subject: Re: Conflict between JSON_AGG and COPY
In-Reply-To: <089767b9-d84c-498f-6ad7-412e054d592a@aklaver.com>
References: <152647427.13167958.1523097853639.JavaMail.zimbra@digi-texx.vn> <fe1c7756-e724-63a7-b200-b2361689b924@aklaver.com> <688939859.13457181.1523245447673.JavaMail.zimbra@digi-texx.vn> <089767b9-d84c-498f-6ad7-412e054d592a@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox