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 1rVq9l-001dEK-GT for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Feb 2024 09:48:22 +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 1rVq9j-00C2ix-Mc for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Feb 2024 09:48:19 +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 1rVq9i-00C2hu-Oe for pgsql-hackers@lists.postgresql.org; Fri, 02 Feb 2024 09:48:19 +0000 Received: from fout7-smtp.messagingengine.com ([103.168.172.150]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rVq9b-004g2z-Fn for pgsql-hackers@postgresql.org; Fri, 02 Feb 2024 09:48:17 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfout.nyi.internal (Postfix) with ESMTP id E3AAB138008A; Fri, 2 Feb 2024 04:48:09 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Fri, 02 Feb 2024 04:48:09 -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=1706867289; x= 1706953689; bh=gW1oAZix216FDRcMtw6xsjCJ+tejnBteHEpXSidePa4=; b=w z3nykHOuSdH7g5eTgOzIMDP+Ux0oM+KYVdVYAVrswVDosOQYXch8mjkuUQrcgaCy 8OuUTPU+gGdg8+uwiuM5tLvU4L82mCGsHxj0y5sieX4Zy6c1uUll75s+cIJzJPyn HBTTsHW9DXPWDJLhqPMS3audVADwgwQKpjIPc/XRAbiY4XXLFVxmADE+56yD1NGM kY7Qo05qvDtcyklOkTk0sNr2M+P9g0381SY6Tsdr+Wje19/Yg/hKxrtQPoH/3WRv Oj92UJfQY6AkhDJnvwahwD7RID7Y2oCyASUfVSf+uK6FQgwL/VUAe+Wx2bPgvBG9 +fpiC95dMZlmho23a6V8g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrfedugedgtdejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkgggtugfgjgesthekredttddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepvdektdffudfftdffffehfffhjeejhffgieeuueekjeek fffgudffhfduffffueevnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhv hhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 2 Feb 2024 04:48:08 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1706867279; bh=SKb9zt+zjSJIosg5VGcfpyHIFtIgoLRNzD9sDoNLZoM=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=OEQlxTJaEcGzN/FSPYKmcBPo/J2WIT3Ve6/n/arUm7EJWIn08qFPPI9sgWr7fKJXF 1jxe3efCiC22HKlLwPEvRpZ/72qEeTuSrIpGDZuAubTMB7oTjO9ZD8QEyp/aUSVBNm Ss/1ZqlKj1n4bRO6aMnAvJ5mB6tAZBnWzNpViF09SIc4OGDAc54R6MduLbljaQ2MOA kSCkj3j4Lc9ObKPSOlQys7VZar8zkWbkR179DlsjFJH9gdGLzV/7mPnoNG1uTVbqwF ld5PE2jsoapt/XjYgFBGAdL/2nmj6HseriAjlToqJ708z+zhOUS/CVwmPe7KOFA2Bu iM2PY1FCreEgA== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id 4D27B8B; Fri, 2 Feb 2024 10:47:59 +0100 (CET) Date: Fri, 2 Feb 2024 10:47:59 +0100 From: Alvaro Herrera To: jian he Cc: Masahiko Sawada , Joe Conway , Daniel Verite , Andrew Dunstan , Davin Shearer , PostgreSQL-development , Junwang Zhao Subject: Re: Emitting JSON to file using COPY TO Message-ID: <202402020947.dsqig7nd4bpf@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-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/