On Dec 3, 2004, at 4:04 PM, D. Richard Hipp wrote:

SQLite does not currently support recursive triggers.
On of the main reasons for not supporting recursive
triggers is that disallowing recursive triggers was
seen as the easiest way to avoid infinite loops like
this:

   CREATE TRIGGER loop AFTER UPDATE OF table1
   BEGIN
     UPDATE table1 SET cnt=(cnt+1)%100 WHERE rowid=old.rowid;
   END;
   UPDATE table1 SET cnt=1 WHERE rowid=1;  -- Infinite loop

By disallowing recursive triggers, SQLite avoids the
infinite loop above.  But there are useful things one
could do with recursive triggers that do not involve
infinite loops.  I would like to relax the constraint
in SQLite and allow some support for recursive triggers
as long as the recursive triggers do not cause an
infinite loop.  But I'm not sure how to do about it?

Question:  What do other RDBMSes do with triggers that
form infinite loops?  Does anybody know?

Dynamic languages typically have a hard coded 'stack limit'. I think this is what Oracle does, see:
http://www.oreilly.com/catalog/ordevworkbook/chapter/ch16s.html #8


Question:  Can anybody suggest a way of providing support
for recursive triggers which also guarantees that
every SQL statement will eventually complete?

Use a 'stack limit' ;)
Report an error when the stack limit is reached. Unfortunately I don't know if how to implement or if this is even a feasible solution for SQLite.


Best,
Charlie



Reply via email to