Peter Bartholdsson wrote:

[H]ow would [limiting recursion depth] not be enough?


Limiting the recursion depth would be sufficient to prevent infinite loops. But it seems overly restrictive.

Consider the following case:

   CREATE TABLE list(
     id INTEGER PRIMARY KEY,
     next INTEGER REFERENCES list,
     data BLOB
   );

The table above lets you look up BLOB data given an integer
ID.  It also keeps all of the entries on a linked list.
(Never mind why you would want to do this - it comes up.)
Suppose that when you delete an entry you also want to
delete all subsequent entries in the list.  We have:

   CREATE TRIGGER deep BEFORE DELETE ON list BEGIN
       DELETE FROM list WHERE id=old.next;
   END;

This trigger is guaranteed to terminate because it will
eventually run out of entries to delete.  But given any
recursion limit, we can always construct a case where
the trigger will want to run longer than the limit.

So do we put recursion limits on UPDATE and INSERT triggers
only and let DELETE triggers run as long as they like?
That works as far as I know, but it seems kind of arbitrary.

Surely somebody else has been down this road before me and
can offer a little guidance?

--
D. Richard Hipp -- [EMAIL PROTECTED] -- 704.948.4565



Reply via email to