Re: [sqlite] Correct use of sqlite3 API (release locks)

2007-01-17 Thread drh
Brodie Thiesfield <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I have multiple processes using a single database for both read and
> write. I want to ensure that my interpretation of the v3 API spec is
> correct. In particular, I want to ensure that all processes lock the
> database for the minimum time possible and release the lock as soon as
> they have finished processing the SQL statement. Are locks released
> automatically on error/done, or manually by the sqlite3_reset() call, or
> some other function?
> 

You should call sqlite3_reset() (or sqlite3_finalize()) to make sure
locks are released.  They might have been released prior to that point,
but not always.
--
D. Richard Hipp  <[EMAIL PROTECTED]>


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] Correct use of sqlite3 API (release locks)

2007-01-17 Thread Brodie Thiesfield
Hi,

I have multiple processes using a single database for both read and
write. I want to ensure that my interpretation of the v3 API spec is
correct. In particular, I want to ensure that all processes lock the
database for the minimum time possible and release the lock as soon as
they have finished processing the SQL statement. Are locks released
automatically on error/done, or manually by the sqlite3_reset() call, or
some other function?

I currently use the following logic in my internal DB layer.

  if sql not prepared
 sqlite3_prepare_v2()

  sqlite3_bind_* ...

  rc = sqlite3_step()
  while rc == SQLITE_ROW
 process row (sqlite3_column_*) ...
 rc = sqlite3_step()

  if rc != SQLITE_DONE
 process error

  sqlite3_reset()

Will this release the locks on the database (assuming no transactions?)
by the end of the function?

Regards,
Brodie


-
To unsubscribe, send email to [EMAIL PROTECTED]
-