Foreign Key Deferrable Misunderstanding or Bug?

Поиск
Список
Период
Сортировка
От Paul Rogers
Тема Foreign Key Deferrable Misunderstanding or Bug?
Дата
Msg-id 4A7B48D6.7000306@sparkbase.com
обсуждение исходный текст
Ответы Re: Foreign Key Deferrable Misunderstanding or Bug?
Re: Foreign Key Deferrable Misunderstanding or Bug?
Список pgsql-general
Why does the attached script fail with a foreign key constraint violation?


Privileged/Confidential Information may be contained in this message.

If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you
maynot copy or deliver this message to anyone. In such case, you should destroy this message and kindly notify the
senderby reply email. Please advise immediately if you or your employer does not consent to Internet email for messages
ofthis kind. Opinions, conclusions and other information in this message that do not relate to the official business of
myfirm shall be understood as neither given nor endorsed by it. 
DROP TABLE IF EXISTS test_fk_def1 CASCADE;
CREATE TABLE test_fk_def1 (id SERIAL PRIMARY KEY, name TEXT);

DROP TABLE IF EXISTS test_fk_def2 CASCADE;
CREATE TABLE test_fk_def2 (id SERIAL PRIMARY KEY,
  fk INTEGER REFERENCES test_fk_def1(id)
    ON UPDATE CASCADE
    ON DELETE RESTRICT
    DEFERRABLE INITIALLY DEFERRED);

INSERT INTO test_fk_def1 (name) VALUES ('one');
INSERT INTO test_fk_def2 (fk) SELECT id FROM test_fk_def1
    ORDER BY id DESC LIMIT 1;

BEGIN;
-- this should be unnecessary since it is initially deferred, but it doesn't
-- work with or without it
SET CONSTRAINTS test_fk_def2_fk_fkey DEFERRED;
DELETE FROM test_fk_def1; -- why does this fail?
DELETE FROM test_fk_def2;
COMMIT;

В списке pgsql-general по дате отправления:

Предыдущее
От: Michael Glaesemann
Дата:
Сообщение: Re: Empty Updates, ON UPDATE triggers and Rules
Следующее
От: Merlin Moncure
Дата:
Сообщение: Re: Empty Updates, ON UPDATE triggers and Rules