Adam DeVita wrote:
> As an error check, I've got a program opening an encrypted file.
>
> sqlite3_prepare_v2 returns SQLITE_OK
>
> and ppStmt is not null.
>
> When I run sqlite3_step(ppStmt) it returns SQLITE_NOTADB.

sqlite3_prepare_v2 does not yet start a transaction (to allow keeping
cached prepared statements around), and only inside a transaction can
the database file be locked and accessed.

> Recognizing an error at this point I'd like to clean up properly.
> sqlite3_finalize(ppStmt) returns SQLITE_NOTADB.
> At this point, has it actually cleared the prepared statement

Yes; sqlite3_finalize _always_ frees the statement.

> http://www.sqlite.org/capi3ref.html#sqlite3_finalize is a bit brief on
> the success of finalizing the statement given that it returned an
> error.

| If the most recent evaluation of the statement encountered no errors
| or if the statement is never been evaluated, then sqlite3_finalize()
| returns SQLITE_OK.  If the most recent evaluation of statement S
| failed, then sqlite3_finalize(S) returns the appropriate error code
| or extended error code.

Or in the words of the source code:
| The following routine destroys a virtual machine that is created by
| the sqlite3_compile() routine. The integer returned is an SQLITE_
| success/failure code that describes the result of executing the virtual
| machine.

In other words, _any_ error returned by this function applies not
to what sqlite3_finalize did itself, but to the result of other
functions.


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to