Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 0EC9A2E002D for ; Thu, 1 May 2008 13:44: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 98224-01-5 for ; Thu, 1 May 2008 13:44:51 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by developer.postgresql.org (Postfix) with ESMTP id ECA912E00A2 for ; Thu, 1 May 2008 13:44:51 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m41Gip6M015881; Thu, 1 May 2008 12:44:51 -0400 (EDT) To: Geoffrey cc: pgsql-admin@postgresql.org Subject: Re: COPY errors when trying to convert from 7.4.19 to 8.3.1 In-reply-to: <4819EDF9.2080000@serioustechnology.com> References: <4819EDF9.2080000@serioustechnology.com> Comments: In-reply-to Geoffrey message dated "Thu, 01 May 2008 12:21:13 -0400" Date: Thu, 01 May 2008 12:44:51 -0400 Message-ID: <15880.1209660291@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/14 X-Sequence-Number: 29098 Geoffrey writes: > 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: > 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. Well, the insert has already happened: the error is actually coming out when the dump script tries to do ALTER TABLE ADD CONSTRAINT FOREIGN KEY. (The message is perhaps a bit misleading if you don't notice which command caused it.) What this looks like to me is a misordering of the dump operations such that we're trying to do the ALTER on aaccess after loading its data, but before loading arates's data. In theory 8.3's pg_dump should avoid such mistakes, but it's possible you've got a case that fools it. Anyway, the first thing you should do to investigate is to check exactly what's the order of operations in the script and which command is causing the failure. If the data involved is too large to make it convenient to eyeball the dump script with an editor, you might try running the dump script with log_statement = all so you can see just the SQL commands in the postmaster log. regards, tom lane