在你告诉我阅读文档之前,是的,我已经阅读过了.但是我自己的测试告诉我,我有时可以反复调用sqlite3_step()一些准备好的语句而不先重置它们.例子是:BEGIN和COMMIT.当我需要重置准备好的声明时,你能否解释一下,因为我希望尽可能避免拨打电话?
编辑:文档说(我的大胆):
准备好的语句对象的生命周期通常如下:
来自sqlite来源:
/* We used to require that sqlite3_reset() be called before retrying
** sqlite3_step() after any error or after SQLITE_DONE. But beginning
** with version 3.7.0, we changed this so that sqlite3_reset() would
** be called automatically instead of throwing the SQLITE_MISUSE error.
** This "automatic-reset" change is not technically an incompatibility,
** since any application that receives an SQLITE_MISUSE is broken by
** definition.
**
** Nevertheless, some published applications that were originally written
** for version 3.6.23 or earlier do in fact depend on SQLITE_MISUSE
** returns, and those were broken by the automatic-reset change. As a
** a work-around, the SQLITE_OMIT_AUTORESET compile-time restores the
** legacy behavior of returning SQLITE_MISUSE for cases where the
** previous sqlite3_step() returned something other than a SQLITE_LOCKED
** or SQLITE_BUSY error.
*/
Run Code Online (Sandbox Code Playgroud)
因此,对于版本3.7.0,如果您到达SQLITE_DONE并且想要再次执行,则不需要sqlite_reset.
完成后,您需要调用sqlite3_finalize来释放该语句.请参阅https://www.sqlite.org/c3ref/finalize.html