Re: [sqlite] How to detect existing TRANSACTION before performingSAVEPOINT?

2011-03-17 Thread Afriza N. Arief
On Thu, Mar 17, 2011 at 8:05 PM, Richard Hipp  wrote:

> On Thu, Mar 17, 2011 at 12:30 AM, Igor Tandetnik  >wrote:
>
> > Afriza N. Arief  wrote:
> > > What is the correct way of detecting existing transaction?
> >
> > sqlite3_get_autocommit
> >
>
> Correct.  Or, you could just always use SAVEPOINT which works the same as
> BEGIN if you are not already in a transaction.
>
>
My understanding is that using [SAVEPOINT's automatic] BEGIN is more prone
to deadlocks than BEGIN IMMEDIATE if there are many read-then-write
transactions; and SAVEPOINT only allows automatic BEGIN DEFERRED. This is
because multiple transactions may hold the SHARED locks and multiple of them
may then tries to get RESERVED in the same transaction. I am not using WAL
and want to rely on sqlite3_busy_timeout() instead of using more complex
error handling.

This understanding leads me to always use BEGIN IMMEDIATE for
read-then-maybe-write transactions as well as read-then-always-write
transactions.

Is my understanding correct?

Regards,

Afriza N. Arief
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] How to detect existing TRANSACTION before performingSAVEPOINT?

2011-03-17 Thread Richard Hipp
On Thu, Mar 17, 2011 at 12:30 AM, Igor Tandetnik wrote:

> Afriza N. Arief  wrote:
> > What is the correct way of detecting existing transaction?
>
> sqlite3_get_autocommit
>

Correct.  Or, you could just always use SAVEPOINT which works the same as
BEGIN if you are not already in a transaction.



> --
> Igor Tandetnik
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] How to detect existing TRANSACTION before performingSAVEPOINT?

2011-03-16 Thread Igor Tandetnik
Afriza N. Arief  wrote:
> What is the correct way of detecting existing transaction?

sqlite3_get_autocommit
-- 
Igor Tandetnik

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users