Re: Conflict handling for COPY FROM

From: Tatsuo Ishii <ishii(at)sraoss(dot)co(dot)jp>
To: surafel3000(at)gmail(dot)com
Cc: asaba(dot)takanori(at)fujitsu(dot)com, a(dot)kondratov(at)postgrespro(dot)ru, alvherre(at)2ndquadrant(dot)com, andres(at)anarazel(dot)de, andrew(dot)dunstan(at)2ndquadrant(dot)com, robertmhaas(at)gmail(dot)com, anowocien(at)gmail(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Conflict handling for COPY FROM
Date: 2020-02-17 02:37:10
Message-ID: 20200217.113710.1462561830892693526.t-ishii@sraoss.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bryn Llewellyn 2020-02-17 03:05:26 Re: jsonb_object() seems to be buggy. jsonb_build_object() is good.
Previous Message Imre Samu 2020-02-17 02:16:42 Re: 1 Status of vertical clustered index - 2 Join using (fk_constraint) suggestion - 3 Status of pgsql's parser autonomization