Tom,

I have another instance of a possible function being used as a check constraint: a 
function that makes sure there is one row, and only one row in a table. 

At table creation, and the creation of the constraint, there are no rows in the table. 
So, even if the constraint is a valid one to have, it will fail. 

We use check constraint functions in a few places, and they work just fine for us 
(minus the case of trying to restore the database from a pg_dump archive). Is it 
impossible to treat check constraints similar to other constraints and make them 
deferrable, specifically in the restoration from a pg_dump archive? Is there a 
specific reason check constraints are handled differently from other constraints?

Jonathan Scott


On Thu, 26 Feb 2004 08:54:59 -0500
Tom Lane <[EMAIL PROTECTED]> wrote:

> Jonathan Scott <[EMAIL PROTECTED]> writes:
> > The functions and tables create just fine, but when it gets to the
> > COPY part of the sql script, it tries to load tables in what really is
> > the wrong order. The check constraint is making sure there is a "plan"
> > before there is a "contract", yet pg_dump is trying to load the
> > contract table before there is anything in the plan table.
> 
> Shouldn't you be using a foreign key for that?
> 
> I don't see any reasonable way that pg_dump can be expected to
> understand that a check constraint expresses a relationship between two
> tables.  The semantics of check constraints aren't right for it anyway.
> 
> All else being equal, I think the tables will be loaded in OID order,
> so a possible workaround is to create the plan table first.  But an
> FK seems like a better answer.
> 
>                       regards, tom lane
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
> 


-- 
Jonathan Scott, Programmer, Vanten K.K.
[EMAIL PROTECTED]       Tel: 03-5919-0266
http://www.vanten.com   Fax: 03-5919-0267

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Reply via email to