Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r9Rec-00HFwk-Ti for pgsql-hackers@arkaria.postgresql.org; Sat, 02 Dec 2023 15:11:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1r9ReY-00AquX-U6 for pgsql-hackers@arkaria.postgresql.org; Sat, 02 Dec 2023 15:11:34 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r9ReY-00AquN-KZ for pgsql-hackers@lists.postgresql.org; Sat, 02 Dec 2023 15:11:34 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r9ReV-008Rl0-TZ for pgsql-hackers@postgreSQL.org; Sat, 02 Dec 2023 15:11:33 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 3B2FBKWc398151; Sat, 2 Dec 2023 10:11:20 -0500 From: Tom Lane To: Joe Conway cc: Nathan Bossart , Davin Shearer , PostgreSQL-development Subject: Re: Emitting JSON to file using COPY TO In-reply-to: <411395e0-697e-44ab-be98-dd2047f9a10e@joeconway.com> References: <3853387.1701096982@sss.pgh.pa.us> <3a98decf-3fe3-4b49-9b68-fda01338872c@sedlakovi.org> <24e3ee88-ec1e-421b-89ae-8a47ee0d2df1@joeconway.com> <20231201230958.GA1786735@nathanxps13> <411395e0-697e-44ab-be98-dd2047f9a10e@joeconway.com> Comments: In-reply-to Joe Conway message dated "Sat, 02 Dec 2023 09:31:46 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <398149.1701529880.1@sss.pgh.pa.us> Date: Sat, 02 Dec 2023 10:11:20 -0500 Message-ID: <398150.1701529880@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Joe Conway 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