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.96) (envelope-from ) id 1vivwZ-001v2u-0C for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Jan 2026 14:45:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vivwX-00DJPW-2U for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Jan 2026 14:45:54 +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.96) (envelope-from ) id 1vivwX-00DJPO-1H for pgsql-hackers@lists.postgresql.org; Thu, 22 Jan 2026 14:45:53 +0000 Received: from mail-ua1-x92f.google.com ([2607:f8b0:4864:20::92f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vivwV-001uwv-1H for pgsql-hackers@lists.postgresql.org; Thu, 22 Jan 2026 14:45:53 +0000 Received: by mail-ua1-x92f.google.com with SMTP id a1e0cc1a2514c-94240659ceaso264680241.3 for ; Thu, 22 Jan 2026 06:45:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1769093148; cv=none; d=google.com; s=arc-20240605; b=auGtH4Cu7Cbutno6jKGtWxdvurFrLT/I5ssWc/3b4txZTlFJyPvOMta9lWZ/UXIGgt G+iPvZNCM7BPB2017N91F+7fUZeI3o3nfTqS469HlT7BZjwPl5ZWsFHKlrtRTukw6vnG zcCCgohFmavaMZ2Oowaqf1PrXQc8JkxDiwmQSlLsrKEKzEwBsPvFVOzrkhaLLF7Tf9ts 70mwpHQ3SIS+0WdFkZGq7QIySpCWpnJK44/2y3Lib8UTF4+3fxcp2x/9yJlPViPT+mTP H+wXrtYzKZa7+VizYBFNAU+VI9mEGN2ZS6RVx4gY7VvKBAhzmwL+A1IqIEY64oEpFLD/ 8JCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=zn6+5NDFkRTmu8XkELbKVojWAf0fyztROI6CRsiJg0s=; fh=He0Iu44MiRW/VtoobwwIfl+rNHcPWd2XNvSlg+8mB/g=; b=GQzESx98MHPa+9KxJVEyg6X4EfJGWFWQMk/VhSJ74hDh0dnsESFNL4jcAMe+QGJdDS +27yPqrRjm4rXFw4uTNCMUAp6GvfSxZH+of5Sxacpv/JBoW/NVyNXU2If18+4oLunsZS mcH5aQZP/0B8Wwy4IFUd4Rv3nlZA7yf1dibS9saJmZh1jOl0KLIezyYmJmDVxfvXPhCp EVqG7sAKDq6pIzq2Pqo4GY3cSHfj1WsNjbfATCidjcTS8RjJPG4C366aN6ic3ZIKRtC4 djYlw6e0IMF4SCCrkMk1NtIoflbGFkPpvvIXknhJmxeBlPemfzzyjQcYdiEHwH+H+Em/ Q0Tg==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769093148; x=1769697948; 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=zn6+5NDFkRTmu8XkELbKVojWAf0fyztROI6CRsiJg0s=; b=clbg41BtiYV5AmT6ada0BZ8xSgus8LHqbf4uSy6ZcHmU208gzzLPcQfcjlAMwwRVxi 8HEMASUdRWra3KP8kLVnkWC85k1y3Xh5/R+1NR+zmmdCBuBZKrLdAaUXx1EsACo0nIQI okRcWOCPTfWAg+9KN+D37PrPCA4Wo7XnNZBZiRnZ+Id7nHyUupcbYU2/JkbTeTTiEse1 R72nPv58O4Bt0HvPB+Rzxw7v+swi1MA4U2oWA1HtiEyAgKhIgENdLr2HRtLuQ7Wxd/2b fXzXG3ZEznMkJ8bAzlDyowehWqbhkk3xzZBrev9jjhzc0Bv4vO0/O07cxSIt7gif4f+k eZSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769093148; x=1769697948; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=zn6+5NDFkRTmu8XkELbKVojWAf0fyztROI6CRsiJg0s=; b=Qh21Bja87jFGj0eMxNeurrgKbtGF7CXt2BKGVrrPbwX+bFjVc1U0FWnZ8NsE0+xndG FgdODIzmwNK65p/XQW3Duq5emizHI7JWQxpn7EXBs6KIUwoSaXPYbfTHNLLCMVJeItzh CV2zjEFEp73CFgHslOnB2yxOHrbUugKMjUAXS95nE8gDg/2yO0FVxZ8WiMrsWngRzieP p+E6w2DNAYH9NqhrJrWj9sOi69ujSFIw6fESUp7mvvtOS55/KyDSyiB/ZPPXxT0cwxw4 qgz5mt/UT00jDFPiqGbdDPuk++SVodazuByif1E0OA98x2L8XBEppwo96HbwOhe0zFCa YO7w== X-Forwarded-Encrypted: i=1; AJvYcCUeixQF6zlpAvKcEJzFJo8PfvnFcXBHjYx7DYg5ZHlob0s82BZGfGVWkF8Dfuv3cepgOwkM8lQpbTm77Z0n@lists.postgresql.org X-Gm-Message-State: AOJu0YzB3i2ylamCdFbC3VoKDlfJpaR7Q4g9vMLWIWOue7ckgD6Drx1+ 2WKS2ChD2tvgZnY5JLi4sIKJF64goQ6h8rx4UE6nCdwcxRNeguRfCoG8xNUMjrxzU/Fhnu0nZZJ GAdkm78hrfJKgasan0DyhqG7bR+jA4UA= X-Gm-Gg: AZuq6aIxemZWLb40dBWAUMnerWg5dGCjuphxhjS5fuzpnkb708hgwNel40Fzd3+8zWh /vuzMOo5uBYhVeSlJ+T9ZOpwvUhKMu2MuQo58Lv6BnY6fdoZ3pq6OZWsaF6ApewuK84uXkSa0Ng h2ZiCAh0pU1PzbJ68M+gUxnqU1lUnA9+1Cg14MDgPb5ovXYOcMKXP1lY68HMKAHNnFZo8ilzbWJ ek7ytsKvM2/ralKvFlVJlHbAuHQvZNoRNpDSLTNejRP0KzFbKCrCDCAgd7mgx6SLjq/kTa+9V5g 5GKI8R2Yb+JVKciznWk/ikcqR7b0xdR8lx/QA1/uIK3IraUMaNenKVbVT9iLtZJAjBvEdQBqPlt EBMQpk14Z3Flm9IoEWUGKM7PUPyicOqwkDGJUG6Xud11f7a1pI/8KLjNtCJHa0Wbd1ZY0z9cNBf KNcy0L22fPew== X-Received: by 2002:a05:6102:442b:b0:5d7:de89:8dc6 with SMTP id ada2fe7eead31-5f1a4d76112mr5703201137.6.1769093148206; Thu, 22 Jan 2026 06:45:48 -0800 (PST) MIME-Version: 1.0 References: <901967e5-e5dc-42c6-b2bf-fb3a49d7e787@gmail.com> In-Reply-To: From: jian he Date: Thu, 22 Jan 2026 22:45:10 +0800 X-Gm-Features: AZwV_Qg5y-pC4SPfd42JyAs6yhj3A-oNEJLSEGMHpiVp6fyvzut_DdgvMaBz2DQ Message-ID: Subject: Re: Change COPY ... ON_ERROR ignore to ON_ERROR ignore_row To: Matheus Alcantara Cc: torikoshia , Masahiko Sawada , vignesh C , Jim Jones , Kirill Reshke , Fujii Masao , "David G. Johnston" , Yugo NAGATA , 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 Thu, Jan 22, 2026 at 2:47=E2=80=AFAM Matheus Alcantara wrote: > > Thanks for the new version. I have some comments on this first round of > review: > > + errmsg_plural("invalid values in %" PRIu64 " row was replaced with null= due to data type incompatibility", > + "invalid values in %" PRIu64 " rows were replaced with null due to da= ta type incompatibility", > > I think that we could remove the "invalid values in" to make it > consistency with the COPY_ON_ERROR_IGNORE NOTICE > sure. > ---------- > > + cstate->domain_with_constraint =3D (bool *) palloc0(attr_= count * sizeof(bool)); > > I think that we can use palloc_array? > sure. > ---------- > > Should FORCE_NOT_NULL be allowed to be used with ON_ERROR set_null? It > seems to me that ON_ERROR set_null overwrite the FORCE_NOT_NULL > behaviour: > > postgres=3D# create table t4(a int, b varchar(5)); > CREATE TABLE > > postgres=3D# copy t4 from 'data.csv' with (FORCE_NOT_NULL(b), format csv,= delimiter ',', NULL 'NULL', ON_ERROR set_null); > NOTICE: invalid values in 2 rows were replaced with null due to data typ= e incompatibility > COPY 5 > > postgres=3D# \pset null 'NULL' > Null display is "NULL". > postgres=3D# select * from t4; > a | b > ---+------ > 1 | aaaa > 2 | bbbb > 2 | NULL > 2 | NULL > 5 | NULL > (5 rows) > > Note that only the ccccc rows on .csv file was inserted with a NULL > value on b column. The 5,NULL row was inserted with a "NULL" string as a > value: > > postgres=3D# select * from t4 where b is null; > a | b > ---+------ > 2 | NULL > 2 | NULL > (2 rows) > > The contents of data.csv: > 1,aaaa > 2,bbbb > 2,ccccc > 2,ccccc > 5,NULL > > Perhaps we should block the usage of FORCE_NOT_NULL with ON_ERROR > SET_NULL? > FORCE_NOT_NULL is related to how we handle NULL string in column value. We first process cstate->opts.force_notnull_flags, cstate->opts.force_null_= flags then InputFunctionCallSafe. see copyfromparse.c, CopyFromTextLikeOneRow ``if (is_csv)``loop. I think these two are unrelated things, FORCE_NOT_NULL should be fine with ON_ERROR SET_NULL. you can see related tests in https://git.postgresql.org/cgit/postgresql.git/tree/src/test/regress/sql/co= py2.sql#n330 Am I missing something? > > On monitoring.sgml we have the following for pg_stat_progress_copy > tuples_skipped: > Number of tuples skipped because they contain malformed data. > This counter only advances when a value other than > stop is specified to the ON_ERROR > > IIUC we are not updating this view if we set a column to NULL due to an > error, perhaps this documentation should be updated to mention that it > will not be updated with ON_ERROR set_null? > IMHO, we don't need to mention ON_ERROR set_null, since we do not support i= t. change to the following should be ok, i think. Number of tuples skipped because they contain malformed data. This counter only advances when ignore is specified to the ON_ERROR option. > > I may have missing something, but we are still considering implementing > the REJECT_LIMIT + ON_ERROR set_null? Possibly as a separate patch later. -- jian https://www.enterprisedb.com/