Re: Emitting JSON to file using COPY TO

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: Nathan Bossart <nathandbossart(at)gmail(dot)com>, 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-02 15:11:20
Message-ID: 398150.1701529880@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Joe Conway <mail(at)joeconway(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Maciek Sakrejda 2023-12-02 18:50:12 Re: Emitting JSON to file using COPY TO
Previous Message Joe Conway 2023-12-02 14:31:46 Re: Emitting JSON to file using COPY TO

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2023-12-02 16:02:47 Re: about help message for new pg_dump's --filter option
Previous Message Joe Conway 2023-12-02 14:31:46 Re: Emitting JSON to file using COPY TO