diff --git a/Data/ODBC/testsuite/src/ODBCOracleTest.cpp b/Data/ODBC/testsuite/src/ODBCOracleTest.cpp index 2139f2eac..375f6fd2f 100644 --- a/Data/ODBC/testsuite/src/ODBCOracleTest.cpp +++ b/Data/ODBC/testsuite/src/ODBCOracleTest.cpp @@ -188,21 +188,6 @@ void ODBCOracleTest::testInternalExtraction() } -void ODBCOracleTest::testInternalBulkExtraction() -{ - if (!_pSession) fail ("Test not available."); - - recreatePersonTable(); - _pSession->setFeature("autoBind", true); - _pSession->setFeature("autoExtract", true); -#ifdef POCO_ODBC_UNICODE - _pExecutor->internalBulkExtractionUTF16(0); -#else - _pExecutor->internalBulkExtraction(0); -#endif -} - - void ODBCOracleTest::testBLOB() { const std::size_t maxFldSize = 1000000; diff --git a/Data/ODBC/testsuite/src/ODBCOracleTest.h b/Data/ODBC/testsuite/src/ODBCOracleTest.h index be44bd45e..5fe2d86a7 100644 --- a/Data/ODBC/testsuite/src/ODBCOracleTest.h +++ b/Data/ODBC/testsuite/src/ODBCOracleTest.h @@ -37,7 +37,6 @@ public: void testBareboneODBC(); void testInternalExtraction(); - void testInternalBulkExtraction(); void testBLOB(); diff --git a/Data/ODBC/testsuite/src/ODBCTest.cpp b/Data/ODBC/testsuite/src/ODBCTest.cpp index 97932ce2c..df9232729 100644 --- a/Data/ODBC/testsuite/src/ODBCTest.cpp +++ b/Data/ODBC/testsuite/src/ODBCTest.cpp @@ -989,9 +989,9 @@ void ODBCTest::testInternalBulkExtraction() _pSession->setFeature("autoBind", true); _pSession->setFeature("autoExtract", true); #ifdef POCO_ODBC_UNICODE - _pExecutor->internalBulkExtractionUTF16(0); + _pExecutor->internalBulkExtractionUTF16(); #else - _pExecutor->internalBulkExtraction(0); + _pExecutor->internalBulkExtraction(); #endif } diff --git a/Data/ODBC/testsuite/src/SQLExecutor.cpp b/Data/ODBC/testsuite/src/SQLExecutor.cpp index ee8500a30..6b20e153b 100644 --- a/Data/ODBC/testsuite/src/SQLExecutor.cpp +++ b/Data/ODBC/testsuite/src/SQLExecutor.cpp @@ -2811,7 +2811,7 @@ void SQLExecutor::filter(const std::string& query, const std::string& intFldName catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } } -/* + void SQLExecutor::internalBulkExtraction() { std::string funct = "internalBulkExtraction()"; @@ -2934,7 +2934,7 @@ void SQLExecutor::internalBulkExtractionUTF16() catch (ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail(funct); } catch (StatementException& se){ std::cout << se.toString() << std::endl; fail(funct); } } -*/ + void SQLExecutor::internalStorageType() { diff --git a/Data/ODBC/testsuite/src/SQLExecutor.h b/Data/ODBC/testsuite/src/SQLExecutor.h index 01f23ff12..317ad12e0 100644 --- a/Data/ODBC/testsuite/src/SQLExecutor.h +++ b/Data/ODBC/testsuite/src/SQLExecutor.h @@ -698,151 +698,11 @@ public: } void filter(const std::string& query = - "SELECT * FROM " + ExecUtil::vectors() + " ORDER BY i0 ASC", - const std::string& intFldName = "i0"); + "SELECT * FROM " + ExecUtil::vectors() + " ORDER BY int0 ASC", + const std::string& intFldName = "int0"); - template - void internalBulkExtraction(IntType) - { - using Poco::Data::RecordSet; - using Poco::NumberFormatter; - - std::string funct = "internalBulkExtraction()"; - int size = 100; - std::vector lastName(size); - std::vector firstName(size); - std::vector address(size); - std::vector age(size); - - for (int i = 0; i < size; ++i) - { - lastName[i] = "LN" + NumberFormatter::format(i); - firstName[i] = "FN" + NumberFormatter::format(i); - address[i] = "Addr" + NumberFormatter::format(i); - age[i] = i; - } - - try - { - session() << "INSERT INTO " << ExecUtil::person() <<" VALUES (?,?,?,?)", - use(lastName, bulk), - use(firstName, bulk), - use(address, bulk), - use(age, bulk), - now; - } - catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } - catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } - - try - { - Statement stmt = (session() << "SELECT * FROM " << ExecUtil::person(), bulk(size), now); - RecordSet rset(stmt); - assert (size == rset.rowCount()); - assert("LN0" == rset["LastName"]); - assert (0 == rset["Age"]); - rset.moveNext(); - assert("LN1" == rset["LastName"]); - assert(1 == rset["Age"]); - rset.moveLast(); - assert (std::string("LN") + NumberFormatter::format(size - 1) == rset["LastName"]); - assert (size - 1 == rset["Age"]); - } - catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } - catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } - - try - { - Statement stmt = (session() << "SELECT * FROM " << ExecUtil::person(), limit(size), bulk, now); - RecordSet rset(stmt); - assert (size == rset.rowCount()); - assert ("LN0" == rset["LastName"]); - assert (0 == rset["Age"]); - rset.moveLast(); - assert (std::string("LN") + NumberFormatter::format(size - 1) == rset["LastName"]); - assert (size - 1 == rset["Age"]); - } - catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } - catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } - } - - template - void internalBulkExtractionUTF16(IntType) - { - using Poco::Data::RecordSet; - using Poco::UTF16String; - using Poco::NumberFormatter; - - std::string funct = "internalBulkExtraction()"; - int size = 100; - std::vector lastName(size); - std::vector firstName(size); - std::vector address(size); - std::vector age(size); - - for (int i = 0; i < size; ++i) - { - lastName[i] = Poco::UnicodeConverter::to("LN" + NumberFormatter::format(i)); - firstName[i] = Poco::UnicodeConverter::to("FN" + NumberFormatter::format(i)); - address[i] = Poco::UnicodeConverter::to("Addr" + NumberFormatter::format(i)); - age[i] = i; - } - - try - { - session() << "INSERT INTO " << ExecUtil::person() <<" VALUES (?,?,?,?)", - use(lastName, bulk), - use(firstName, bulk), - use(address, bulk), - use(age, bulk), - now; - } - catch (ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail(funct); } - catch (StatementException& se){ std::cout << se.toString() << std::endl; fail(funct); } - - try - { - Statement stmt = (session() << "SELECT * FROM " << ExecUtil::person(), bulk(size), now); - RecordSet rset(stmt); - assert(size == rset.rowCount()); - assert(Poco::UnicodeConverter::to("LN0") == rset["LastName"]); - assert(0 == rset["Age"]); - rset.moveNext(); - assert(Poco::UnicodeConverter::to("LN1") == rset["LastName"]); - assert(1 == rset["Age"]); - rset.moveLast(); - assert(std::string("LN") + NumberFormatter::format(size - 1) == rset["LastName"]); - assert(size - 1 == rset["Age"]); - } - catch (ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail(funct); } - catch (StatementException& se){ std::cout << se.toString() << std::endl; fail(funct); } - - try - { - Statement stmt = (session() << "SELECT * FROM " << ExecUtil::person(), limit(size), bulk, now); - RecordSet rset(stmt); - assert(size == rset.rowCount()); - assert("LN0" == rset["LastName"]); - assert(0 == rset["Age"]); - rset.moveLast(); - assert(std::string("LN") + NumberFormatter::format(size - 1) == rset["LastName"]); - assert(size - 1 == rset["Age"]); - } - catch (ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail(funct); } - catch (StatementException& se){ std::cout << se.toString() << std::endl; fail(funct); } - } + void internalBulkExtraction(); + void internalBulkExtractionUTF16(); void internalStorageType(); void nulls(bool emptyStrIsSpace = false); diff --git a/Data/include/Poco/Data/RowFilter.h b/Data/include/Poco/Data/RowFilter.h index be89607b6..f7ee19997 100644 --- a/Data/include/Poco/Data/RowFilter.h +++ b/Data/include/Poco/Data/RowFilter.h @@ -85,12 +85,15 @@ public: ~RowFilter(); /// Destroys the RowFilter. - void addFilter(const Ptr& pFilter, LogicOperator comparison); + void addFilter(Ptr pFilter, LogicOperator comparison); /// Appends another filter to this one. - void removeFilter(const Ptr& pFilter); + void removeFilter(Ptr pFilter); /// Removes filter from this filter. + bool has(Ptr pFilter) const; + /// Returns true if this filter is parent of pFilter; + template void add(const std::string& name, Comparison comparison, const T& value, LogicOperator op = OP_OR) /// Adds value to the filter. @@ -185,6 +188,12 @@ private: /// +inline bool RowFilter::has(Ptr pFilter) const +{ + return _filterMap.find(pFilter) != _filterMap.end(); +} + + inline bool RowFilter::isEmpty() const { return _comparisonMap.size() == 0; diff --git a/Data/src/RowFilter.cpp b/Data/src/RowFilter.cpp index 3d3de5f47..4c7db2592 100644 --- a/Data/src/RowFilter.cpp +++ b/Data/src/RowFilter.cpp @@ -29,6 +29,7 @@ RowFilter::RowFilter(RecordSet* pRecordSet): _pRecordSet(pRecordSet), _not(false { poco_check_ptr(pRecordSet); init(); + duplicate(); _pRecordSet->filter(this); } @@ -39,6 +40,7 @@ RowFilter::RowFilter(Ptr pParent, LogicOperator op): _pRecordSet(0), { poco_check_ptr(_pParent.get()); init(); + duplicate(); _pParent->addFilter(this, op); } @@ -62,7 +64,9 @@ RowFilter::~RowFilter() try { if (_pRecordSet) _pRecordSet->filter(0); - if (_pParent.get()) _pParent->removeFilter(this); + if (_pParent && _pParent->has(this)) + _pParent->removeFilter(this); + release(); } catch (...) { @@ -162,7 +166,7 @@ RowFilter::Comparison RowFilter::getComparison(const std::string& comp) const } -void RowFilter::addFilter(const Ptr& pFilter, LogicOperator comparison) +void RowFilter::addFilter(Ptr pFilter, LogicOperator comparison) { poco_check_ptr (_pRecordSet); @@ -172,13 +176,14 @@ void RowFilter::addFilter(const Ptr& pFilter, LogicOperator comparison) } -void RowFilter::removeFilter(const Ptr& pFilter) +void RowFilter::removeFilter(Ptr pFilter) { poco_check_ptr (_pRecordSet); - pFilter->_pRecordSet = 0; _pRecordSet->moveFirst(); _filterMap.erase(pFilter); + pFilter->_pRecordSet = 0; + pFilter->_pParent = 0; }