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 1rUEwV-009j78-Rw for pgsql-hackers@arkaria.postgresql.org; Sun, 28 Jan 2024 23:52:04 +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 1rUEwU-00APZJ-Qg for pgsql-hackers@arkaria.postgresql.org; Sun, 28 Jan 2024 23:52:02 +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 1rUEwU-00APZB-Hj for pgsql-hackers@lists.postgresql.org; Sun, 28 Jan 2024 23:52:02 +0000 Received: from mail-qv1-xf31.google.com ([2607:f8b0:4864:20::f31]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rUEwR-003sJA-Vq for pgsql-hackers@lists.postgresql.org; Sun, 28 Jan 2024 23:52:01 +0000 Received: by mail-qv1-xf31.google.com with SMTP id 6a1803df08f44-6860ff3951aso18156576d6.1 for ; Sun, 28 Jan 2024 15:51:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706485919; x=1707090719; 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=ta27p/oVjS+ReFy+ccH109tIVSoKjSXQnRvbdxT4Wdo=; b=YAw6mofTDO4WnDXj6LgXTcXdOMB6lug58Hims6qQ0q2N6ECcU4SriteZ6U+MktfADL iWToMdKVfATyp3+GjtlhRC7QC+INJQrk62/tmIPg8jufFDYO28f9UeXmiIkxJWR3+8Uw Ab2iDbf+rq6VbFmZlv7FBBnQGrQiNe+s3r01QS4oAqeQnemqos8q/GzqlotTAMUaIzzK UOAsmKCYARPEWIg9cO/sulv6nKGBFRq5lETkjW1UWU2Nu+nMHGQ1ZxbehHhXmn8IXUwL n9Jk69luEv3Aa9t6uQjhO8mAy08wQLViK4VwqzbabAWqnNUYAkELJEXHE2ZB5lyOuu79 jdtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706485919; x=1707090719; 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=ta27p/oVjS+ReFy+ccH109tIVSoKjSXQnRvbdxT4Wdo=; b=S2BDjEDjZRZH1to2YbRr2vOUh01/nHVjDzhUF0zOiOyx3B8KCLanUkBuVg5/39qpM6 7I02rnCIc7XgmlNIc+ytVh7Cj9Qq5Zcy0yA37mcZj9tupfJjLBQTdpma0kBVOVO3r+tj Mou4LtjtBY6lije4h7n+/Bl2zTMS94S90Eu4yB8Yj1nfBhRuPHwz61NmF2ttPuCPEwlB iFdFkMsAqXuwjBi1awDnPrCvwo0hVWcUI4NxEC0UooaUTxbQV86wwkbF/9LOrPta7pyp ILNQOjPKeGEETiFWt/h7WP+WrrMx0SYYuHvr2nAXHGXSn4es6TaO4T6tYFTYnvYYhVRV F+eg== X-Gm-Message-State: AOJu0YxMJ0yDbDWAcD0LCUfIG7EZFwe4s/VLFA7VZgF8nhXRv86zCeUx s71MDdBw+GEL3KYfb46p5L5U1H+P2dtQ+c/ysKzePshNmbYYLFriwIcSM4G6O96QZ3lJlPvl+Bt YyaAlTcOA//ohBZH/mfjkLSaDf+w= X-Google-Smtp-Source: AGHT+IEj9um+hoZ8tM2CqkVdbx945CbT7um/YbgUyLZGj7eZ3l6HlX26oVWxzp63d8GJjp2iBofPSIsymid0wCDXoWU= X-Received: by 2002:a05:6214:1c4c:b0:686:ba26:9d23 with SMTP id if12-20020a0562141c4c00b00686ba269d23mr5577145qvb.3.1706485918844; Sun, 28 Jan 2024 15:51:58 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: jian he Date: Mon, 29 Jan 2024 07:50:00 +0800 Message-ID: Subject: Re: Change COPY ... ON_ERROR ignore to ON_ERROR ignore_row To: "David G. Johnston" Cc: 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 Fri, Jan 26, 2024 at 11:09=E2=80=AFPM David G. Johnston wrote: > > Hi, > > The option choice of "ignore" in the COPY ON_ERROR clause seems overly ge= neric. There would seem to be two relevant ways to ignore bad column input= data - drop the entire row or just set the column value to null. I can se= e us wanting to provide the set to null option and in any case having the o= ption name be explicit that it ignores the row seems like a good idea. two issue I found out while playing around with it; create table x1(a int not null, b int not null ); you can only do: COPY x1 from stdin (on_error 'null'); but you cannot do COPY x1 from stdin (on_error null); we need to hack the gram.y to escape the "null". I don't know how to make it work. related post I found: https://stackoverflow.com/questions/31786611/how-to-escape-flex-keyword another issue: COPY x1 from stdin (on_error null); when we already have `not null` top level constraint for table x1. Do we need an error immediately? "on_error null" seems to conflict with `not null` constraint (assume refers to the same column). it may fail while doing bulk inserts while on_error is set to null because of violating a not null constraint.