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 1trwu8-00CZGH-F9 for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Mar 2025 10:32:09 +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 1trwu7-00DJLy-98 for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Mar 2025 10:32:07 +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 1trwtF-00DGJV-8N for pgsql-hackers@lists.postgresql.org; Tue, 11 Mar 2025 10:31:13 +0000 Received: from udcm-wwu1.uni-muenster.de ([128.176.118.7]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1trwtB-002DR7-2A for pgsql-hackers@lists.postgresql.org; Tue, 11 Mar 2025 10:31:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=uni-muenster.de; i=@uni-muenster.de; q=dns/txt; s=uniout; t=1741689071; x=1773225071; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=gCFGHfKjDgS4fq+Pq8TKn7O57DyfWTvv7GS+t5ppQI8=; b=eWvd8AW5qebpoYwVBMYHtjfkCiCkn+6d4r71knebBwWtTKhnanV5gTes TIg2pBFZG1cOkfPGeuilfJ0sN32ecZEo920+LqlykanCLsyKI72uG4Zjk MzVXTk9wwlWVFAXhr/xSPcueamYx3KOPhPXRJHT3aLHIPTwjWiyLkcWYK dhMYvSOcfK/EAwvY3EbujUIbOG2Klz09YLyPRbTPXD70ZxMup6CqrlO5a uiPR4E1Et2RDiw1o2eftCEDaSvHyOCwuIlltGJ+cLb5+TKoJ1DW0rS8iG Ty500g4mMY2N6rDsfcColnbz0emyOmwo0gALTprF8NG7Y1lrnVdyrYctK g==; X-CSE-ConnectionGUID: 5A5Ir54cTVGE78/Dh6+B5Q== X-CSE-MsgGUID: sIyKdn92SmKLU4KWjjn3Jw== X-IronPort-AV: E=Sophos;i="6.14,238,1736809200"; d="scan'208";a="358840835" Received: from secmail.uni-muenster.de ([128.176.118.4]) by UDCM-RELAY1.UNI-MUENSTER.DE with ESMTP; 11 Mar 2025 11:31:10 +0100 Received: from [192.168.178.27] (dynamic-080-171-170-101.80.171.pool.telefonica.de [80.171.170.101]) by SECMAIL.UNI-MUENSTER.DE (Postfix) with ESMTPSA id 2B64420ADF03; Tue, 11 Mar 2025 11:31:08 +0100 (CET) Message-ID: <90dc6e9d-9348-485a-b27c-7b1637f06c2e@uni-muenster.de> Date: Tue, 11 Mar 2025 11:31:06 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Change COPY ... ON_ERROR ignore to ON_ERROR ignore_row To: jian he , Kirill Reshke Cc: Fujii Masao , "David G. Johnston" , Yugo NAGATA , torikoshia , PostgreSQL Hackers References: <07587c36-18b3-4ccb-b5fb-579bcb04ed37@oss.nttdata.com> Content-Language: en-US, de-DE From: Jim Jones In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Jian On 07.03.25 04:48, jian he wrote: > hi. > rebase only. I revisited this patch today. It applies and builds cleanly, and it works as expected. Some tests and minor comments: ==== 1) WARNING might be a better fit than NOTICE here. postgres=# \pset null NULL Null display is "NULL". postgres=# CREATE TEMPORARY TABLE t (x int, y int, z text); CREATE TABLE postgres=# COPY t (x,y) FROM STDIN WITH (on_error set_to_null, format csv); Enter data to be copied followed by a newline. End with a backslash and a period on a line by itself, or an EOF signal. >> 1,a >> 2,1 >> 3,2 >> 4,b >> a,c >> \. NOTICE:  erroneous values in 3 rows were replaced with null COPY 5 postgres=# SELECT * FROM t;   x   |  y   |  z    ------+------+------     1 | NULL | NULL     2 |    1 | NULL     3 |    2 | NULL     4 | NULL | NULL  NULL | NULL | NULL (5 rows) postgres=# \pset null NULL Null display is "NULL". postgres=# CREATE TEMPORARY TABLE t (x int, y int, z text); CREATE TABLE postgres=# COPY t (x,y) FROM STDIN WITH (on_error set_to_null, format csv, log_verbosity verbose); Enter data to be copied followed by a newline. End with a backslash and a period on a line by itself, or an EOF signal. >> 1,a >> 2,1 >> 3,2 >> 4,b >> a,c >> \. NOTICE:  column "y" was set to null due to data type incompatibility at line 1 NOTICE:  column "y" was set to null due to data type incompatibility at line 4 NOTICE:  column "x" was set to null due to data type incompatibility at line 5 NOTICE:  column "y" was set to null due to data type incompatibility at line 5 NOTICE:  erroneous values in 3 rows were replaced with null COPY 5 postgres=# SELECT * FROM t;   x   |  y   |  z    ------+------+------     1 | NULL | NULL     2 |    1 | NULL     3 |    2 | NULL     4 | NULL | NULL  NULL | NULL | NULL (5 rows) I would still leave the extra messages from "log_verbosity verbose" as NOTICE though. What do you think? ==== 2) Inconsistent terminology. Invalid values in "on_error set_to_null" mode are names as "erroneous", but as "invalid" in "on_error stop" mode. I don't want to get into the semantics of erroneous or invalid, but sticking to one terminology would IMHO look better. postgres=# \pset null NULL Null display is "NULL". postgres=# CREATE TEMPORARY TABLE t (x int, y int, z text); CREATE TABLE postgres=# COPY t (x,y) FROM STDIN WITH (on_error stop, format csv, log_verbosity verbose); Enter data to be copied followed by a newline. End with a backslash and a period on a line by itself, or an EOF signal. >> 1,a >> 2,1 >> 3,2 >> 4,b >> a,c >> \. ERROR:  invalid input syntax for type integer: "a" CONTEXT:  COPY t, line 1, column y: "a" postgres=# SELECT * FROM t;  x | y | z ---+---+--- (0 rows) ==== 3) same as in 1) postgres=# \pset null NULL Null display is "NULL". postgres=# CREATE TEMPORARY TABLE t (x int, y int, z text); CREATE TABLE postgres=# COPY t (x,y) FROM STDIN WITH (on_error ignore, format csv, log_verbosity verbose); Enter data to be copied followed by a newline. End with a backslash and a period on a line by itself, or an EOF signal. >> 1,a >> 2,1 >> 3,2 >> 4,b >> a,c >> \. NOTICE:  skipping row due to data type incompatibility at line 1 for column "y": "a" NOTICE:  skipping row due to data type incompatibility at line 4 for column "y": "b" NOTICE:  skipping row due to data type incompatibility at line 5 for column "x": "a" NOTICE:  3 rows were skipped due to data type incompatibility COPY 2 postgres=# SELECT * FROM t;  x | y |  z    ---+---+------  2 | 1 | NULL  3 | 2 | NULL (2 rows)==== ==== "on_error ignore" works well with "reject_limit #" postgres=# \pset null NULL Null display is "NULL". postgres=# CREATE TEMPORARY TABLE t (x int, y int, z text); CREATE TABLE postgres=# COPY t (x,y) FROM STDIN WITH (on_error ignore, format csv, log_verbosity verbose, reject_limit 1); Enter data to be copied followed by a newline. End with a backslash and a period on a line by itself, or an EOF signal. >> 1,a >> 2,1 >> 3,2 >> 4,b >> a,c >> \. NOTICE:  skipping row due to data type incompatibility at line 1 for column "y": "a" NOTICE:  skipping row due to data type incompatibility at line 4 for column "y": "b" ERROR:  skipped more than REJECT_LIMIT (1) rows due to data type incompatibility CONTEXT:  COPY t, line 4, column y: "b" postgres=# SELECT * FROM t;  x | y | z ---+---+--- (0 rows) best regards, Jim