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 1uWcNR-00GUbQ-8j for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Jul 2025 14:54:29 +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 1uWcNO-006Dff-C0 for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Jul 2025 14:54:27 +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 1uWcNO-006DfV-1y for pgsql-hackers@lists.postgresql.org; Tue, 01 Jul 2025 14:54:26 +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.96) (envelope-from ) id 1uWcNL-00576e-1h for pgsql-hackers@lists.postgresql.org; Tue, 01 Jul 2025 14:54:26 +0000 Received: from oss.nttdata.com (localhost [127.0.0.1]) by oss.nttdata.com (Postfix) with ESMTPA id 5AB49619B7; Tue, 1 Jul 2025 23:54:16 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at oss.nttdata.com MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 01 Jul 2025 23:54:15 +0900 From: torikoshia To: jian he Cc: Masahiko Sawada , vignesh C , Jim Jones , Kirill Reshke , Fujii Masao , "David G. Johnston" , Yugo NAGATA , PostgreSQL Hackers Subject: Re: Change COPY ... ON_ERROR ignore to ON_ERROR ignore_row In-Reply-To: References: <90dc6e9d-9348-485a-b27c-7b1637f06c2e@uni-muenster.de> 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 Hi, Thanks for updating the patch and I've read v17-0001-COPY-on_error-set_null.patch and here are some comments. > +COPY x from stdin (on_error set_null, reject_limit 2); > +ERROR: COPY REJECT_LIMIT requires ON_ERROR to be set to IGNORE I understand that REJECT_LIMIT is out of scope for this patch, but personally, I feel that supporting REJECT_LIMIT with ON_ERROR SET_NULL would be a natural extension. - Both IGNORE and SET_NULL share the common behavior of allowing COPY to continue despite soft errors. - Since REJECT_LIMIT defines the threshold for how many soft errors can be tolerated before COPY fails, it seems consistent to allow it with SET_NULL as well. + if (current_row_erroneous) + cstate->num_errors++; Is there any reason this error counting isn't placed inside the "if (cstate->opts.on_error == COPY_ON_ERROR_SET_NULL)" block? As far as I can tell, current_row_erroneous is only modified within that block, so it might make sense to keep this logic together for clarity. These may be very minor, but I noticed a few inconsistencies in casing and wording: + * If ON_ERROR is specified with IGNORE, skip rows with soft errors. + * If ON_ERROR is specified with set_null, try to replace with null. IGNORE is in uppercase, but set_null is lowercase. + * we use it to count number of rows (not fields!) that + * successfully applied on_error set_null. The sentence should begin with a capital: "We use it..." Also, I felt it's unclear what "we use it" means. Does it necessary? +COPY x to stdout (on_error set_null); +ERROR: COPY ON_ERROR cannot be used with COPY TO +LINE 1: COPY x to stdout (on_error set_null); COPY is uppercase, but to is lowercase. +COPY x from stdin (format BINARY, on_error set_null); +ERROR: only ON_ERROR STOP is allowed in BINARY mode +COPY x from stdin (on_error set_null, reject_limit 2); +ERROR: COPY REJECT_LIMIT requires ON_ERROR to be set to IGNORE ... +COPY t_on_error_null FROM STDIN WITH (on_error set_null); +ERROR: domain d_int_not_null does not allow null values +CONTEXT: COPY t_on_error_null, line 1, column a: null input It might be better to consider standardizing casing across all COPY statements (e.g., COPY ... TO, COPY ... FROM STDIN) for consistency. -- Regards, -- Atsushi Torikoshi Seconded from NTT DATA Japan Corporation to SRA OSS K.K.