Re: constraint deferred but fails?
От | Ron |
---|---|
Тема | Re: constraint deferred but fails? |
Дата | |
Msg-id | fcf3589d-7f24-c12a-18d2-54cac14ea1c0@gmail.com обсуждение исходный текст |
Ответ на | constraint deferred but fails? (Nagy László Zsolt <gandalf@shopzeus.com>) |
Список | pgsql-admin |
On 1/24/19 12:35 AM, Nagy László Zsolt wrote:
Deferring a constraint doesn't mean "disappearing" the constraint; it just means... deferring it until later (i.e. commit time). It's only purpose is to allow your code to delete from doc.display_mode before deleting from book . But you do have to delete from book at some point in the transaction.
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=>
Deferring a constraint doesn't mean "disappearing" the constraint; it just means... deferring it until later (i.e. commit time). It's only purpose is to allow your code to delete from doc.display_mode before deleting from book . But you do have to delete from book at some point in the transaction.
--
Angular momentum makes the world go 'round.
Angular momentum makes the world go 'round.
В списке pgsql-admin по дате отправления: