"Wesley W. Terpstra" <[EMAIL PROTECTED]> wrote:
> 
> Suppose you have two prepared queries: q1 and q2. I currently believe
> that it is an error to execute: step q1, step q2, step q1.

No.  Queries can be interleaved this way.

> 
> In fact, I believe that after step q1, you must either call finalize
> or reset on q1 before you can call step q2.

Not true.  Two or more queries can be running at the same time.
For that matter SQLite is reentrant, and this fact is used within
the implementation.  Some queries will automatically invoke other
queries.  Examples of this occur when you run VACUUM or when you
make any kind of queries against fts1 or fts2 virtual tables.

> 
> If I'm wrong with the above, what happens if I step q1, start a
> transaction, then step q1 again?

An implicit transaction was already started when you started
stepping q1.  That implicit transaction will not end until all
active queries have finished.

If you run the BEGIN command, all that does is set a flag that
tells SQLite not to commit once all queries have finished but
rather to keep the transaction open.

> 
> What happens to an open transaction if you reset a query? I imagine
> that a user might be running a select statement, have found the row
> they were interested in, and then called reset rather than read the
> rest of the result set. In this case, I would like to be able to
> continue running new statements within the query. Similarly, I might
> cancel the query with finalize. The documentation seems to imply that
> this will abort a transaction?

If you have not run BEGIN, then the transaction will end once *all*
active queries have completed. 

--
D. Richard Hipp  <[EMAIL PROTECTED]>


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

Reply via email to