Search Postgresql Archives

Re: Is this correct behavior for ON DELETE rule?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Rick Schumeyer" <rschumeyer@xxxxxxxx> writes:
> -- delete to item and book instead of bookview
> create rule bookviewdel as on delete to bookview do instead (
>       delete from book where id=old.id;
>       delete from item where id=old.id;
> );

This is an ancient gotcha: as soon as you delete the book row, there is
no longer any such entry in the bookview view ... and "old.id" is
effectively a reference to the bookview view, so the second delete
finds no matching rows.

If you can reasonably turn the view into a LEFT JOIN in one direction or
the other, then a workaround is to delete from the nullable side first.

			regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux