Question for the paragraph in http://www.sqlite.org/lang_transaction.html:
"An implicit transaction (a transaction that is started automatically, not a
transaction started by BEGIN) is committed automatically when the last active
statement finishes. A statement finishes when its prepared statement is reset
or finalized. An open sqlite3_blob used for incremental BLOB I/O counts as an
unfinished statement. The sqlite3_blob finishes when it is closed."
This means without sqlite3_reset or sqlite3_finalize, the transaction is not
commited. But my code shows it does commit immediately after sqlite3_step():
void
test_insert()
{
int ite = 0;
int rc = 0;
sqlite3_stmt *stmt = NULL;
char sql[] = "insert into test values (?1, ?2);";
rc = sqlite3_prepare_v2(db, sql, strlen(sql) + 1, &stmt, NULL);
if (rc) {
perror("sqlite3_prepare_v2");
return;
}
for (ite = 0; ite < 1; ite++) {
rc = sqlite3_reset(stmt);
assert(rc == SQLITE_OK);
sqlite3_bind_int(stmt, 1, ite);
sqlite3_bind_int(stmt, 2, ite + 100);
rc = sqlite3_step(stmt);
if (rc != SQLITE_DONE) {
printf("sqlite3_step ite:%d %s", ite,
sqlite3_errmsg(db));
return;
}
}
}
I verified this through Linux Perf tools.
So, the result of the code is different with the Documentation, which one is
correct ??
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users