pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: jian he <jian.universality@gmail.com>
Cc: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: Joe Conway <mail@joeconway.com>
Cc: Daniel Verite <daniel@manitou-mail.org>
Cc: Andrew Dunstan <andrew@dunslane.net>
Cc: Davin Shearer <davin@apache.org>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Cc: Junwang Zhao <zhjwpku@gmail.com>
Subject: Re: Emitting JSON to file using COPY TO
Date: Fri, 2 Feb 2024 10:47:59 +0100
Message-ID: <202402020947.dsqig7nd4bpf@alvherre.pgsql> (raw)
In-Reply-To: <CACJufxHG9Cko8GTOQcx-8i7r1GugA=gJcwngvJzfLuGg9HRbjw@mail.gmail.com>

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/





view thread (163+ messages)  latest in thread

Message-ID: <202402020947.dsqig7nd4bpf@alvherre.pgsql>
Permalink:  ../202402020947.dsqig7nd4bpf@alvherre.pgsql/
Also on:    postgresql.org/message-id/202402020947.dsqig7nd4bpf@alvherre.pgsql

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-general@postgresql.org
  Cc: alvherre@alvh.no-ip.org, jian.universality@gmail.com, sawada.mshk@gmail.com, mail@joeconway.com, daniel@manitou-mail.org, andrew@dunslane.net, davin@apache.org, pgsql-hackers@postgresql.org, zhjwpku@gmail.com
  Subject: Re: Emitting JSON to file using COPY TO
  In-Reply-To: <202402020947.dsqig7nd4bpf@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox