Re: Emitting JSON to file using COPY TO
David G. Johnston <david.g.johnston@gmail.com>
From: "David G. Johnston" <david.g.johnston@gmail.com>
To: Joe Conway <mail@joeconway.com>
Cc: Daniel Verite <daniel@manitou-mail.org>,
Andrew Dunstan <andrew@dunslane.net>, Davin Shearer <davin@apache.org>,
PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2023-12-07T01:09:22Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Add option force_array for COPY JSON FORMAT
- 4c0390ac53b7 19 (unreleased) landed
-
json format for COPY TO
- 7dadd38cda95 19 (unreleased) landed
-
introduce CopyFormat, refactor CopyFormatOptions
- a2145605ee3d 19 (unreleased) landed
-
Doc: add IDs to copy.sgml's <varlistentry> and <refsect1>
- e4018f891dec 19 (unreleased) cited
On Wed, Dec 6, 2023 at 5:57 PM Joe Conway <mail@joeconway.com> wrote: > On 12/6/23 19:39, David G. Johnston wrote: > > On Wed, Dec 6, 2023 at 4:45 PM Joe Conway <mail@joeconway.com > > <mailto:mail@joeconway.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. 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. David J.