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 1tDURI-0014FZ-Az for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Nov 2024 20:03:08 +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 1tDURF-00GixV-BT for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Nov 2024 20:03:05 +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 1tDURE-00Givi-TL for pgsql-hackers@lists.postgresql.org; Tue, 19 Nov 2024 20:03:05 +0000 Received: from mail-lj1-x229.google.com ([2a00:1450:4864:20::229]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tDURC-002kZC-Ap for pgsql-hackers@lists.postgresql.org; Tue, 19 Nov 2024 20:03:03 +0000 Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2fb587d0436so34103901fa.2 for ; Tue, 19 Nov 2024 12:03:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732046581; x=1732651381; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=IuinP1+yzgR7yM8iOi8fX0nKe3cU29WUT5lyAY0/hvk=; b=FXrECmMNIbG3EsRVMF5L2t0IWso8p/DF9pUEo4Ge3hkCmVGl/hYMqM/KaaDBzHaOyE 8mFDRUKDeSyId8++G16aTxy+Pq6c716vJ1Lyq+ytqYi2cNR/LRKuFmpuyusDPYZv4zET epoDRU478P8vGfeqPZgSeJoeDUS7Q3R5eQoFpHvRDPlazGDvds71S/WMv7B1dy1sdjA1 CzBMte/FMtqDcCvkeQ8WNWtCX3sedyJl6oba5pvxoc1SEtNXsvIzzpQmac8V8k8PvntY DKyqxblRoSbh+m5R9h45nkapnGp3dUU6lVnmtE6v4Zcuy7b44aGnatICbwiBRfq2Ljxu J2ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732046581; x=1732651381; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IuinP1+yzgR7yM8iOi8fX0nKe3cU29WUT5lyAY0/hvk=; b=JYFmBJxIvvCXl3xkJAKSBWBNVhRmt6snhCetSnB0FhhiP+hmyZKACYvWaPzPzg/SQh 4XmSzLJdJAUKXqZmwk9ufQAX4e9OEKHrsA/jp+OUigdcIll3BGEwUGGmMmKcnJuLk9On EugEodzTsCuc03mpq1h0Qk1vc5JOnc9ByFL/1hJ5o/tngRL0rvE21fjaY2Vomh3KTfSc nC/tctKTY4YFaG8T8awvIJf0FLpPjNMIKXCiQFMVGFUEcEY9mE/xX8e2xKX6OidM5WlI OWeXL/cu5o6jEXeP0cyiKpaTzBHZNdoQN7cKXUrIw3RFUjY/NSKadwLY+JBOS/UB2Kdd mhVg== X-Forwarded-Encrypted: i=1; AJvYcCW+Ila1NG2JYJ1jPTypg2nCcx8HkI6jLDoEAmSgzz3qbRpjXlc9RF6WS+PRxnojUJmQxUo9LlZuSIFvnwm3@lists.postgresql.org X-Gm-Message-State: AOJu0YzZxW8UtyA4AZw5jfdMwurCPnA5IUREiWrhJGMuJMLeHzEATc2a 1Wbwa0LmvBfIDupKPKH8ccFaLfiJQuwLVUtBWPtck0qywGlSa1Nk0Fwc+iVS2vap3cMuPuWMo/I Wvq6g62+kvQ/W0EFKaN5l3uS1XDU= X-Google-Smtp-Source: AGHT+IERL5stIesytGjSeFrbG8vEeM0pK9Ln9m1BYlc+mCMkyB1MGEqI0CxNLE/cWkvvqiyRbIY6ag43dVonE54YbOw= X-Received: by 2002:a2e:a887:0:b0:2fb:7f9f:7f50 with SMTP id 38308e7fff4ca-2ff8dbcf34amr1761411fa.13.1732046580183; Tue, 19 Nov 2024 12:03:00 -0800 (PST) MIME-Version: 1.0 References: <04bf425ad1b15a4daefe96c478a5253b@oss.nttdata.com> <20240206191937.72eaf0ccc20cfea37944b422@sraoss.co.jp> <76da9fcc-93c5-4053-872e-12932a95356d@uni-muenster.de> <6eac5b45-7f45-4c7a-aae1-e90db8be2e08@uni-muenster.de> <3d6b5885-16a1-475d-b56f-41701c48d9d4@uni-muenster.de> <63595e8f-a245-4335-aa22-7e449a70e210@oss.nttdata.com> <07587c36-18b3-4ccb-b5fb-579bcb04ed37@oss.nttdata.com> In-Reply-To: From: Kirill Reshke Date: Wed, 20 Nov 2024 01:02:49 +0500 Message-ID: Subject: Re: Change COPY ... ON_ERROR ignore to ON_ERROR ignore_row To: jian he Cc: Fujii Masao , Jim Jones , "David G. Johnston" , Yugo NAGATA , torikoshia , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 19 Nov 2024, 13:52 jian he, wrote: > > On Sat, Nov 16, 2024 at 5:55=E2=80=AFPM Kirill Reshke wrote: > > > > I am attaching my v8 for reference. > > > > in your v8. > > > REJECT_LIMIT > > > Specifies the maximum number of errors tolerated while converting a > column's input value to its data type, when ON_ERROR is > set to ignore. > If the input contains more erroneous rows than the specified > value, the COPY > command fails, even with ON_ERROR set to > ignore. > > > > > then above description not meet with following example, (i think) > > create table t(a int not null); > COPY t FROM STDIN WITH (on_error set_to_null, reject_limit 2); > 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. > >> a > >> \. > ERROR: null value in column "a" of relation "t" violates not-null constr= aint > DETAIL: Failing row contains (null). > CONTEXT: COPY t, line 1, column a: "a" Sure, my v8 does not helps with column level NOT NULL constraint (or other constraint) > Overall, I think > making the domain not-null align with column level not-null would be a > good thing. While this looks sane, it's actually a separate topic. Even on current HEAD we have domain not-null vs column level not-null unalignment. consider this example ``` reshke=3D# create table ftt2 (i int not null); CREATE TABLE reshke=3D# copy ftt2 from stdin with (reject_limit 1000, on_error ignore); 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. >> \N >> \. ERROR: null value in column "i" of relation "ftt2" violates not-null const= raint DETAIL: Failing row contains (null). CONTEXT: COPY ftt2, line 1: "\N" reshke=3D# create domain dd as int not null ; CREATE DOMAIN reshke=3D# create table ftt3(i dd); CREATE TABLE reshke=3D# copy ftt3 from stdin with (reject_limit 1000, on_error ignore); 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. >> \N >> \. NOTICE: 1 row was skipped due to data type incompatibility COPY 0 reshke=3D# ``` So, if we want this, we need to start another thread and deal with REJECT_LIMIT + on_error ignore first. The ExecConstraints function is the source of the error in scenario 1. Therefore, we require something like "ExecConstraintsSafe" to accommodate the aforementioned. That is a significant change. Not sure it will be accepted by the community. > > > Specifies how to behave when encountering an error converting a col= umn's > input value into its data type. > An error_action valu= e of > stop means fail the command, > ignore means discard the input row and > continue with the next one, and > set_to_null means replace columns containing > erroneous input values with null and move to the > next row. > > "and move to the next row" is wrong? > I think it should be " and move to the next field". Yes, "and move to the next field" is correct.