Re: Emitting JSON to file using COPY TO - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Emitting JSON to file using COPY TO
Date
Msg-id 398150.1701529880@sss.pgh.pa.us
Whole thread Raw
In response to Re: Emitting JSON to file using COPY TO  (Joe Conway <mail@joeconway.com>)
Responses Re: Emitting JSON to file using COPY TO
Re: Emitting JSON to file using COPY TO
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: Joe Conway
Date:
Subject: Re: Emitting JSON to file using COPY TO
Next
From: Alvaro Herrera
Date:
Subject: Re: about help message for new pg_dump's --filter option