I've taken a further look. The main problem is that the cursor number is
hardcoded, as can be seen 
in the following example (A delete trigger causing further deletes.)

29|OpenRead|3|6|
30|SetNumColumns|3|1|
31|Rewind|3|38|
32|Column|3|0|
33|Rowid|0|0|
34|Ne|355|37|collseq(BINARY)
35|Rowid|3|0|
36|FifoWrite|0|0|
37|Next|3|32|
38|Close|3|0| 

The OpenRead, SetNumColumns, Rewind, Column, Rowid, Next and Close commands
in the example depend 
on fixed cursor identifiers. To be able to call a trigger recursively I'd
need to modify the opcodes to 
support passing the appropriate cursor identifiers around on the stack like
parameters in a C routine.

My thinking was to allow negative cursor identifiers to indicate the
location of the real cursor as an
offset into the VDBE stack. This of course would mean, that the cursors
oldIdx, newIdx need to be
pushed onto the stack by the caller before the gosub and popped afterwards.
In addition an opcode may 
be required to allocate a new cursor identifier dynamically and push it onto
the stack, if the trigger 
requires new cursors.

Do you see any possibility of supporting this without breaking other things?

Mike

-----Ursprüngliche Nachricht-----
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Gesendet: Donnerstag, 26. April 2007 21:05
An: [email protected]
Betreff: Re: [sqlite] Recursive triggers

"Michael Ruck" <[EMAIL PROTECTED]> wrote:
> Hello,
> 
> I've been looking into the way triggers are implemented and was 
> thinking about adding support for recursive triggers, as they would 
> simplify my current project dramatically. What was/is the reason to leave
them out?
> 
> My thoughts were adding recursive triggers by calling them like 
> subroutines (via the VDBE Gosub and Return) on demand. I haven't 
> thought this through, but wanted to ask if there are limitations or 
> blocking points in doing recursive triggers this way? I know that the 
> VDBE stack is limited and queries with very deep triggers may abort, if
the stack is overflowed.
> 
> Is the function sqlite3CodeRowTrigger, the only place I'd need to 
> adjust to support recursive triggers?
> 

Recursive triggers are hard to implement correctly.
But if you think you can do so by tweaking sqlite3CodeRowTrigger, then by
all means give it a whirl.

--
D. Richard Hipp  <[EMAIL PROTECTED]>


----------------------------------------------------------------------------
-
To unsubscribe, send email to [EMAIL PROTECTED]
----------------------------------------------------------------------------
-



-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to