Re: Emitting JSON to file using COPY TO
Alvaro Herrera <alvherre@alvh.no-ip.org>
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: jian he <jian.universality@gmail.com>
Cc: Masahiko Sawada <sawada.mshk@gmail.com>, Joe Conway <mail@joeconway.com>, Daniel Verite <daniel@manitou-mail.org>, Andrew Dunstan <andrew@dunslane.net>, Davin Shearer <davin@apache.org>, PostgreSQL-development <pgsql-hackers@postgresql.org>,
Junwang Zhao <zhjwpku@gmail.com>
Date: 2024-02-02T09:47:59Z
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 2024-Feb-02, jian he wrote: > copy (select 1) to stdout with (format json); > ERROR: syntax error at or near "format" > LINE 1: copy (select 1) to stdout with (format json); > ^ > > json is a keyword. Is it possible to escape it? > make `copy (select 1) to stdout with (format json)` error message the same as > `copy (select 1) to stdout with (format json1)` Sure, you can use copy (select 1) to stdout with (format "json"); and then you get ERROR: COPY format "json" not recognized is that what you meant? If you want the server to send this message when the JSON word is not in quotes, I'm afraid that's not possible, due to the funny nature of the FORMAT keyword when the JSON keyword appears after it. But why do you care? If you use the patch, then you no longer need to have the "not recognized" error messages anymore, because the JSON format is indeed a recognized one. Maybe I didn't understand your question. -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/