Re: implicit abort harmful?

From: Jan Wieck <JanWieck(at)Yahoo(dot)com>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: Wayne Armstrong <wdarmst(at)bacchus(dot)com(dot)au>, pgsql-general(at)postgresql(dot)org
Subject: Re: implicit abort harmful?
Date: 2003-05-30 00:25:56
Message-ID: 3ED6A514.6070102@Yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Martijn van Oosterhout wrote:
> On Sun, May 25, 2003 at 10:04:30AM +1000, Wayne Armstrong wrote:
>
>> During import of 120 thousand records from an isam file system, 3 say records
>>fail integrity checks ( files in non-database systems tend not to have
>>referential integrity implemented on them except at an application level
>>(meaning not at all :). The desired result is to drop the records failing
>>integrity checks.
>
>
> Yes, I have that problem too. I actually wrote a script that took an input
> file and automatically reissued queries that succeeded but got rolled-back.
> I called it quickloader.pl :)
>
> Probably the biggest problem is that you can't use COPY to load the data.
> I've thought about loading into another table and transferring later but I
> havn't sorted out the details.

The general idea would be to setup a table that has exactly the same
structure as the final target table, but with no constraints at all. As
long as your data passes all input functions you can even COPY it in.

Now you run check queries that show you all tuples in that staging table
that would fail constraints on the final table. Fix those and you can do

INSERT INTO final SELECT * FROM staging;

If step one fails because of data that doesn't pass the input functions
of our data types, you have to go through another level of staging with
a table that has text fields only and move it by explicit casting after
cleaning up those problems.

Jan

--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message DeJuan Jackson 2003-05-30 00:57:39 Re: CURRENT_DATE and CURRENT_TIME return incorrect values
Previous Message Williams, Travis L, NPONS 2003-05-30 00:20:35 Join question