mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-18 12:19:30 +01:00
Merge pull request #922 from dimanikulin/develop
fixed sql lite statement for empty extracts
This commit is contained in:
commit
64ed9bacf0
@ -273,7 +273,15 @@ std::size_t SQLiteStatementImpl::next()
|
||||
}
|
||||
_stepCalled = false;
|
||||
if (_affectedRowCount == POCO_SQLITE_INV_ROW_CNT) _affectedRowCount = 0;
|
||||
_affectedRowCount += (*extracts.begin())->numOfRowsHandled();
|
||||
|
||||
if (extracts.size())
|
||||
_affectedRowCount += (*extracts.begin())->numOfRowsHandled();
|
||||
else
|
||||
{
|
||||
_stepCalled = true;
|
||||
_nextResponse = SQLITE_DONE;
|
||||
}
|
||||
|
||||
}
|
||||
else if (SQLITE_DONE == _nextResponse)
|
||||
{
|
||||
|
@ -3446,6 +3446,37 @@ void SQLiteTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
void SQLiteTest::testIncrementVacuum()
|
||||
{
|
||||
std::string lastName("lastname");
|
||||
std::string firstName("firstname");
|
||||
std::string address("Address");
|
||||
|
||||
Session tmp (Poco::Data::SQLite::Connector::KEY, "dummy.db");
|
||||
|
||||
tmp << "PRAGMA auto_vacuum = 2", now;
|
||||
int pragma_mode = 0;
|
||||
|
||||
tmp << "PRAGMA auto_vacuum", into(pragma_mode), now;
|
||||
assert (pragma_mode==2);
|
||||
|
||||
tmp << "DROP TABLE IF EXISTS Person", now;
|
||||
tmp << "CREATE TABLE IF NOT EXISTS Person (LastName VARCHAR(30), FirstName VARCHAR, Address VARCHAR, Image BLOB)", now;
|
||||
CLOB img("0123456789", 10);
|
||||
int count = 0;
|
||||
|
||||
for (int index = 0; index < 5000; ++index)
|
||||
tmp << "INSERT INTO PERSON VALUES(:ln, :fn, :ad, :img)", use(lastName), use(firstName), use(address), use(img), now;
|
||||
|
||||
tmp << "SELECT COUNT(*) FROM PERSON", into(count), now;
|
||||
assert (count == 5000);
|
||||
|
||||
// delete record
|
||||
Statement stmt0(tmp << "DELETE FROM PERSON");
|
||||
assert (5000 == stmt0.execute());
|
||||
|
||||
tmp << "PRAGMA incremental_vacuum(1024);", now;
|
||||
}
|
||||
|
||||
CppUnit::Test* SQLiteTest::suite()
|
||||
{
|
||||
@ -3538,6 +3569,6 @@ CppUnit::Test* SQLiteTest::suite()
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testTransactor);
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testFTS3);
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testJSONRowFormatter);
|
||||
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testIncrementVacuum);
|
||||
return pSuite;
|
||||
}
|
||||
|
@ -137,6 +137,8 @@ public:
|
||||
|
||||
void testJSONRowFormatter();
|
||||
|
||||
void testIncrementVacuum();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user