Re: BUG #3696: FK integrity check bypassed using rules.

Поиск
Список
Период
Сортировка
От Pierre-Yves Strub
Тема Re: BUG #3696: FK integrity check bypassed using rules.
Дата
Msg-id 592647410710250955k98ebf33u23d90dc24d0f2ad1@mail.gmail.com
обсуждение исходный текст
Ответ на Re: BUG #3696: FK integrity check bypassed using rules.  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
On 10/25/07, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Yes, a poorly designed rule can invalidate all kinds of expectations
> about behavior.  This isn't a bug in my humble opinion.

         Yes, this was my first impression.

         I was just surprised because of this: the script

CREATE TABLE data (
  id INTEGER PRIMARY KEY
);

CREATE TABLE ref (
  id INTEGER PRIMARY KEY,
  ref_id INTEGER NULL REFERENCES data(id) ON DELETE CASCADE
);

CREATE RULE ref_delete_rule
AS ON DELETE TO ref
DO INSTEAD NOTHING;

INSERT INTO data VALUES (1);
INSERT INTO ref  (id, ref_id) VALUES(2, 1);

DELETE FROM data;

       gives for the DELETE statement:

ERROR:  referential integrity query on "data" from constraint
"ref_ref_id_fkey" on "ref" gave unexpected result
HINT:  This is most likely due to a rule having rewritten the query.

        But if I change the rule by adding a "WHERE True" to it:

CREATE RULE ref_delete_rule
AS ON DELETE TO ref WHERE True
DO INSTEAD NOTHING;

        The integrity is violated. In this sense, this could reveal a
bug (unless postgresql states clearly that it uses a best effort
algorithm when dealing with rewrite rules that can potentially
rewrites auto-generated statements)

        I agree, this is not a big deal.

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: BUG #3697: utf8 issue: can not reimport a table that was successfully exported.
Следующее
От: "Marc Mamin"
Дата:
Сообщение: Re: BUG #3697: utf8 issue: can not reimport a table that was successfully exported.