Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id A721964FCD4 for ; Wed, 27 Aug 2008 11:15:14 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 09171-01 for ; Wed, 27 Aug 2008 11:15:04 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from rhino2.esc1.com (69-77-143-107.dsl.static.skybest.com [69.77.143.107]) by postgresql.org (Postfix) with ESMTP id 8C6D0650285 for ; Wed, 27 Aug 2008 11:15:03 -0300 (ADT) Received: from rhino2.esc1.com (localhost.localdomain [127.0.0.1]) by rhino2.esc1.com (8.13.8/8.13.8) with ESMTP id m7REF0aX031298 for ; Wed, 27 Aug 2008 10:15:00 -0400 Received: from localhost (localhost [[UNIX: localhost]]) by rhino2.esc1.com (8.13.8/8.13.8/Submit) id m7REF0O9031297 for pgsql-general@postgresql.org; Wed, 27 Aug 2008 10:15:00 -0400 X-Authentication-Warning: rhino2.esc1.com: terry set sender to terry@chosen-ones.org using -f From: Terry Lee Tucker Organization: Ozburn-Hessey Logistics To: "PG-General Mailing List" Subject: Re: Dumping/Restoring with constraints? User-Agent: KMail/1.9.4 References: <200808270929.42049.terry@chosen-ones.org> In-Reply-To: MIME-Version: 1.0 Content-Disposition: inline Date: Wed, 27 Aug 2008 10:15:00 -0400 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200808271015.00589.terry@chosen-ones.org> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200808/946 X-Sequence-Number: 136776 On Wednesday 27 August 2008 09:36, Phoenix Kiula wrote: > On Wed, Aug 27, 2008 at 9:29 PM, Terry Lee Tucker wrote: > > We have all sorts of constraints and foreign keys and we have never had > > any problem with pg_restore related to dumping such that foreign keys are > > satisfied. You must have data already in the database that violates the > > restraints. You can restore in two phases; that is, by restoring the > > schema, and then the data using --disable-triggers. I'm assuming you are > > doing a binary dump. See the man page for pg_restore. > > Thanks for this. I don't have any foreign key violations in my > existing database. I think the violation is happening because upon > restoring the table that is being populated checks in another table > that doesn't yet have data. > > I am not using pg_restore. I am just using "psql --file=FILENAME" > syntax. Is that an issue? The errors you are having, then, must be related to your own trigger code. It sounds like you will need to prevent those triggers from firing and the only way I know how to accomplish that is to do a binary dump and then use pg_restore as I indicated earlier. There is no way to disable triggers in your method referenced above. -- Terry Lee Tucker Turbo's IT Manager Turbo, division of Ozburn-Hessey Logistics 2251 Jesse Jewell Pkwy NE Gainesville, GA 30501 Tel: (336) 372-6812 Fax: (336) 372-6812 Cell: (336) 404-6987 terry@turbocorp.com www.turbocorp.com