On Tue, Jun 25, 2013 at 11:49:00PM +0100, Simon Slavin scratched on the wall:
> 
> On 25 Jun 2013, at 11:45pm, Yuriy Stelmakh <yuriy...@gmail.com> wrote:
> 
> > I assumed that commit would take care of sync, but because my
> > statement was never finalized/reset after last use, it didn't it
> > seems..
> 
> You always need to _finalize().  Getting the data you asked for is not
> the end of the job.  You have to _finalize() in order to let SQLite
> clear up after the statement (which does more than just unlock the file,
> it also does things about the memory your application uses).

  _finalize() isn't the only function that does this.  You can also
  call _reset() to, well... reset the statement.  This will clear all
  the locks and make it clear to the SQLite engine that you're done
  with the current execution of the statement, but will leave the
  statement ready to go for another execution.

> So get used to this: for every _prepare() do a _finalize().  As
> soon as practical.

  That's true, but it isn't the whole story, since there isn't a fixed
  relationship between _prepare() and statement executions.  Using
  _reset() to clear the statement is perfectly acceptable. 
  
  Your other point still stands, however... as soon as _step() returns
  SQLITE_DONE, it is best to call _reset() before doing anything else.
  _finalize() can also be called if you know you're done with the
  statement.

   -j

-- 
Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"Intelligence is like underwear: it is important that you have it,
 but showing it to the wrong people has the tendency to make them
 feel uncomfortable." -- Angela Johnson
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to