From: Joe Conway <mail@joeconway.com>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Daniel Verite <daniel@manitou-mail.org>
Cc: Andrew Dunstan <andrew@dunslane.net>
Cc: Davin Shearer <davin@apache.org>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: Emitting JSON to file using COPY TO
Date: Thu, 7 Dec 2023 10:07:59 -0500
Message-ID: <61818b31-4e7a-4d99-b08a-9e545dbf0038@joeconway.com> (raw)
In-Reply-To: <CAKFQuwZ2e6QanxpoUarMva0mp1UJvT9bOJRwhkZ8w_E=K-s8ww@mail.gmail.com>
References: <3df907b2-0a3a-4597-8ef1-707b553667cd@manitou-mail.org>
<0344a366-5176-4131-b7ca-b6b74857b841@joeconway.com>
<6a04628d-0d53-41d9-9e35-5a8dc302c34c@joeconway.com>
<CAKFQuwZ2e6QanxpoUarMva0mp1UJvT9bOJRwhkZ8w_E=K-s8ww@mail.gmail.com>
On 12/7/23 09:11, David G. Johnston wrote:
> Those are all the same breakage though - if truly interpreted as data
> rows the protocol is basically written such that the array format is not
> supportable and only the lines format can be used. Hence my “format 0
> doesn’t work” comment for array output and we should explicitly add
> format 2 where we explicitly decouple lines of output from rows of
> data. That said, it would seem in practice format 0 already decouples
> them and so the current choice of the brackets on their own lines is
> acceptable.
>
> I’d prefer to keep them on their own line.
WFM ¯\_(ツ)_/¯
I am merely responding with options to the many people opining on the
thread.
> I also don’t know why you introduced another level of object nesting
> here. That seems quite undesirable.
I didn't add anything. It is an artifact of the particular query I wrote
in the copy to statement (I did "select ss from ss" instead of "select *
from ss"), mea culpa.
This is what the latest patch, as written today, outputs:
8<----------------------
copy
(select 1, g.i from generate_series(1, 3) g(i))
to stdout (format json, force_array);
[
{"?column?":1,"i":1}
,{"?column?":1,"i":2}
,{"?column?":1,"i":3}
]
8<----------------------
--
Joe Conway
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.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 using the --to and --cc options:
reply via email
To: pgsql-general@postgresql.org
Cc: mail@joeconway.com, david.g.johnston@gmail.com, daniel@manitou-mail.org, andrew@dunslane.net, davin@apache.org, pgsql-hackers@postgresql.org
Subject: Re: Emitting JSON to file using COPY TO
In-Reply-To: <61818b31-4e7a-4d99-b08a-9e545dbf0038@joeconway.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