Re: Emitting JSON to file using COPY TO

From: Joe Conway <mail(at)joeconway(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Daniel Verite <daniel(at)manitou-mail(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Davin Shearer <davin(at)apache(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Emitting JSON to file using COPY TO
Date: 2023-12-07 01:14:09
Message-ID: 6d8baa96-1c7c-4fa9-a49a-57f7393fcf08@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On 12/6/23 20:09, David G. Johnston wrote:
> On Wed, Dec 6, 2023 at 5:57 PM Joe Conway <mail(at)joeconway(dot)com
> <mailto:mail(at)joeconway(dot)com>> wrote:
>
> On 12/6/23 19:39, David G. Johnston wrote:
> > On Wed, Dec 6, 2023 at 4:45 PM Joe Conway <mail(at)joeconway(dot)com
> <mailto:mail(at)joeconway(dot)com>
> > <mailto:mail(at)joeconway(dot)com <mailto:mail(at)joeconway(dot)com>>> wrote:
>
> > But I still cannot shake the belief that using a format code of 1 -
> > which really could be interpreted as meaning "textual csv" in
> practice -
> > for this JSON output is unwise and we should introduce a new integer
> > value for the new fundamental output format.
>
> No, I am pretty sure you still have that wrong. The "1" means binary
> mode
>
>
> Ok.  I made the same typo twice, I did mean to write 0 instead of 1.

Fair enough.

> But the point that we should introduce a 2 still stands.  The new code
> would mean: use text output functions but that there is no inherent
> tabular structure in the underlying contents.  Instead the copy format
> was JSON and the output layout is dependent upon the json options in the
> copy command and that there really shouldn't be any attempt to turn the
> contents directly into a tabular data structure like you presently do
> with the CSV data under format 0.  Ignore the column count and column
> formats as they are fixed or non-existent.

I think that amounts to a protocol change, which we tend to avoid at all
costs.

--
Joe Conway
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2023-12-07 01:21:28 Re: Emitting JSON to file using COPY TO
Previous Message Joe Conway 2023-12-07 01:10:21 Re: Emitting JSON to file using COPY TO

Browse pgsql-hackers by date

  From Date Subject
Next Message David G. Johnston 2023-12-07 01:21:28 Re: Emitting JSON to file using COPY TO
Previous Message Joe Conway 2023-12-07 01:10:21 Re: Emitting JSON to file using COPY TO