mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Add new COPY option SAVE_ERROR_TO
Currently, when source data contains unexpected data regarding data type or range, the entire COPY fails. However, in some cases, such data can be ignored and just copying normal data is preferable. This commit adds a new option SAVE_ERROR_TO, which specifies where to save the error information. When this option is specified, COPY skips soft errors and continues copying. Currently, SAVE_ERROR_TO only supports "none". This indicates error information is not saved and COPY just skips the unexpected data and continues running. Later works are expected to add more choices, such as 'log' and 'table'. Author: Damir Belyalov, Atsushi Torikoshi, Alex Shulgin, Jian He Discussion: https://postgr.es/m/87k31ftoe0.fsf_-_%40commandprompt.com Reviewed-by: Pavel Stehule, Andres Freund, Tom Lane, Daniel Gustafsson, Reviewed-by: Alena Rybakina, Andy Fan, Andrei Lepikhov, Masahiko Sawada Reviewed-by: Vignesh C, Atsushi Torikoshi
This commit is contained in:
@ -43,6 +43,7 @@ COPY { <replaceable class="parameter">table_name</replaceable> [ ( <replaceable
|
||||
FORCE_QUOTE { ( <replaceable class="parameter">column_name</replaceable> [, ...] ) | * }
|
||||
FORCE_NOT_NULL { ( <replaceable class="parameter">column_name</replaceable> [, ...] ) | * }
|
||||
FORCE_NULL { ( <replaceable class="parameter">column_name</replaceable> [, ...] ) | * }
|
||||
SAVE_ERROR_TO '<replaceable class="parameter">location</replaceable>'
|
||||
ENCODING '<replaceable class="parameter">encoding_name</replaceable>'
|
||||
</synopsis>
|
||||
</refsynopsisdiv>
|
||||
@ -373,6 +374,25 @@ COPY { <replaceable class="parameter">table_name</replaceable> [ ( <replaceable
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><literal>SAVE_ERROR_TO</literal></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies to save error information to <replaceable class="parameter">
|
||||
location</replaceable> when there is malformed data in the input.
|
||||
Currently, only <literal>error</literal> (default) and <literal>none</literal>
|
||||
values are supported.
|
||||
If the <literal>error</literal> value is specified,
|
||||
<command>COPY</command> stops operation at the first error.
|
||||
If the <literal>none</literal> value is specified,
|
||||
<command>COPY</command> skips malformed data and continues copying data.
|
||||
The option is allowed only in <command>COPY FROM</command>.
|
||||
The <literal>none</literal> value is allowed only when
|
||||
not using <literal>binary</literal> format.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><literal>ENCODING</literal></term>
|
||||
<listitem>
|
||||
@ -556,7 +576,8 @@ COPY <replaceable class="parameter">count</replaceable>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<command>COPY</command> stops operation at the first error. This
|
||||
<command>COPY</command> stops operation at the first error when
|
||||
<literal>SAVE_ERROR_TO</literal> is not specified. This
|
||||
should not lead to problems in the event of a <command>COPY
|
||||
TO</command>, but the target table will already have received
|
||||
earlier rows in a <command>COPY FROM</command>. These rows will not
|
||||
|
Reference in New Issue
Block a user