On 6/13/2014 1:27 PM, Richard Hipp wrote:
On Fri, Jun 13, 2014 at 1:20 PM, Eric Rubin-Smith <eas....@gmail.com> wrote:
If I say sqlite_bind_text(...SQLITE_STATIC), I am promising that the buffer
is going to stick around for a while. How long am I promising that it will
stick around? Til the next statement reset()? Til the statement
finalize()? Til the database close()?
Until the parameter you are binding against cannot long be used. Which
will be either (1) sqlite3_reset() or (2) sqlite3_finalize() or (3) the
next sqlite3_bind() against the same parameter, whichever comes first.
I believe it's possible, though unusual, to step, then reset, then step
again without rebinding, at which point the previous parameter value
will be used and must remain alive.
Perhaps something like this: the buffer must remain alive through any
call to sqlite3_step that "uses" it. sqlite3_step uses the buffer if a)
it was bound to a parameter by a prior sqlite3_bind_* call, and b) there
was no intervening sqlite3_bind_* call for the same parameter, nor
sqlite3_clear_bindings call.
As a corollary, the buffer is no longer needed after sqlite3_finalize,
simply because it would not be possible to call sqlite3_step anymore on
the finalized statement.
--
Igor Tandetnik
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users