Richard,

>From the same link you gave:

"Furthermore, if a BEFORE trigger modifies or deletes a row, then it
is undefined whether or not AFTER triggers that would have otherwise
run on those rows will in fact run."

I believe in case of recursive triggers turned on this statement is
incorrect and AFTER triggers have to run recursively, haven't they?
And btw, does it mean that if update issued is touching several rows
and AFTER UPDATE trigger on first row deleted all others then AFTER
UPDATE trigger will be called on deleted rows anyway? What about
recursive AFTER DELETE trigger? Will it be called before AFTER UPDATE
trigger in this case?


Pavel

On Tue, Nov 24, 2009 at 2:49 PM, D. Richard Hipp <d...@hwaci.com> wrote:
>
> On Nov 24, 2009, at 1:15 PM, Vasu Nori wrote:
>
>> wondering if this is a known issue in 3.6.20.
>
> http://www.sqlite.org/lang_createtrigger.html#undef_before
>
> "If a BEFORE UPDATE or BEFORE DELETE trigger modifies or deletes a row
> that was to have been updated or deleted, then the result of the
> subsequent update or delete operation is undefined."
>
>>
>> create table t1(_id integer primary key, v integer, d integer);
>> CREATE TRIGGER t1_trig BEFORE UPDATE ON t1
>>  BEGIN
>>    update t1 SET v=OLD.v+1 WHERE NEW._id=OLD._id AND NEW.d!= OLD.d;
>>  END;
>>
>> insert into t1 values(1, 1,0);
>> update t1  set d= 2  where _id = 1;  <-- expected "v" = 2
>> select * FROM t1;   <--  shows "v" = 1
>>
>> this works fine in versions upto 3.6.16..
>>
>> in 3.6.20, trigger does the right thing and updates the table. but
>> the data
>> is not reflected in the table after the update statement is
>> complete. I
>> didn't look at the vdbe.
>> anyone seen this behavior?
>>
>> thanks
>> _______________________________________________
>> sqlite-users mailing list
>> sqlite-users@sqlite.org
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
> D. Richard Hipp
> d...@hwaci.com
>
>
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to