COT_EVENT_TABLE = "CREATE TABLE MAIN_TABLE(   pk char(41) primary key,\
                                                                item1 real,     
           
\
                                                                item2
char(64),                   \
                                                                item3
timestamp,              \
                                                                item4
integer,                \
                                                                item5
TIMESTAMP NOT NULL DEFAULT current_timestamp, \
                                                                Blob
char(1024))";

Lets assume I have inserted 10 records. pk = 1 - 10

sqlite3_exec(this->hDBC_, "BEGIN EXCLUSIVE TRANSACTION;", NULL, NULL, 0); 
sqlite3_prepare_v2(this->hDBC_, "SELECT * FROM MAIN_TABLE", -1,
&this->hStmt_, 0); 
sqlite3_step(this->hStmt_); 
sqlite3_exec(this->hDBC_, "END TRANSACTION;", NULL, NULL, 0); 
sqlite3_finalize(this->hStmt_);
    Expect 10 Results -- Returns 10 Results
This Select statement is on a loop of roughly .5s
...

Then on an external event, another thread will aquire my mutex and attempt
an update
sqlite3_exec(this->hDBC_, "BEGIN EXCLUSIVE TRANSACTION;", NULL, NULL, 0);
sqlite3_prepare_v2(this->hDBC_, "UPDATE EVENT_TABLE SET item1 = value1,
item2 = value2, blob = ?, WHERE pk = 5", -1, &this->hStmt_, 0); 
sqlite3_bind_blob(this->hStmt_, 1, blob, blobSize, SQLITE_STATIC);
sqlite3_step(this->hStmt_); 
sqlite3_exec(this->hDBC_, "END TRANSACTION;", NULL, NULL, 0);
sqlite3_finalize(this->hStmt_); 
  Expect SQLITE_OK -- Returns SQLITE_OK

Now, if a select statments timer is up immediately after this update,
meaning the next thing the thread does it the first set of statements. Then
sqlite3_exec returns SQLITE_OK and there are 9 results (pk = 5 is missing).
I expect either 10 results, or for sqlite3_exec to return a SQLITE_LOCKED,
BUSY, or something other than _OK.

Additional Info
SQLITE_VERSION "3.7.14.1"
To open my connection:
sqlite3_config(SQLITE_CONFIG_URI);
sqlite3_enable_shared_cache(true);
sqlite3_open("file::memory:?cache=shared", &hDBC_);
sqlite3_extended_result_codes(hDBC_, true);
I did not change SQLITE_THREADSAFE so I assuming it is still the default "1"
 




--
View this message in context: 
http://sqlite.1065341.n5.nabble.com/Memory-DB-Query-does-not-return-all-records-after-Update-tp67267p67320.html
Sent from the SQLite mailing list archive at Nabble.com.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to