"Scott Hess" <[EMAIL PROTECTED]> wrote:
> >
> > Many (most?) of the other teams using SQLite in situations
> > similar to Gears have their own separate methods for starting,
> > committing, and rolling back transactions.  They don't run
> > BEGIN, COMMIT, or ROLLBACK statements - they call their own
> > built-in methods which in turn runs BEGIN, COMMIT, and
> > ROLLBACK on the user's behalf.  If you used this approach,
> > then you could easily revise your method to call BEGIN IMMEDIATE
> > instead of just BEGIN.  You could also do the BUSY retry
> > handling that Ken suggests.
> Indeed, there has been past discussion about whether we should do some
> sort of transaction API which integrated with the language (for
> instance, automating ROLLBACK on uncaught exceptions).  It may be that
> this is the time for that to come back to the fore.

Exactly.  Notice how the TCL bindings do this.  If "db" is
the object that is your database connection then you do:

    db transaction {
        # lots of other code.
        db eval {--SQL} ...
        # more code

And if an exception gets thrown inside the {...} and doesn't
get caught before leaving the {...} the transaction is 
automatically rolled back.  Furthermore, you can nest the
"db transaction" implementations:

    db transaction {
        db transaction {
           db transaction {

The BEGIN, ROLLBACK, and/or COMMIT only happen on the outermost
"transaction".  Of course, it is kind of silly to nest 
as shown above.  But this is useful, for example, when each
"db transaction" is really in a separate procedure and the
procedures are nested.

This is all relatively easy to implement for TCL where every
string is also a lambda procedure.  It isn't clear to me if
or how you could do the same in javascript.  But if you have
a javascript guru who can pull it off, it would be neat.

D. Richard Hipp <[EMAIL PROTECTED]>

To unsubscribe, send email to [EMAIL PROTECTED]

Reply via email to