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 1rVAby-00FHT1-LK for pgsql-hackers@arkaria.postgresql.org; Wed, 31 Jan 2024 13:26:43 +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 1rVAbv-00E13K-8i for pgsql-hackers@arkaria.postgresql.org; Wed, 31 Jan 2024 13:26:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rVAbu-00E13C-3g for pgsql-hackers@lists.postgresql.org; Wed, 31 Jan 2024 13:26:38 +0000 Received: from fhigh5-smtp.messagingengine.com ([103.168.172.156]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rVAbq-004iYs-DL for pgsql-hackers@postgresql.org; Wed, 31 Jan 2024 13:26:37 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 225E8114008C; Wed, 31 Jan 2024 08:26:31 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 31 Jan 2024 08:26:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1706707591; x= 1706793991; bh=KzRpcmVVRvabrw7OGEWJ5zAjhc2EUlW8XvI/ArKkjkk=; b=N 3MXDjoTu0nlv/x5CtUN7+2KY/r1V069Dsd7dv+MxQf+yNUHWQ2N8XXX7VSPUX2CI cQY3dmQ6IuCEYbEJm4w1Q4IMzYX16BObDNtjEhOem7K7H8z670cwH3x+bvbBhBBb XxjlVHvsLmoTwussiFXPqQMQu6QVp8z+vwVTG5HuN3xX2dQzMQsxD2I/TTow2VK2 a6HIY5deZyYMWQN5azf11qLj680adD6qYCHw+UlrByRhiaJ/7Fci01BR9L2PF9gO M+b5iVhjcD/IP2KgsoKYJkehHQGV7dfmaeyhZs+QOMFsr7bO0aTtNpETXYNAcyZl gKwj+QO3wdfW/k2Fh42/g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrfedtledggeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkgggtugfgjgesthekredttddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepvdektdffudfftdffffehfffhjeejhffgieeuueekjeek fffgudffhfduffffueevnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhv hhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 31 Jan 2024 08:26:30 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1706707588; bh=MWoZbeZhqj2TU/vQ/DdHqJjviW2WKKWvooWuDL7YO7E=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=kKgtuj745dGkUA6YTXjwvuaiFaHAenzJIRY5Eq4Zl40uaKkuRnB4UCEXQMZzCyU5R eAW3Dr+4YYTVFn/h63RvZe+13Z47ONd9I0SGlIxH1aSBi2gsdGs4dkdvhe/S3Y19cT dqVcQcT8kARvwHEoIttATZiSrjGn5PQoe7XqQQfKaCTqi5PKUlal//wbQsP/PR2oPE RRi8XlzMQVKizhTlpQw4KYaB0lz5o31j0QMtpnT9Dgg0Y/VSPZfbvJe5YCeK3TxKiL uoflJ1kQZPvHXMKxkqJji37k7V1FSkqibXQlASoFos+CQnSWvDX/nBkwAzSDuqQouc bc8txXElvXEYw== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id 0FF208B; Wed, 31 Jan 2024 14:26:28 +0100 (CET) Date: Wed, 31 Jan 2024 14:26:28 +0100 From: Alvaro Herrera To: jian he Cc: Masahiko Sawada , Joe Conway , Daniel Verite , Andrew Dunstan , Davin Shearer , PostgreSQL-development Subject: Re: Emitting JSON to file using COPY TO Message-ID: <202401311326.zvfydnpkqnnd@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024-Jan-23, jian he wrote: > > + | FORMAT_LA copy_generic_opt_arg > > + { > > + $$ = makeDefElem("format", $2, @1); > > + } > > ; > > > > I think it's not necessary. "format" option is already handled in > > copy_generic_opt_elem. > > test it, I found out this part is necessary. > because a query with WITH like `copy (select 1) to stdout with > (format json, force_array false); ` will fail. Right, because "FORMAT JSON" is turned into FORMAT_LA JSON by parser.c (see base_yylex there). I'm not really sure but I think it might be better to make it "| FORMAT_LA JSON" instead of invoking the whole copy_generic_opt_arg syntax. Not because of performance, but just because it's much clearer what's going on. -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/