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 1swN3H-003QAj-01 for pgsql-hackers@arkaria.postgresql.org; Thu, 03 Oct 2024 14:43:35 +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 1swN3E-00GQI0-UR for pgsql-hackers@arkaria.postgresql.org; Thu, 03 Oct 2024 14:43:32 +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 1swN3E-00GQFq-KQ for pgsql-hackers@lists.postgresql.org; Thu, 03 Oct 2024 14:43:32 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1swN39-002MYz-PB for pgsql-hackers@lists.postgresql.org; Thu, 03 Oct 2024 14:43:31 +0000 Received: from [192.168.11.3] (p3610184-ipxg13101funabasi.chiba.ocn.ne.jp [60.45.23.184]) by oss.nttdata.com (Postfix) with ESMTPSA id 03A0D6182A; Thu, 3 Oct 2024 23:43:25 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at oss.nttdata.com Message-ID: <8830518a-28ac-43a2-8a11-1676d9a3cdf8@oss.nttdata.com> Date: Thu, 3 Oct 2024 23:43:25 +0900 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Add new COPY option REJECT_LIMIT Content-Language: en-US To: torikoshia , jian he Cc: zhjwpku@gmail.com, pgsql-hackers@lists.postgresql.org References: <63f99327aa6b404cc951217fa3e61fe4@oss.nttdata.com> <6e3dcdc6-8e18-4716-a23b-3bee316aeaa7@oss.nttdata.com> <979c6d306343f3d665d14eab2cd1b7bc@oss.nttdata.com> <920a29a36032befbeb355cbdfbbe0f63@oss.nttdata.com> <54bea7dd-94b1-41f1-a4e9-c5c53cc82ce7@oss.nttdata.com> <644a094c-2c0c-4b5f-b151-3677c7de4ee7@oss.nttdata.com> <5f807fcf3a36df7ba41464ab40b5c37d@oss.nttdata.com> <056a5728cf733685cff7d9b5a8fbb0ad@oss.nttdata.com> From: Fujii Masao In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024/09/30 21:08, torikoshia wrote: > Since defGetInt64() checks not only whether the input value exceeds the range of bigint but also input value is specified, attached v6 patch checks them by directly calling defGetInt64(). Thanks for updating the patch! But the patch no longer applied cleanly to the master branch. Could you rebase it? + if (opts_out->reject_limit && !opts_out->on_error) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + /*- translator: first and second %s are the names of COPY + * option, e.g. ON_ERROR, third is the value of the COPY option, + * e.g. IGNORE */ + errmsg("COPY %s requires %s to be set to %s", + "REJECT_LIMIT", "ON_ERROR", "IGNORE"))); This check might be better moved to other place, for example at the bottom of ProcessCopyOptions(). I noticed a comment in the code: "Check for incompatible options (must do these two before inserting defaults)." You added your condition after this comment and before inserting the defaults, but it's not related to that process. So, moving this check to other place seems more appropriate. While reviewing, I also noticed that the check for "opts_out->binary && opts_out->on_error != COPY_ON_ERROR_STOP" is similarly placed before setting the defaults, which might not be correct. This check should probably be moved as well. Additionally, the comment mentioning "must do these two" should be updated to "must do these three." These changes should be handled in a separate patch. + if (cstate->opts.reject_limit && Wouldn't it be clearer to use cstate->opts.reject_limit > 0 for better readability? + cstate->num_errors > cstate->opts.reject_limit) + ereport(ERROR, + (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), + errmsg("skipped more than REJECT_LIMIT rows: \"%lld\",", + (long long) cstate->opts.reject_limit))); To make the error message clearer, similar to the NOTICE about skipped rows, how about rewording it to: "skipped more than REJECT_LIMIT (%lld) rows due to data type incompatibility"? Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION