Re: Add new COPY option REJECT_LIMIT

jian he <jian.universality@gmail.com>

From: jian he <jian.universality@gmail.com>
To: torikoshia <torikoshia@oss.nttdata.com>
Cc: Fujii Masao <masao.fujii@oss.nttdata.com>, zhjwpku@gmail.com, pgsql-hackers@lists.postgresql.org
Date: 2024-10-03T07:27:19Z
Lists: pgsql-hackers
> I'm wondering if we can use the wording maxerror as in the attached
> patch.
>

+   <varlistentry>
+    <term><literal>REJECT_LIMIT</literal></term>
+    <listitem>
+     <para>
+      Specifies the maximum number of errors tolerated while converting a
+      column's input value to its data type, when
<literal>ON_ERROR</literal> is
+      set to <literal>ignore</literal>.
+      If the input causes more errors than the specified value, the
<command>COPY</command>
+      command fails, even with <literal>ON_ERROR</literal> set to
<literal>ignore</literal>.
+      This clause must be used with
<literal>ON_ERROR</literal>=<literal>ignore</literal>
+      and <replaceable class="parameter">maxerror</replaceable> must
be positive.
+      If not specified, <literal>ON_ERROR</literal>=<literal>ignore</literal>
+      allows an unlimited number of errors, meaning
<command>COPY</command> will
+      skip all erroneous data.
+     </para>
+    </listitem>
+   </varlistentry>

mentioning <replaceable class="parameter">maxerror</replaceable> is a
bigint type
or explicitly mentioning the maximum allowed value of "maxerror" would be great.

other than that, it looks good to me.



Commits

  1. Move check for binary mode and on_error option to the appropriate location.

  2. Add REJECT_LIMIT option to the COPY command.