@@ -90,6 +90,13 @@ COPY { <replaceable class="parameter">table_name</replaceable> [ ( <replaceable
90
90
in the <structname>pg_stat_progress_copy</structname> view. See
91
91
<xref linkend="copy-progress-reporting"/> for details.
92
92
</para>
93
+
94
+ <para>
95
+ By default, <command>COPY</command> will fail if it encounters an error
96
+ during processing. For use cases where a best-effort attempt at loading
97
+ the entire file is desired, the <literal>ON_ERROR</literal> clause can
98
+ be used to specify some other behavior.
99
+ </para>
93
100
</refsect1>
94
101
95
102
<refsect1>
@@ -378,17 +385,20 @@ COPY { <replaceable class="parameter">table_name</replaceable> [ ( <replaceable
378
385
<term><literal>ON_ERROR</literal></term>
379
386
<listitem>
380
387
<para>
381
- Specifies which <replaceable class="parameter">
382
- error_action</replaceable> to perform when there is malformed data in the input.
383
- Currently, only <literal>stop</literal> (default) and <literal>ignore</literal>
384
- values are supported.
385
- If the <literal>stop</literal> value is specified,
386
- <command>COPY</command> stops operation at the first error.
387
- If the <literal>ignore</literal> value is specified,
388
- <command>COPY</command> skips malformed data and continues copying data.
389
- The option is allowed only in <command>COPY FROM</command>.
390
- Only <literal>stop</literal> value is allowed when
391
- using <literal>binary</literal> format.
388
+ Specifies how to behave when encountering an error converting a column's
389
+ input value into its data type.
390
+ An <replaceable class="parameter">error_action</replaceable> value of
391
+ <literal>stop</literal> means fail the command, while
392
+ <literal>ignore</literal> means discard the input row and continue with the next one.
393
+ The default is <literal>stop</literal>.
394
+ </para>
395
+ <para>
396
+ The <literal>ignore</literal> option is applicable only for <command>COPY FROM</command>
397
+ when the <literal>FORMAT</literal> is <literal>text</literal> or <literal>csv</literal>.
398
+ </para>
399
+ <para>
400
+ A <literal>NOTICE</literal> message containing the ignored row count is emitted at the end
401
+ of the <command>COPY FROM</command> if at least one row was discarded.
392
402
</para>
393
403
</listitem>
394
404
</varlistentry>
@@ -576,15 +586,13 @@ COPY <replaceable class="parameter">count</replaceable>
576
586
</para>
577
587
578
588
<para>
579
- <command>COPY</command> stops operation at the first error when
580
- <literal>ON_ERROR</literal> is not specified. This
581
- should not lead to problems in the event of a <command>COPY
582
- TO</command>, but the target table will already have received
583
- earlier rows in a <command>COPY FROM</command>. These rows will not
584
- be visible or accessible, but they still occupy disk space. This might
585
- amount to a considerable amount of wasted disk space if the failure
586
- happened well into a large copy operation. You might wish to invoke
587
- <command>VACUUM</command> to recover the wasted space.
589
+ The <command>COPY FROM</command> command physically inserts input rows
590
+ into the table as it progresses. If the command fails, these rows are
591
+ left in a deleted state; these rows will not be visible, but still
592
+ occupy disk space. This might amount to considerable
593
+ wasted disk space if the failure happened well into a large copy
594
+ operation. <command>VACUUM</command> should be used to recover the
595
+ wasted space.
588
596
</para>
589
597
590
598
<para>
0 commit comments