added multi-session sys table tests

This commit is contained in:
aleks-f 2012-12-23 03:27:56 -06:00
parent 760fa4bbb0
commit 50b67d711f
2 changed files with 30 additions and 8 deletions

View File

@ -88,7 +88,6 @@ void SQLiteStatementImpl::compileImpl()
if (SQLITE_OK != sqlite3_exec(_pDB, "delete from sys.dual where 1 <> 1;", 0, 0, 0))
throw ExecutionException("Error updating system database.");
}
_bindBegin = bindings().begin();
}

View File

@ -2560,18 +2560,41 @@ void SQLiteTest::testReconnect()
void SQLiteTest::testSystemTable()
{
Session session (Poco::Data::SQLite::Connector::KEY, "dummy.db");
int cntFile = 0;
session << "DROP TABLE IF EXISTS Test", now;
session << "CREATE TABLE Test (Test INTEGER)", now;
session << "INSERT INTO Test VALUES (1)", now;
session << "SELECT count(*) FROM Test", into(cntFile), now;
assert (1 == cntFile);
int cnt = -1;
session << "SELECT count(*) FROM sys.dual", into(cnt), now;
assert (0 == cnt);
int cntMem = -1;
session << "SELECT count(*) FROM sys.dual", into(cntMem), now;
assert (0 == cntMem);
session << "INSERT INTO sys.dual VALUES ('test')", now;
session << "SELECT count(*) FROM sys.dual", into(cnt), now;
assert (1 == cnt);
session << "SELECT count(*) FROM sys.dual", into(cntMem), now;
assert (1 == cntMem);
// connect another session
Session session2(Poco::Data::SQLite::Connector::KEY, "dummy.db");
// verify it has it's own sys table
session2 << "SELECT count(*) FROM sys.dual", into(cntMem), now;
assert (0 == cntMem);
// verify it shares the file table
session2 << "SELECT count(*) FROM Test", into(cntFile), now;
assert (1 == cntFile);
session2 << "INSERT INTO sys.dual VALUES ('test')", now;
session2 << "SELECT count(*) FROM sys.dual", into(cntMem), now;
assert (1 == cntMem);
session << "DELETE FROM sys.dual", now;
session << "SELECT count(*) FROM sys.dual", into(cnt), now;
assert (0 == cnt);
session << "SELECT count(*) FROM sys.dual", into(cntMem), now;
assert (0 == cntMem);
session2 << "SELECT count(*) FROM sys.dual", into(cntMem), now;
assert (1 == cntMem);
session2 << "DELETE FROM sys.dual", now;
session2 << "SELECT count(*) FROM sys.dual", into(cntMem), now;
assert (0 == cntMem);
try
{