Re: Emitting JSON to file using COPY TO
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Joe Conway <mail@joeconway.com>
Cc: Nathan Bossart <nathandbossart@gmail.com>,
Davin Shearer <davin@apache.org>,
PostgreSQL-development <pgsql-hackers@postgreSQL.org>
Date: 2023-12-02T15:11:20Z
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
Joe Conway <mail@joeconway.com> writes:
>> 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.
While I've not looked too closely, I suspect this might be due to the
FORMAT_LA hack in base_yylex:
/* Replace FORMAT by FORMAT_LA if it's followed by JSON */
switch (next_token)
{
case JSON:
cur_token = FORMAT_LA;
break;
}
So if you are writing a production that might need to match
FORMAT followed by JSON, you need to match FORMAT_LA too.
(I spent a little bit of time last week trying to get rid of
FORMAT_LA, thinking that it didn't look necessary. Did not
succeed yet.)
regards, tom lane