On Sat, Jul 16, 2016 at 02:19:37PM +0800, Hilaire wrote:
> In a multi-thread context use of Sqlite, I try to find out how one will
> fetch securely the automatically last row index of a Primary key.
> 
> The problem seems to be that between the insert of rows in a table and
> the moment you request the last row id, you may have another insert from
> another thread in the same database.

Hi Hilaire,

See http://www.sqlite.org/c3ref/last_insert_rowid.html, especially
last paragraph:

  If a separate thread performs a new INSERT on the same database connection
  while the sqlite3_last_insert_rowid() function is running and thus changes the
  last insert rowid, then the value returned by sqlite3_last_insert_rowid() is
  unpredictable and might not equal either the old or the new last insert rowid.

Pierce

Reply via email to