REVIEW: ALTER TABLE ... ADD FOREIGN KEY ... NOT ENFORCED - Mailing list pgsql-hackers

From Marko Tiikkaja
Subject REVIEW: ALTER TABLE ... ADD FOREIGN KEY ... NOT ENFORCED
Date
Msg-id 4D3C6A75.9050204@cs.helsinki.fi
Whole thread Raw
In response to Re: ALTER TABLE ... ADD FOREIGN KEY ... NOT ENFORCED  (Simon Riggs <simon@2ndQuadrant.com>)
Responses Re: REVIEW: ALTER TABLE ... ADD FOREIGN KEY ... NOT ENFORCED  (Simon Riggs <simon@2ndQuadrant.com>)
List pgsql-hackers
Hi Simon,

On 1/14/2011 1:15 PM, Simon Riggs wrote:
> Patch to implement the proposed feature attached, for CFJan2011.

Overall, I think the patch looks good, but I found some problems with 
it.  In tablecmds.c you have:

+       if (found && con->contype == CONSTR_FOREIGN && !con->convalidated)

which I don't think is correct, and my tests seem to agree; the actual 
validation doesn't happen at all.  Changing that to CONSTRAINT_FOREIGN 
makes the validation part work, but then I get:

ERROR:  cache lookup failed for constraint 16419

when trying to drop the table and the regression tests fail because of 
this.  Also having a regression test where the validation fails seems 
like a good idea.

Another problem I found is that psql doesn't indicate in any way that a 
FOREIGN KEY constraint is not validated yet.

I also think that having the function for getting a list of values that 
violate the constraint would be helpful.  Any particular reason why you 
decided to omit it from this patch?


Regards,
Marko Tiikkaja


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Bug in pg_describe_object, patch v2
Next
From: Simon Riggs
Date:
Subject: Re: REVIEW: ALTER TABLE ... ADD FOREIGN KEY ... NOT ENFORCED