Re: Emitting JSON to file using COPY TO

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: 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-01 23:09:58
Message-ID: 20231201230958.GA1786735@nathanxps13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general 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:

In response to


Browse pgsql-general by date

  From Date Subject
Next Message Davin Shearer 2023-12-02 03:00:29 Re: Emitting JSON to file using COPY TO
Previous Message Joe Conway 2023-12-01 19:28:55 Re: Emitting JSON to file using COPY TO

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2023-12-01 23:55:22 Re: Refactoring backend fork+exec code
Previous Message Sacha Hottinger 2023-12-01 23:06:59 AW: Building PosgresSQL with LLVM fails on Solaris 11.4