Hi all, please help: very strange issue that should not be happening:
1. Have two connections to same database: _db1 and _db2. 2. Create table in _db1 3. Run count * from _db2 -> returns 0 4. Insert 1 row using _db1 –OK 5. Run select * from _db2 -> 0 rows return Weird thing is that if I remove step 3, then step 5 returns a row. I’m guessing there must be a bug in SQLite with cache sync, or I’m missing something obvious. Please help: sqlite3* _db1; sqlite3* _db2; sqlite3_open("test.sqlite", &_db1); sqlite3_open("test.sqlite", &_db2); //create table char* errorMessage; sqlite3_exec(_db1, "CREATE TABLE test (column1 INTEGER)", NULL, NULL, &errorMessage); //get count of items from db2 -> should return 0 string countStatement = "SELECT COUNT(*) FROM test"; sqlite3_stmt* stmt; //prepare statement if(sqlite3_prepare_v2(_db2, countStatement.c_str(), -1, &stmt, NULL) != SQLITE_OK){ GHAssertTrue(false, @"Should have created prepared statement: %s", sqlite3_errmsg(_db1)); } int rc = sqlite3_step(stmt); if(rc == SQLITE_ROW){ //get the count if(sqlite3_column_count(stmt) > 0){ int count = sqlite3_column_int(stmt, 0); GHAssertTrue(count == 0, @"Count should be zero"); }else{ GHAssertTrue(false, @"Should have returned a row"); } }else{ GHAssertTrue(false, @"Should have returned a row"); } //insert one row into table using db1 sqlite3_exec(_db1, "INSERT into test(column1) values (4)", NULL, NULL, &errorMessage); //read row using db2 //get count of items from db2 -> should return 0 string selectStatement = "SELECT * FROM test"; //prepare statement if(sqlite3_prepare_v2(_db2, selectStatement.c_str(), -1, &stmt, NULL) != SQLITE_OK){ GHAssertTrue(false, @"Should have created prepared statement: %s", sqlite3_errmsg(_db1)); } rc = sqlite3_step(stmt); if(rc == SQLITE_ROW){ //get the count if(sqlite3_column_count(stmt) > 0){ //good }else{ //bad GHAssertTrue(false, @"Should have returned a row"); } }else{ //bad GHAssertTrue(false, @"Should have returned a row"); } _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users