Re: Conflict handling for COPY FROM - Mailing list pgsql-hackers

From Tatsuo Ishii
Subject Re: Conflict handling for COPY FROM
Date
Msg-id 20200217.113710.1462561830892693526.t-ishii@sraoss.co.jp
Whole thread Raw
In response to Re: Conflict handling for COPY FROM  (Tatsuo Ishii <ishii@sraoss.co.jp>)
Responses Re: Conflict handling for COPY FROM  (Surafel Temesgen <surafel3000@gmail.com>)
List pgsql-hackers
> In your patch for copy.sgml:
> 
>     ERROR_LIMIT '<replaceable class="parameter">limit_number</replaceable>'
> 
> I think this should be:
> 
>     ERROR_LIMIT <replaceable class="parameter">limit_number</replaceable>
> 
> (no single quote)

More comments:

- I think the document should stat that if limit_number = 0, all
  errors are immediately raised (behaves same as current befavior without the patch).

- "constraint violating rows will be returned back to the caller."
  This does explains the current implementation. I am not sure if it's
  intended or not though:

cat /tmp/a
1    1
2    2
3    3
3    4

psql test
$ psql test
psql (13devel)
Type "help" for help.

test=# select * from t1;
 i | j 
---+---
 1 | 1
 2 | 2
 3 | 3
(3 rows)

test=# copy t1 from '/tmp/a' with (error_limit 1);
ERROR:  duplicate key value violates unique constraint "t1_pkey"
DETAIL:  Key (i)=(2) already exists.
CONTEXT:  COPY t1, line 2: "2    2"

So if the number of errors raised exceeds error_limit, no constaraint
violating rows (in this case i=1, j=1) are returned.

Best regards,
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese:http://www.sraoss.co.jp



pgsql-hackers by date:

Previous
From: "Moon, Insung"
Date:
Subject: Flexible pglz_stategy values and delete const.
Next
From: Bryn Llewellyn
Date:
Subject: Re: jsonb_object() seems to be buggy. jsonb_build_object() is good.