Hello I want to use sqlite to log some data into a simple table. My application is multi-threaded but I only need to write to the database. I begin with specifying the statements.
const char *vectorsql = "INSERT INTO vector (x0,x1,x2) VALUES (?,?,?);"; const char *intrsql = "INSERT INTO interaction (bodyid1,bodyid2,iter,vectorid)" \ "VALUES (?,?,?,last_insert_rowid());"; sqlite3_prepare_v2(db, "BEGIN EXCLUSIVE TRANSACTION;", -1, &beginstmt, NULL); sqlite3_prepare_v3(db, vectorsql, -1, &vectorstmt, NULL); sqlite3_prepare_v2(db, intrsql, -1, &intrstmt, NULL); sqlite3_prepare_v2(db, "END TRANSACTION;", -1, &commitstmt, NULL); The execution looks as follow: sqlite3_bind_int(vectorstmt, 1, x0); sqlite3_bind_int(vectorstmt, 2, x1); sqlite3_bind_int(vectorstmt, 3, x2); sqlite3_bind_int(intrstmt, 1, bodyid1); sqlite3_bind_int(intrstmt, 2, bodyid2); sqlite3_bind_int(intrstmt, 3, iter); sqlite3_step(beginstmt); sqlite3_step(vectorstmt); sqlite3_step(intrstmt); sqlite3_step(commitstmt); sqlite3_reset(beginstmt); sqlite3_reset(vectorstmt); sqlite3_reset(intrstmt); sqlite3_reset(commitstmt); sqlite3_clear_bindings(vectorstmt); sqlite3_clear_bindings(intrstmt); But now it seems that not every interaction is logged into the database (I also log the data in a std container). As I understand with the serialization option multiple threads can have access to the same database connection and statement, and sqlite will sort out any data races and dead locks. And within an exclusive transaction no other process can have read or write access to the database. But the interaction table and the vector table don't have the same number of rows, therefore some race conditions must occur. Can someone point out my errors? Cheers Reza _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users