If I run the following code I get some unexpected results:

               sqlite3* db1_p = 0;
               const int open1Res = sqlite3_open16(L"test.db", &db1_p);
               sqlite3* db2_p = 0;
               const int open2Res = sqlite3_open16(L"test.db", &db2_p);

               sqlite3_stmt* stmt1_p;
               const int prep1Res = sqlite3_prepare16_v2(db1_p, L"SELECT
               * FROM test", -1, &stmt1_p, 0);
               sqlite3_stmt* stmt2_p;
               const int prep2Res =
                   sqlite3_prepare16_v2(db2_p, L"INSERT INTO test VALUES
                   (1, 1.1, 'q')", -2, &stmt2_p, 0);

               const int step1Res = sqlite3_step(stmt1_p);
               const int step2Res = sqlite3_step(stmt2_p);

               const int finalize2Res1 = sqlite3_finalize(stmt2_p);
               const int finalize2Res2 = sqlite3_finalize(stmt2_p);

                const int finalize1Res = sqlite3_finalize(stmt1_p);
                const int finalize2Res3 = sqlite3_finalize(stmt2_p);

Everything works as expected up to the first call to sqlite3_finalize. 
I Get SQLITE_OK form the opens and prepares, SQLITE_ROW from the first
step statement and SQLITE_BUSY form the second step statement.  Then on
the first call to finalize I get SQLITE_BUSY.  I'm not sure if this
means that the statement could not be finalized due to a database lock
or that sqlite3_finalize is returning the result of executing the
statement. The documentation confuses me a bit on this point.  I'm
leaning towards the latter since the subsequent calls to
sqlite3_finalize for stmt2_p result in SQLITE_MISUSE.  So I'm wondering
if database locks can prevent sqlite3_finalize from running
successfully, it seems strange if they do.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to