I think I found a bug, tested with SQLite v3.7.15.2 and v3.7.9. Looks like sqlite3_finalize() always returns SQLITE_OK, even if most recent execution of prepared statement failed, which contradicts the documentation<http://www.sqlite.org/c3ref/finalize.html> :
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<http://www.sqlite.org/c3ref/c_abort.html> > or extended error code<http://www.sqlite.org/c3ref/c_abort_rollback.html> > . > I'm using sqlite3 via lsqlite3 <http://lua.sqlite.org/> Lua wrapper library (so maybe the bug is there but I can't confirm). Here's some sample code: > require "lsqlite3" > db = sqlite3.open_memory() > =db sqlite database (0x238e858) > =db:exec("create table t(x unique)") *-- create a table with a constraint * 0 > stmt = db:prepare("insert into t(x) values(?)") > =stmt sqlite virtual machine (0x23a23e8) > =stmt:bind_values(123) 0 > =stmt:step() 101 > =sqlite3.DONE 101 > =stmt:reset() 0 > =stmt:step() *-- intentionally execute statement with same values to violate the constraint* 19 *> =sqlite3.CONSTRAINT -- step() returns the expected error code* *19* > =db:errmsg() column x is not unique *> =stmt:finalize() -- finalize returns OK!* *0* *> =db:errmsg() -- error message is still persisted, though* *column x is not unique* Somebody please confirm this... -- Dmitry Pashkevich _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users