mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-14 06:55:49 +02:00
see CHANGELOG
- upgraded SQLite to version 3.7.15.1 (2012-12-19) - fixed SQLite affectedRows reporting and added tests - added SQLite::Utility::isThreadSafe() function - added SQLite::Utility::setThreadMode(int mode) function - fixed GH #41: Buffer::resize crash
This commit is contained in:
@@ -58,6 +58,7 @@
|
||||
#include "Poco/AutoPtr.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/RefCountedObject.h"
|
||||
#include "Poco/Stopwatch.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
@@ -618,7 +619,6 @@ void SQLiteTest::testSharedPtrComplexTypeVector()
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SQLiteTest::testInsertVector()
|
||||
{
|
||||
Session tmp (Poco::Data::SQLite::Connector::KEY, "dummy.db");
|
||||
@@ -680,6 +680,7 @@ void SQLiteTest::testAffectedRows()
|
||||
assert (0 == stmt.execute());
|
||||
|
||||
Statement stmt1((tmp << "INSERT INTO Strings VALUES(:str)", use(str)));
|
||||
count = -1;
|
||||
tmp << "SELECT COUNT(*) FROM Strings", into(count), now;
|
||||
assert (count == 0);
|
||||
assert (4 == stmt1.execute());
|
||||
@@ -692,10 +693,13 @@ void SQLiteTest::testAffectedRows()
|
||||
Statement stmt3(tmp << "DELETE FROM Strings WHERE str = 's1'");
|
||||
assert (1 == stmt3.execute());
|
||||
|
||||
Statement stmt4(tmp << "DELETE FROM Strings WHERE str = 'bad value'");
|
||||
assert (0 == stmt4.execute());
|
||||
|
||||
// see SQLiteStatementImpl::affectedRows() documentation for explanation
|
||||
// why "WHERE 1" is necessary here
|
||||
Statement stmt4(tmp << "DELETE FROM Strings WHERE 1");
|
||||
assert (3 == stmt4.execute());
|
||||
Statement stmt5(tmp << "DELETE FROM Strings WHERE 1");
|
||||
assert (3 == stmt5.execute());
|
||||
}
|
||||
|
||||
|
||||
@@ -2263,8 +2267,6 @@ void SQLiteTest::testDynamicAny()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void SQLiteTest::testPair()
|
||||
{
|
||||
Session tmp (Poco::Data::SQLite::Connector::KEY, "dummy.db");
|
||||
@@ -2299,6 +2301,7 @@ void SQLiteTest::testPair()
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SQLiteTest::testSQLChannel()
|
||||
{
|
||||
Session tmp (Poco::Data::SQLite::Connector::KEY, "dummy.db");
|
||||
@@ -2580,6 +2583,51 @@ void SQLiteTest::testSystemTable()
|
||||
}
|
||||
|
||||
|
||||
void SQLiteTest::benchmarkThreadModesTiming()
|
||||
{
|
||||
using namespace Poco::Data::SQLite;
|
||||
typedef std::vector<int> ModeVec;
|
||||
|
||||
const int datasize = 1000;
|
||||
ModeVec mode;
|
||||
mode.push_back(Utility::THREAD_MODE_SINGLE);
|
||||
mode.push_back(Utility::THREAD_MODE_MULTI);
|
||||
mode.push_back(Utility::THREAD_MODE_SERIAL);
|
||||
|
||||
Poco::Stopwatch sw;
|
||||
ModeVec::iterator it = mode.begin();
|
||||
ModeVec::iterator end = mode.end();
|
||||
for (; it != end; ++it)
|
||||
{
|
||||
sw.start();
|
||||
Utility::setThreadMode(*it);
|
||||
Session tmp (Connector::KEY, "dummy.db");
|
||||
std::vector<int> iv;
|
||||
int count = 0;
|
||||
for (int i =0; i < datasize; ++i) iv.push_back(i);
|
||||
|
||||
tmp << "DROP TABLE IF EXISTS Ints", now;
|
||||
tmp << "CREATE TABLE IF NOT EXISTS Ints (theInt INTEGER)", now;
|
||||
{
|
||||
Statement stmt((tmp << "INSERT INTO Ints VALUES(?)", use(iv)));
|
||||
tmp << "SELECT COUNT(*) FROM Ints", into(count), now;
|
||||
assert (count == 0);
|
||||
stmt.execute();
|
||||
tmp << "SELECT COUNT(*) FROM Ints", into(count), now;
|
||||
assert (count == datasize);
|
||||
}
|
||||
count = 0;
|
||||
tmp << "SELECT COUNT(*) FROM Ints", into(count), now;
|
||||
assert (count == datasize);
|
||||
sw.stop();
|
||||
std::cout << "Mode: " << ((*it == Utility::THREAD_MODE_SINGLE) ? "single,"
|
||||
:(*it == Utility::THREAD_MODE_MULTI) ? "multi,"
|
||||
:(*it == Utility::THREAD_MODE_SERIAL) ? "serial,"
|
||||
: "unknown,") << " Time: " << sw.elapsed() / 1000.0 << " [ms]" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SQLiteTest::setUp()
|
||||
{
|
||||
}
|
||||
@@ -2671,6 +2719,7 @@ CppUnit::Test* SQLiteTest::suite()
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testPair);
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testReconnect);
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testSystemTable);
|
||||
CppUnit_addTest(pSuite, SQLiteTest, benchmarkThreadModesTiming);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
Reference in New Issue
Block a user