Re: Emitting JSON to file using COPY TO - Mailing list pgsql-hackers

From Nathan Bossart
Subject Re: Emitting JSON to file using COPY TO
Date
Msg-id 20231201230958.GA1786735@nathanxps13
Whole thread Raw
In response to Re: Emitting JSON to file using COPY TO  (Joe Conway <mail@joeconway.com>)
Responses Re: Emitting JSON to file using COPY TO
Re: Emitting JSON to file using COPY TO
List pgsql-hackers
On Fri, Dec 01, 2023 at 02:28:55PM -0500, Joe Conway wrote:
> I did a quick PoC patch (attached) -- if there interest and no hard
> objections I would like to get it up to speed for the January commitfest.

Cool.  I would expect there to be interest, given all the other JSON
support that has been added thus far.

I noticed that, with the PoC patch, "json" is the only format that must be
quoted.  Without quotes, I see a syntax error.  I'm assuming there's a
conflict with another json-related rule somewhere in gram.y, but I haven't
tracked down exactly which one is causing it.

> 1. Is supporting JSON array format sufficient, or does it need to support
> some other options? How flexible does the support scheme need to be?

I don't presently have a strong opinion on this one.  My instinct would be
start with something simple, though.  I don't think we offer any special
options for log_destination...

> 2. This only supports COPY TO and we would undoubtedly want to support COPY
> FROM for JSON as well, but is that required from the start?

I would vote for including COPY FROM support from the start.

> !     if (!cstate->opts.json_mode)

I think it's unfortunate that this further complicates the branching in
CopyOneRowTo(), but after some quick glances at the code, I'm not sure it's
worth refactoring a bunch of stuff to make this nicer.

-- 
Nathan Bossart
Amazon Web Services: https://aws.amazon.com



pgsql-hackers by date:

Previous
From: Sacha Hottinger
Date:
Subject: AW: Building PosgresSQL with LLVM fails on Solaris 11.4
Next
From: Tom Lane
Date:
Subject: Re: Refactoring backend fork+exec code