Re: [GENERAL] Trouble with recursive trigger

2005-11-20 Thread Justin Hawkins
On Thu, Nov 17, 2005 at 11:45:07PM -0500, Tom Lane wrote: > This has a couple of problems: > > 1. You can't delete a post's children before deleting the post itself, > because of the REFERENCES constraint. I'm not entirely sure why your > original formulation of the trigger didn't hit that failu

Re: [GENERAL] Trouble with recursive trigger

2005-11-17 Thread Tom Lane
Justin Hawkins <[EMAIL PROTECTED]> writes: > I'm having trouble with the DELETE. When deleting a row three things > need to happen: > o recursively DELETE all children posts to preserve data integrity > o decrement the number of replies of the parent post (if it exists) > o delete itself This has

Re: [GENERAL] Trouble with recursive trigger

2005-11-16 Thread Justin Hawkins
On Wed, Nov 16, 2005 at 07:43:16AM +0100, Martijn van Oosterhout wrote: > Just a thought, maybe it has something to do with the UPDATE updating a > row where the trigger is running. So, think of the execution like > this: > > # DELETE FROM post WHERE id = 3002; > trigger> DELETE FROM post WHERE p

Re: [GENERAL] Trouble with recursive trigger

2005-11-15 Thread Martijn van Oosterhout
On Wed, Nov 16, 2005 at 11:45:45AM +1030, Justin Hawkins wrote: > Hi all, > > I am writing a bulletin board style system, which stores posts in a > hierachy. > However, only the ultimate child (the post with no children posts) > gets deleted, despite the debugging NOTICE's seeming to indicate t

[GENERAL] Trouble with recursive trigger

2005-11-15 Thread Justin Hawkins
Hi all, I am writing a bulletin board style system, which stores posts in a hierachy. Each post has a parent (or NULL for a top level post). For efficiency, I'm storing a number of replies on each post, which shows the total replies a post has, including all sub (and sub sub, and sub sub sub etc