when COPY violates Primary Keys

Started by Joao Ferreira gmailover 17 years ago3 messagesgeneral
Jump to latest
#1Joao Ferreira gmail
joao.miguel.c.ferreira@gmail.com

Hello all,

I have a ascii dump file based on the COPY operation.

lets say I restore this dump into a live database with applications
doing INSERTs and UPDATEs onto it.

in case the COPY of a register causes a primary key (or UNIQUE, or FK)
violation does the psql restore command try to continue the operation
until it has parsed the whole dump, or does it abort on the first
violation ?

thx
Joao

#2Chris
dmagick@gmail.com
In reply to: Joao Ferreira gmail (#1)
Re: when COPY violates Primary Keys

Joao Ferreira gmail wrote:

Hello all,

I have a ascii dump file based on the COPY operation.

lets say I restore this dump into a live database with applications
doing INSERTs and UPDATEs onto it.

in case the COPY of a register causes a primary key (or UNIQUE, or FK)
violation does the psql restore command try to continue the operation
until it has parsed the whole dump, or does it abort on the first
violation ?

Copy is all or nothing. It'll abort as soon as a violation happens.

the bulkloader on pgfoundry (http://pgfoundry.org/projects/pgbulkload/)
can apparently handle this for you...

--
Postgresql & php tutorials
http://www.designmagick.com/

#3ITAGAKI Takahiro
itagaki.takahiro@oss.ntt.co.jp
In reply to: Chris (#2)
Re: when COPY violates Primary Keys

Chris <dmagick@gmail.com> wrote:

Joao Ferreira gmail wrote:

in case the COPY of a register causes a primary key (or UNIQUE, or FK)
violation does the psql restore command try to continue the operation
until it has parsed the whole dump, or does it abort on the first
violation ?

Copy is all or nothing. It'll abort as soon as a violation happens.

the bulkloader on pgfoundry (http://pgfoundry.org/projects/pgbulkload/)
can apparently handle this for you...

No, pg_bulkload is all or nothing for constraints violations.
Please use pgloader (http://pgfoundry.org/projects/pgloader/)
for the purpose.

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center