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<http://www.sqlite.org/c3ref/reset.html> or 
finalized<http://www.sqlite.org/c3ref/finalize.html>. An open 
sqlite3_blob<http://www.sqlite.org/c3ref/blob.html> used for incremental BLOB 
I/O counts as an unfinished statement. The 
sqlite3_blob<http://www.sqlite.org/c3ref/blob.html> finishes when it is 
closed<http://www.sqlite.org/c3ref/blob_close.html>."

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 also verified this through Linux Perf tools by tracing syscalls.

So, the result of the code is different with the Documentation, which one is 
correct ??
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to