Re: [sqlite] Lock and transaction

2011-11-04 Thread Paxdo Presse

Great. Thanks to both.

(and sorry for my bad english)

Le 5 nov. 2011 à 00:05, Petite Abeille a écrit :

> 
> On Nov 4, 2011, at 11:59 PM, Paxdo Presse wrote:
> 
>> Are we sure that another process is not going to create another row between 
>> my "INSERT" and "SELECT LAST ROWID"? 
> 
> yes
> 
>> The "LAST ROWID" is it for sure the id of "INSERT INTO" of the transaction?
> 
> yes
> 
> ___
> 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


Re: [sqlite] Lock and transaction

2011-11-04 Thread Petite Abeille

On Nov 4, 2011, at 11:59 PM, Paxdo Presse wrote:

> Are we sure that another process is not going to create another row between 
> my "INSERT" and "SELECT LAST ROWID"? 

yes

> The "LAST ROWID" is it for sure the id of "INSERT INTO" of the transaction?

yes

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


Re: [sqlite] Lock and transaction

2011-11-04 Thread Richard Hipp
On Fri, Nov 4, 2011 at 6:59 PM, Paxdo Presse  wrote:

>
> Hello,
>
> a question from beginner please :
>
> In this transaction (with wal-mode) :
>
>
> BEGIN TRANSACTION
>
> INSERT INTO
>
> SELECT last_insert_rowid()
>
> COMMIT
>
>
> Are we sure that another process is not going to create another row
> between my "INSERT" and "SELECT LAST ROWID"?
>

Yes.  Isolation in SQLite is SERIALIZABLE.



> The "LAST ROWID" is it for sure the id of "INSERT INTO" of the transaction?
>

Yes.  Actually, this is true even without the BEGIN...COMMIT.  The
last_insert_rowid() is the rowid of the most recent insert on the same
database connection.



>
> In fact, is the lock that starts with INSERT is set to COMMIT? Or the
> write lock is it only when the INSERT? (so no lock between INSERT and
> COMMIT)
>

I do not exactly understand the question, so I'm guessing:  The lock that
is acquire at INSERT is held until COMMIT.



>
> Thank you
>
> olivier
> ___
> 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