From: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
---|---|
To: | jian he <jian(dot)universality(at)gmail(dot)com> |
Cc: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Joe Conway <mail(at)joeconway(dot)com>, Daniel Verite <daniel(at)manitou-mail(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Davin Shearer <davin(at)apache(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Junwang Zhao <zhjwpku(at)gmail(dot)com> |
Subject: | Re: Emitting JSON to file using COPY TO |
Date: | 2024-02-02 09:47:59 |
Message-ID: | 202402020947.dsqig7nd4bpf@alvherre.pgsql |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
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/
From | Date | Subject | |
---|---|---|---|
Next Message | jian he | 2024-02-02 10:05:53 | Re: Emitting JSON to file using COPY TO |
Previous Message | Evan Czaplicki | 2024-02-02 08:57:55 | Re: using palloc/pfree for OpenSSL allocations with CRYPTO_set_mem_functions |
From | Date | Subject | |
---|---|---|---|
Next Message | jian he | 2024-02-02 10:05:53 | Re: Emitting JSON to file using COPY TO |
Previous Message | Hayato Kuroda (Fujitsu) | 2024-02-02 09:41:35 | RE: speed up a logical replica setup |