From 2d656fe0a69ea1349472d88794c18f8a2e2d37e9 Mon Sep 17 00:00:00 2001 From: "David G. Johnston" Date: Thu, 25 Jan 2024 23:35:44 -0700 Subject: [PATCH] v2 Improve ON_ERROR verbiage in COPY documentation --- doc/src/sgml/ref/copy.sgml | 48 +++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/doc/src/sgml/ref/copy.sgml b/doc/src/sgml/ref/copy.sgml index 21a5c4a052..38ce0b0a4c 100644 --- a/doc/src/sgml/ref/copy.sgml +++ b/doc/src/sgml/ref/copy.sgml @@ -90,6 +90,13 @@ COPY { table_name [ ( pg_stat_progress_copy view. See for details. + + + By default, COPY will fail if it encounters an error + during processing. For use cases where a best-effort attempt at loading + the entire file is desired, the ON_ERROR clause can + be used to specify some other behavior. + @@ -378,17 +385,23 @@ COPY { table_name [ ( ON_ERROR - Specifies which - error_action to perform when there is malformed data in the input. - Currently, only stop (default) and ignore - values are supported. - If the stop value is specified, - COPY stops operation at the first error. - If the ignore value is specified, - COPY skips malformed data and continues copying data. - The option is allowed only in COPY FROM. - Only stop value is allowed when - using binary format. + Specifies which how to behave when encountering a soft error. + An error_action value of + stop means fail the command, while + ignore means discard the input row and continue with the next one. + The default is stop + + + The ignore option is applicable only for COPY FROM + when the FORMAT is text or csv. + + + The only relevant soft error is "invalid input syntax", which manifests when attempting + to create a column value from the text input. + + + An INFO level context message containing the ignored row count is + emitted at the end of the COPY FROM if at least one row was discarded. @@ -576,15 +589,12 @@ COPY count - COPY stops operation at the first error when - ON_ERROR is not specified. This - should not lead to problems in the event of a COPY - TO, but the target table will already have received - earlier rows in a COPY FROM. These rows will not - be visible or accessible, but they still occupy disk space. This might + The COPY FROM command physically inserts input rows + into the table as it progresses. If the command fails these rows are + left in a deleted state, still occupying disk space. This might amount to a considerable amount of wasted disk space if the failure - happened well into a large copy operation. You might wish to invoke - VACUUM to recover the wasted space. + happened well into a large copy operation. VACUUM + should be used to recover the wasted space. -- 2.34.1