Check Constraints and pg_dump - Mailing list pgsql-hackers

From Jonathan Scott
Subject Check Constraints and pg_dump
Date
Msg-id 20040226164752.25b63244.jwscott@vanten.com
Whole thread Raw
Responses Re: Check Constraints and pg_dump  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hello again,

A project I am working on has been having problems with pg_dump's output, using 7.3. Our project's database includes
functionsthat do constraint checking for us, as well as circular dependencies.  

We heard about the changes on the pgsql HEAD/7.5, and have given it a try. It fixed nearly all our problems; however,
thereis one that is cropping up that we feel should be reviewed: check constraints do not get deferred when loading the
databack in to the database using pg_dump's default script. 

I have written a script which should be able to reproduce the problem we are encountering. We do not have binary data,
sowe just use the regular SQL output of pg_dump. The functions and tables create just fine, but when it gets to the
COPYpart of the sql script, it tries to load tables in what really is the wrong order. The check constraint is making
surethere is a "plan" before there is a "contract", yet pg_dump is trying to load the contract table before there is
anythingin the plan table. This may seem weird at first, as the plan table is referencing the contract table's PK. Our
intentionis to make sure that EVERY contract has at least one plan.  

Please feel free to ask me about this script and associated files. You will most likely want to edit the Test file, and
makeit point to the correct HEAD/7.5 run environment. I do not specify PGPORT/PGHOST etc in the file, so you will need
tomake sure you have those set in your environment.  

Jonathan Scott

--
Jonathan Scott, Programmer, Vanten K.K.
jwscott@vanten.com    Tel: 03-5919-0266
http://www.vanten.com    Fax: 03-5919-0267


Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: CVS HEAD compile warning
Next
From: Gavin Sherry
Date:
Subject: Tablespaces