Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id B8EC72E005B for ; Thu, 1 May 2008 16:57:59 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 92504-08 for ; Thu, 1 May 2008 16:57:48 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from fmailhost01.isp.att.net (fmailhost06.isp.att.net [207.115.11.56]) by developer.postgresql.org (Postfix) with ESMTP id EC7EF2E002D for ; Thu, 1 May 2008 16:57:48 -0300 (ADT) Received: from mac.home.edu (adsl-065-013-025-241.sip.asm.bellsouth.net[65.13.25.241]) by isp.att.net (frfwmhc06) with ESMTP id <20080501195746H0600clbmje>; Thu, 1 May 2008 19:57:46 +0000 X-Originating-IP: [65.13.25.241] Message-ID: <481A20B9.3000403@serioustechnology.com> Date: Thu, 01 May 2008 15:57:45 -0400 From: Geoffrey User-Agent: Thunderbird 2.0.0.12 (X11/20080226) MIME-Version: 1.0 To: Shane Ambler CC: pgsql-admin@postgresql.org Subject: Re: COPY errors when trying to convert from 7.4.19 to 8.3.1 References: <4819EDF9.2080000@serioustechnology.com> <481A09B8.2070604@Sheeky.Biz> In-Reply-To: <481A09B8.2070604@Sheeky.Biz> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/20 X-Sequence-Number: 29104 Shane Ambler wrote: > Geoffrey wrote: >> We are trying to test our process for upgrading our database from >> 7.4.19 to 8.3.1. We are following the instructions for dumping the >> 7.4.19 database from: >> >> http://www.postgresql.org/docs/8.3/static/install-upgrading.html >> >> ie: >> >> /usr/local/pg83/bin/pg_dumpall -h master -p 5434 |gzip > dump.gz >> >> Create a new 8.3.1 cluster as follows: >> >> /usr/local/pg83/bin/initdb -D /data/pgsql/master83 >> >> Load the data into the new cluster: >> >> gunzip < dump.gz |/usr/local/pg83/bin/psql -d postgres >> >> We know we have some old data in the database that does not meet >> current criteria, thus we are seeing errors such as: > > Are you modifying the dump before the import with the new criteria > adjustments? Or is this criteria from changes between 7.4 and 8.3? We aren't making any changes to the dump data. It's likely caused by data that was quite old in the 7.4 database and new constraints were added since that data was created. > >> ERROR: insert or update on table "aaccess" violates foreign key >> constraint "$1" >> DETAIL: Key (code)=(CFSAVAUS000) is not present in table "arates". >> >> What baffles us is, that although we get these errors, the data is >> still being inserted in to the table, in this case, the aaccess table. >> > >> >> >> What are we missing? >> > > I am guessing here - I believe that the message is misleading. > > If you look at the dumpall output you may notice the order in which some > things are done. Yeah, as noted in my response to Tom, that is what I'm going to do. > > ... > ... > create table.... > copy from stdin.... > alter table add constraint.... > create index.... > ... > ... > > My guess is that the error is coming from the add constraint which is > invoked after the data has been inserted. > > Check your table defs in 8.3 and see if the fk constraints are in place. Will do. > > You would have two choices - clean up the data in 7.4 before the export > or clean up after the import and before the fk constraints are added. The latter is likely the plan. The primary concern is that we don't lose any data. -- Until later, Geoffrey Those who would give up essential Liberty, to purchase a little temporary Safety, deserve neither Liberty nor Safety. - Benjamin Franklin