The 12-message 2005-01-04 discussion with subject "Is
there any way to enable recursive triggers?"<1> ends
with concerns about infinite recursion causing Sqlite
to crash without rollback (example email at bottom).
First question: Because all non-SELECT sql always
takes place within a transaction<2>, won't the
transaction always be safely rolled back, in effect,
by the crash? If yes, crashes are (temporary)
show-stoppers, yes, but as Lothar_Märkle pointed out
below, the sqlite db file is not shared between
different users and so a crash is not as bad as they
are in a multiuser dbmses. I would argue that having
the power of recursion is worth the risk of infinite
loop.
Second qn: As a probably incredibly naive 1st try to
enable recursion, I made the fire_this = 1; assignment
unconditional in sqlite/src/trigger.c by adding the
two comments shown in /*** ***/:
/*** commented out 10/5/06 gh for testing only
(unsafe). if( !pS ){ ***/
fire_this = 1;
/*** } ***/
#if 0 /* Give no warning for recursive triggers.
Just do not do them */
else{
sqlite3ErrorMsg(pParse, "recursive triggers
not supported (%s)",
p->name);
return SQLITE_ERROR;
}
#endif
but, alas, Segmentation fault:
sqlite> select * from sqlite_master;
table|t1|t1|2|CREATE TABLE t1 (intcol int, textcol
text, updcnt int)
trigger|trig1|t1|0|CREATE TRIGGER trig1 after update
on t1 when old.updcnt<100 begin update t1 set
updcnt=updcnt+1; end
sqlite> select * from t1;
1|a|2
sqlite> update t1 set intcol=1;
Segmentation fault
Advice on how to pursue enabling recursion? My C is
rusty. I prefer Linux but also run Windows.
TIA,
George Herson
<1>http://marc.theaimsgroup.com/?l=sqlite-users&w=2&r=1&s=recursion&q=b
<2>http://sqlite.org/lang_transaction.html has: "Any
command that changes the database (basically, any SQL
command other than SELECT) will automatically start a
transaction if one is not already in effect."
List: sqlite-users
Subject: [sqlite] recursive triggers thoughts
From: Lothar_Märkle <lothar () netpioneer ! de>
Date: 2005-01-15 18:30:45
Message-ID: 20050115183044.GA28894 () netpioneer ! de
[Download message RAW]
I recently step over a problem where recursive
triggers are really
helpfull, and realized that my idea for propagating
changes along a tree
structure won't work without recursive triggers
obviously.
In short, I think the server sql engines implement
recursion limits because
they are mulit-user. So, if one creates accidentally
an endless loop,
the whole server must not be taken down(at least no
db-admin must be
called...) and the other applications can continue.
There are other
ways for DOS, of course, too.
Mostly, I think, a sqlite db-file is not shared
between different users, so
*this* problem of endless recursive triggers ist not
present often.
thanks for this nice pice of software,
lothar
List: sqlite-users
Subject: Re: [sqlite] Is there any way to enable
recursive triggers?
From: Jay <cupycake_jay () yahoo ! com>
Date: 2005-01-04 20:05:36
Message-ID: 20050104200536.72094.qmail () web53803 !
mail ! yahoo ! com
One poster mentioned some OS's will not let you know
when you're
out of RAM (malloc() never fails). That might be
difficult!
--- Darren Duncan <[EMAIL PROTECTED]> wrote:
> If possible, SQLite should also manage memory so
that it has the
> resources necessary to roll back the infinite
recursion and carry on
> as normal; SQLite should not crash from an infinity
error.
=====
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------