Re: getting all constraint violations

From: "Gauthier, Dave" <dave(dot)gauthier(at)intel(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: getting all constraint violations
Date: 2010-05-21 19:29:43
Message-ID: 482E80323A35A54498B8B70FF2B879800458B887A1@azsmsx504.amr.corp.intel.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm thinking more along the lines of creating a bunch of temp tables, each with one of the constraints. Then, in a loop, throw the record at each of these temp tables and collect up the violations.

Exploring now hot to get the pieces I need from the metadata tables to do this.

-----Original Message-----
From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
Sent: Friday, May 21, 2010 3:10 PM
To: Gauthier, Dave
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] getting all constraint violations

"Gauthier, Dave" <dave(dot)gauthier(at)intel(dot)com> writes:
> Is there a way to temporarily suspend constraint checking for a particular constraint inside of the transaction, try the insert again, capture the next violation, then the next, etc... then rollback after all have been collected?

You could do something like

BEGIN;
ALTER TABLE DROP CONSTRAINT ...
INSERT ...
ROLLBACK;

The major deficiency of this is that the ALTER TABLE would grab
exclusive lock on the table, so this doesn't scale if you need to
have several insertions happening in parallel.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andreas Schmitz 2010-05-21 20:02:01 Re: cleaning wal files from postgres
Previous Message Tom Lane 2010-05-21 19:10:22 Re: getting all constraint violations