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 1rXGyj-009gcd-7r for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Feb 2024 08:38:53 +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 1rXGyi-001udR-4q for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Feb 2024 08:38:52 +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 1rXGyh-001udJ-Pc for pgsql-hackers@lists.postgresql.org; Tue, 06 Feb 2024 08:38:51 +0000 Received: from mail-ua1-x936.google.com ([2607:f8b0:4864:20::936]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rXGya-005jGF-MS for pgsql-hackers@lists.postgresql.org; Tue, 06 Feb 2024 08:38:51 +0000 Received: by mail-ua1-x936.google.com with SMTP id a1e0cc1a2514c-7d60ee03b54so1721726241.2 for ; Tue, 06 Feb 2024 00:38:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707208723; x=1707813523; 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=SSQ1xOHHjgc+LyumISjJb8OcmTTbNdptAQ8U71HiJEo=; b=ERslTgx4cAcL4oNa8tJzTKaYvDelNLaG4npkluKsFh8Wxg2mmmHYJhTkz7j7qsDLIn St1veMSjouqds0+dHYnVkJ2/p1kTC/gkt+MuY1Y1DGwzcyfWf7dgCQlq79y/BVJ/AbNE dy9o8sxnkhQZWAhIpOxRqEAK+3sSmu6SNvo1k0P9GRNZ1ol5Wf/cGYDQG3Q+6nTCOpzY ZnNpx7rW9msLDEQZuY9jTsnBRc4dRoxby5Y3LtcCiVrgYHAVtLaz8UYGBqkttdbUYb/V zJHsBzVsJq6DefHujZgobfeBsh2bZ4xK3rF+RPlu/QdOa+Oiai6uTCiz7iW7ihtLsvvE fAjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707208723; x=1707813523; 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=SSQ1xOHHjgc+LyumISjJb8OcmTTbNdptAQ8U71HiJEo=; b=xByBNIrkIAKEZnAVcz8amZJ8wFKiT7X5Gbi5wu/Yl1oZbZ5N6DITxs+nwuOK6d5CSd VkDctP+FUgBbenjAtQFaaKMJ6iTUv0arrILQN//D5/HqdRWWvF9sTCjt1JUk3E8QBzaI ZUilTQjqvXnKjfFti1cDEUpS//lkQjchJaitqjD1ZCp7UhaznOQ9MY7YEZgBaqCA6BHG ZSWMoPcr5ZmpqyfmYVssKXdORW5+CT1NQzgj/z8h6UkKi5ro/c3Uxdd3fOHgrXXzDYrK AIvHFo5OyruqSumCvufhGBPSKaSH8NXFIRV4Q/ZjRaZuVgh+l4AZntft7/CbCDNzwNlI yP2w== X-Gm-Message-State: AOJu0YwCEFx0qDC8aoU9niC2N4ORcbQ9HFBBFBD6+OO8yoBEs5pGAeGN K4JR3pHLUR5f8nbBAXyzHcmuuc4fQf7pR/CvamTDR1TrUytHBDG4CLoA3V/13lKdeRceNykF1FW R3JsS67fXMxsuxKpwz1idM2MPvJ4= X-Google-Smtp-Source: AGHT+IH0QrBj1sb05jljUh+WBoi/fEjKtbx/YCZjxCh5Qjby4v7hCe9o07VKHfEFzSfTxsojzrUvmX1+VhN8ex1BTyU= X-Received: by 2002:a67:fd09:0:b0:46b:303d:471a with SMTP id f9-20020a67fd09000000b0046b303d471amr2417594vsr.31.1707208722563; Tue, 06 Feb 2024 00:38:42 -0800 (PST) MIME-Version: 1.0 References: <04bf425ad1b15a4daefe96c478a5253b@oss.nttdata.com> <20240205172256.0942c4e8b757fc6f7c4dbfa8@sraoss.co.jp> <20240206.093909.1866377550429411676.horikyota.ntt@gmail.com> <20240206164641.43d0793c5d82da27b5982ef5@sraoss.co.jp> In-Reply-To: <20240206164641.43d0793c5d82da27b5982ef5@sraoss.co.jp> From: jian he Date: Tue, 6 Feb 2024 16:38:31 +0800 Message-ID: Subject: Re: Change COPY ... ON_ERROR ignore to ON_ERROR ignore_row To: Yugo NAGATA Cc: Kyotaro Horiguchi , torikoshia@oss.nttdata.com, david.g.johnston@gmail.com, pgsql-hackers@lists.postgresql.org 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, Feb 6, 2024 at 3:46=E2=80=AFPM Yugo NAGATA wr= ote: > > On Tue, 06 Feb 2024 09:39:09 +0900 (JST) > Kyotaro Horiguchi wrote: > > > At Mon, 5 Feb 2024 17:22:56 +0900, Yugo NAGATA wr= ote in > > > On Mon, 05 Feb 2024 11:28:59 +0900 > > > torikoshia wrote: > > > > > > > > Based on this, I've made a patch. > > > > > based on COPY Synopsis: ON_ERROR 'error_action' > > > > > on_error 'null', the keyword NULL should be single quoted. > > > > > > > > As you mentioned, single quotation seems a little odd.. > > > > > > > > I'm not sure what is the best name and syntax for this feature, but > > > > since current error_action are verbs('stop' and 'ignore'), I feel '= null' > > > > might not be appropriate. > > > > > > I am not in favour of using 'null' either, so I suggested to use > > > "set_to_null" or more generic syntax like "set_to (col, val)" in my > > > previous post[1], although I'm not convinced what is the best either. > > > > > > [1] https://www.postgresql.org/message-id/20240129172858.ccb6c77c3be9= 5a295e2b2b44%40sraoss.co.jp > > > > Tom sugggested using a separate option, and I agree with the > > suggestion. Taking this into consideration, I imagined something like > > the following, for example. Although I'm not sure we are actually > > going to do whole-tuple replacement, the action name in this example > > has the suffix '-column'. > > > > COPY (on_error 'replace-colomn', replacement 'null') .. > > Thank you for your information. I've found a post[1] you mentioned, > where adding a separate option for error log destination was suggested. > > Considering consistency with other options, adding a separate option > would be better if we want to specify a value to replace the invalid > value, without introducing a complex syntax that allows options with > more than one parameters. Maybe, if we allow to use values for the > replacement other than NULL, we have to also add a option to specify > a column (or a type) for each replacement value. Or, we may add a > option to specify a list of replacement values as many as the number of > columns, each of whose default is NULL. > > Anyway, I prefer 'replace" (or 'set_to') to just 'null' as the option > value. > Let's say tabe t column (a,b,c) if we support set_to_null(a,b), what should we do if column c has an error. should we ignore this row or error out immediately? also I am not sure it's doable to just extract columnList from the function defGetCopyOnErrorChoice. to make `COPY x from stdin (on_error set_to_null(a,b);` work, we may need to refactor to gram.y, in a similar way we do force null i am ok with COPY x from stdin (on_error set_to_null);