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 1rq2Np-00AD3E-0H for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Mar 2024 02:54:21 +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 1rq2Nn-0099V3-MG for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Mar 2024 02:54: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 1rq2Nn-0099Uv-8d for pgsql-hackers@lists.postgresql.org; Fri, 29 Mar 2024 02:54:19 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rq2Ni-006yyc-H3 for pgsql-hackers@postgresql.org; Fri, 29 Mar 2024 02:54:18 +0000 Received: from oss.nttdata.com (localhost [127.0.0.1]) by oss.nttdata.com (Postfix) with ESMTPA id BB6D560342; Fri, 29 Mar 2024 11:54:10 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at oss.nttdata.com MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=_23be9bef3a2929052e78723c6449f432" Content-Transfer-Encoding: 8bit Date: Fri, 29 Mar 2024 11:54:10 +0900 From: torikoshia To: Masahiko Sawada Cc: Alexander Korotkov , jian he , Tom Lane , Kyotaro Horiguchi , vignesh21@gmail.com, lena.ribackina@yandex.ru, dam.bel07@gmail.com, zhihuifan1213@163.com, daniel@yesql.se, pgsql-hackers@postgresql.org, andres@anarazel.de, anisimow.d@gmail.com, HukuToc@gmail.com, pgsql-hackers@lists.postgresql.org, a.lepikhov@postgrespro.ru Subject: Re: POC PATCH: copy from ... exceptions to: (was Re: VLDB Features) In-Reply-To: References: <762d7dd4d5aa9e5ecffec2ae6a255a28@oss.nttdata.com> <20240117.164859.2242646601795501168.horikyota.ntt@gmail.com> <2070915.1705527477@sss.pgh.pa.us> <350926525700756634e7c7b003fb1694@oss.nttdata.com> User-Agent: Roundcube Webmail/1.4.11 Message-ID: X-Sender: torikoshia@oss.nttdata.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=_23be9bef3a2929052e78723c6449f432 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8; format=flowed On 2024-03-28 21:54, Masahiko Sawada wrote: > On Thu, Mar 28, 2024 at 9:38 PM torikoshia > wrote: >> >> On 2024-03-28 10:20, Masahiko Sawada wrote: >> > Hi, >> > >> > On Thu, Jan 18, 2024 at 5:33 PM Masahiko Sawada >> > wrote: >> >> >> >> On Thu, Jan 18, 2024 at 4:59 PM Alexander Korotkov >> >> wrote: >> >> > >> >> > On Thu, Jan 18, 2024 at 4:16 AM torikoshia wrote: >> >> > > On 2024-01-18 10:10, jian he wrote: >> >> > > > On Thu, Jan 18, 2024 at 8:57 AM Masahiko Sawada >> >> > > > wrote: >> >> > > >> On Thu, Jan 18, 2024 at 6:38 AM Tom Lane wrote: >> >> > > >> > Kyotaro-san's suggestion isn't bad, though I might shorten it to >> >> > > >> > error_action {error|ignore|log} (or perhaps "stop" instead of "error")? >> >> > > >> > You will need a separate parameter anyway to specify the destination >> >> > > >> > of "log", unless "none" became an illegal table name when I wasn't >> >> > > >> > looking. I don't buy that one parameter that has some special values >> >> > > >> > while other values could be names will be a good design. Moreover, >> >> > > >> > what if we want to support (say) log-to-file along with log-to-table? >> >> > > >> > Trying to distinguish a file name from a table name without any other >> >> > > >> > context seems impossible. >> >> > > >> >> >> > > >> I've been thinking we can add more values to this option to log errors >> >> > > >> not only to the server logs but also to the error table (not sure >> >> > > >> details but I imagined an error table is created for each table on >> >> > > >> error), without an additional option for the destination name. The >> >> > > >> values would be like error_action {error|ignore|save-logs|save-table}. >> >> > > >> >> >> > > > >> >> > > > another idea: >> >> > > > on_error {error|ignore|other_future_option} >> >> > > > if not specified then by default ERROR. >> >> > > > You can also specify ERROR or IGNORE for now. >> >> > > > >> >> > > > I agree, the parameter "error_action" is better than "location". >> >> > > >> >> > > I'm not sure whether error_action or on_error is better, but either way >> >> > > "error_action error" and "on_error error" seems a bit odd to me. >> >> > > I feel "stop" is better for both cases as Tom suggested. >> >> > >> >> > OK. What about this? >> >> > on_error {stop|ignore|other_future_option} >> >> > where other_future_option might be compound like "file 'copy.log'" or >> >> > "table 'copy_log'". >> >> >> >> +1 >> >> >> > >> > I realized that ON_ERROR syntax synoposis in the documentation is not >> > correct. The option doesn't require the value to be quoted and the >> > value can be omitted. The attached patch fixes it. >> > >> > Regards, >> >> Thanks! >> >> Attached patch fixes the doc, but I'm wondering perhaps it might be >> better to modify the codes to prohibit abbreviation of the value. >> >> When seeing the query which abbreviates ON_ERROR value, I feel it's >> not >> obvious what happens compared to other options which tolerates >> abbreviation of the value such as FREEZE or HEADER. >> >> COPY t1 FROM stdin WITH (ON_ERROR); >> >> What do you think? > > Indeed. Looking at options of other commands such as VACUUM and > EXPLAIN, I can see that we can omit a boolean value, but non-boolean > parameters require its value. The HEADER option is not a pure boolean > parameter but we can omit the value. It seems to be for backward > compatibility; it used to be a boolean parameter. I agree that the > above example would confuse users. > > Regards, Thanks for your comment! Attached a patch which modifies the code to prohibit omission of its value. I was a little unsure about adding a regression test for this, but I have not added it since other COPY option doesn't test the omission of its value. -- Regards, -- Atsushi Torikoshi NTT DATA Group Corporation --=_23be9bef3a2929052e78723c6449f432 Content-Transfer-Encoding: base64 Content-Type: text/x-diff; name=v1-0001-Disallow-ON_ERROR-option-without-value.patch Content-Disposition: attachment; filename=v1-0001-Disallow-ON_ERROR-option-without-value.patch; size=1646 RnJvbSAxYjRiZWMzYz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