Re: constraint deferred but fails?

From: Shreeyansh Dba <shreeyansh2014(at)gmail(dot)com>
To: Nagy László Zsolt <gandalf(at)shopzeus(dot)com>
Cc: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: constraint deferred but fails?
Date: 2019-01-24 07:08:57
Message-ID: CAGDYbUN3rm5fThzoeoxEo3F0VwK_MjBkqYXTC1BwcRafKAHujg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

To automate this, you could define the foreign key constraint with ON
DELETE CASCADE.
So when deleting first delete child rows and then parent.

Thanks & Regards,
*Shreeyansh DBA Team*
www.shreeyansh.com

On Thu, Jan 24, 2019 at 12:05 PM Nagy László Zsolt <gandalf(at)shopzeus(dot)com>
wrote:

>
> Hello,
>
> I have deferred the only fk constraint to this table inside a
> transaction, but I still cannot delete rows from it.
>
> How is that possible?
>
>
> master=> ALTER TABLE doc.display_mode disable trigger user;
> ALTER TABLE
> master=> BEGIN;
> BEGIN
> master=> SET CONSTRAINTS doc.fk_book_display_mode_id DEFERRED;
> SET CONSTRAINTS
> master=> DELETE FROM doc.display_mode;
> ERROR: update or delete on table "display_mode" violates foreign key
> constraint "fk_book_display_mode_id" on table "book"
> DETAIL: Key (id)=(1) is still referenced from table "book".
> master=>
>
>
>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Cory Nemelka 2019-01-24 16:34:02 Re: Creation of temporary tables on a publisher
Previous Message David G. Johnston 2019-01-24 07:08:47 Re: constraint deferred but fails?