作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在你告诉我阅读docs之前,是的,我已经读过它们。但我自己的测试告诉我,有时我可以对某些准备好的语句重复调用 sqlite3_step()
而无需先重置它们。例如:BEGIN
和 COMMIT
。您能否告诉我何时需要重置准备好的语句,因为我希望尽可能避免进行调用?
编辑:文档说(我的粗体):
The life-cycle of a prepared statement object usually goes like this:
最佳答案
来自 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.
*/
因此,在版本 3.7.0 中,如果您达到 SQLITE_DONE 并想要再次单步执行,则不需要 sqlite_reset。
完成后,您需要调用 sqlite3_finalize 来释放该语句。请参阅 https://www.sqlite.org/c3ref/finalize.html
关于c - sqlite3_reset() 什么时候需要?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35741175/
我是一名优秀的程序员,十分优秀!