Will Leshner wrote:
On 4/17/06, Michael Ekstrand <[EMAIL PROTECTED]> wrote:

So, if someone could enlighten me as to the defined behavior of
sqlite3_last_insert_rowid with regards to transactions, I would be most
grateful.

The last insert id is a property of a connection. So there is no way
that one connection can accidently get the last row inserted by
another connection.

But when is the ROWID generated? Is it generated when the INSERT is evaluated/executed, or when it is committed?

Take the following scenario:

Conn 1: BEGIN TRANSACTION
Conn 1: INSERT...
Conn 1: sqlite3_last_insert_rowid()
Conn 2: INSERT... (same table as Conn1 just did)
Conn 2: COMMIT
Conn 1: COMMIT

Now, who got the "next" ROWID? Conn 1 or Conn 2? What did sqlite3_last_insert_rowid() return to Conn 1?

I'm sorry if I'm being dense; I'm just trying to understand the exact behavior in this case.

- Michael

--
mouse, n: a device for pointing at the xterm in which you want to type.
        -- Fortune
Visit me on the Web: http://www.elehack.net

Reply via email to