From 325874b9fdde48583beae6338c1baa75216eaa53 Mon Sep 17 00:00:00 2001 From: "dmitriy.n" Date: Wed, 26 Aug 2015 18:47:42 +0300 Subject: [PATCH 1/3] When we call statement execution for "PRAGMA incremental_vacuum(1024);" it fails with null std iterator exception. It happens because variable "extracts" is empty and construction "*extracts.begin()" is invalid. --- Data/SQLite/src/SQLiteStatementImpl.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Data/SQLite/src/SQLiteStatementImpl.cpp b/Data/SQLite/src/SQLiteStatementImpl.cpp index dc6c3778e..4411d2ab1 100644 --- a/Data/SQLite/src/SQLiteStatementImpl.cpp +++ b/Data/SQLite/src/SQLiteStatementImpl.cpp @@ -273,7 +273,16 @@ std::size_t SQLiteStatementImpl::next() } _stepCalled = false; if (_affectedRowCount == POCO_SQLITE_INV_ROW_CNT) _affectedRowCount = 0; - _affectedRowCount += (*extracts.begin())->numOfRowsHandled(); + + //_affectedRowCount += (*extracts.begin())->numOfRowsHandled(); + if (extracts.size()) + _affectedRowCount += (*extracts.begin())->numOfRowsHandled(); + else + { + _stepCalled = true; + _nextResponse = SQLITE_DONE; + } + } else if (SQLITE_DONE == _nextResponse) { From 044a23b1e81fb9917566396bb8f5a88897d84ba8 Mon Sep 17 00:00:00 2001 From: "dmitriy.n" Date: Mon, 19 Oct 2015 16:55:53 +0300 Subject: [PATCH 2/3] added test case for pull request 922 --- Data/SQLite/testsuite/src/SQLiteTest.cpp | 33 +++++++++++++++++++++++- Data/SQLite/testsuite/src/SQLiteTest.h | 2 ++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/Data/SQLite/testsuite/src/SQLiteTest.cpp b/Data/SQLite/testsuite/src/SQLiteTest.cpp index 77da4beb3..8d886763e 100644 --- a/Data/SQLite/testsuite/src/SQLiteTest.cpp +++ b/Data/SQLite/testsuite/src/SQLiteTest.cpp @@ -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; } diff --git a/Data/SQLite/testsuite/src/SQLiteTest.h b/Data/SQLite/testsuite/src/SQLiteTest.h index 614eb06fd..57b37522a 100644 --- a/Data/SQLite/testsuite/src/SQLiteTest.h +++ b/Data/SQLite/testsuite/src/SQLiteTest.h @@ -137,6 +137,8 @@ public: void testJSONRowFormatter(); + void testIncrementVacuum(); + void setUp(); void tearDown(); From 4e6ec71c182c5ec16bdc8e1dfbd1d980831c05df Mon Sep 17 00:00:00 2001 From: "dmitriy.n" Date: Tue, 20 Oct 2015 10:18:59 +0300 Subject: [PATCH 3/3] deleted commented code --- Data/SQLite/src/SQLiteStatementImpl.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Data/SQLite/src/SQLiteStatementImpl.cpp b/Data/SQLite/src/SQLiteStatementImpl.cpp index 4411d2ab1..5f0b6c725 100644 --- a/Data/SQLite/src/SQLiteStatementImpl.cpp +++ b/Data/SQLite/src/SQLiteStatementImpl.cpp @@ -274,7 +274,6 @@ 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