> whom to trust?

Trust Kees. Borgan's thought about keeping the lock and transaction
management inside sqlite3_exec is incorrect.

> as for Kees Nuyt reply, did you toke int account that "select
> last_insert_rowid() "
> and insert query combined in single query and executed via single call
> of sqlite3_exec()?

Actually it depends on particular implementation of sqlite3_exec.
Kees' reply is general and it would stand if sqlite3_exec didn't
acquire connection's mutex and let individual statements acquire mutex
as necessary. But as I see in SQLite sources sqlite3_exec does acquire
connection's mutex, so nothing can be executed in between statements.
Thus if you execute this line as one call to sqlite3_exec then it
won't suffer from threading.


Pavel

On Tue, Nov 16, 2010 at 8:08 AM, Ruslan Mullakhmetov
<r.mullakhme...@tools4brokers.com> wrote:
>  i got following contradictory replies to my question
>
>> if i execute query like " insert into tbl( filed ) VALUES ( 1 ); Select
>> last_insert_rowid() as li;" would be it atomic? or  it anyway would suffer
>> from threads?
>
> from borgan:
>> Hi, i think this will probably be "atomic".
>> What i mean is the transaction will aquire EXCLUSIVE lock (because of
>> the insert command) and it will keep this lock until commit, which
>> takes place after the last select and last semicolon.
>>
>> So i believe no other threads should be able to do anything with your
>> db until the whole query finishes.
> and from Kees Nuyt:
>> The last_insert_rowid() function returns the ROWID of the last row
>> insert from the database connection which invoked the function.
>> So, yes, it suffers from threads if the threads use the same
>> database connection.
>
> whom to trust?
>
> as for Kees Nuyt reply, did you toke int account that "select
> last_insert_rowid() "
> and insert query combined in single query and executed via single call
> of sqlite3_exec()?
>
> BR, RM
> _______________________________________________
> 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