pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Deferred Constraints Issues
2+ messages / 2 participants
[nested] [flat]

* Deferred Constraints Issues
@ 2008-03-25 20:10  kevin kempter <kevin@kevinkempterllc.com>
  0 siblings, 1 reply; 2+ messages in thread

From: kevin kempter @ 2008-03-25 20:10 UTC (permalink / raw)
  To: pgsql-admin

Hi List;

I've placed this sql in a script:

psql my_db <<!
begin;
SET CONSTRAINTS ALL DEFERRED ;
delete from account where 1 = 1;
delete from cust where 1 = 1;
delete from cust_type where 1 = 1;
delete from cust_orders where 1 = 1;
commit;
!

The tables have relationships, however I expect the 'SET CONSTRAINTS  
ALL DEFERRED' to defer constraint checks.  When I run the script I get  
this:


BEGIN
SET CONSTRAINTS
ERROR:  update or delete on table "account" violates foreign key  
constraint "account_rel" on table "cust_type"
DETAIL:  Key (account_id)=(1) is still referenced from table  
"cust_type".
ERROR:  current transaction is aborted, commands ignored until end of  
transaction block
ERROR:  current transaction is aborted, commands ignored until end of  
transaction block
ERROR:  current transaction is aborted, commands ignored until end of  
transaction block
ROLLBACK


Am I doing something wrong ? Or, is the 'SET CONSTRAINTS ALL DEFERRED'  
not working properly ?


Thanks in advance...






^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Deferred Constraints Issues
@ 2008-03-25 20:27  Stephan Szabo <sszabo@megazone.bigpanda.com>
  parent: kevin kempter <kevin@kevinkempterllc.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Stephan Szabo @ 2008-03-25 20:27 UTC (permalink / raw)
  To: kevin kempter <kevin@kevinkempterllc.com>; +Cc: pgsql-admin

On Tue, 25 Mar 2008, kevin kempter wrote:

> I've placed this sql in a script:
>
> psql my_db <<!
> begin;
> SET CONSTRAINTS ALL DEFERRED ;
> delete from account where 1 = 1;
> delete from cust where 1 = 1;
> delete from cust_type where 1 = 1;
> delete from cust_orders where 1 = 1;
> commit;
> !
>
> The tables have relationships, however I expect the 'SET CONSTRAINTS
> ALL DEFERRED' to defer constraint checks.

IIRC it's defined to only defer constraints created with DEFERRABLE and/or
INITIALLY DEFERRED. The default is NOT DEFERRABLE.



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2008-03-25 20:27 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-03-25 20:10 Deferred Constraints Issues kevin kempter <kevin@kevinkempterllc.com>
2008-03-25 20:27 ` Stephan Szabo <sszabo@megazone.bigpanda.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox