mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-28 11:31:53 +01:00
fixed GH #1532: RecordSet and RowFilter: bad use of reference counter
This commit is contained in:
@@ -26,10 +26,12 @@
|
||||
#include "Poco/Data/BulkExtraction.h"
|
||||
#include "Poco/Data/Statement.h"
|
||||
#include "Poco/Data/RowIterator.h"
|
||||
#include "Poco/Data/RowFilter.h"
|
||||
#include "Poco/Data/LOB.h"
|
||||
#include "Poco/String.h"
|
||||
#include "Poco/Dynamic/Var.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/AutoPtr.h"
|
||||
#include <ostream>
|
||||
#include <limits>
|
||||
|
||||
@@ -98,7 +100,6 @@ public:
|
||||
_currentRow(0),
|
||||
_pBegin(new RowIterator(this, 0 == rowsExtracted())),
|
||||
_pEnd(new RowIterator(this, true)),
|
||||
_pFilter(0),
|
||||
_totalRowCount(UNKNOWN_TOTAL_ROW_COUNT)
|
||||
/// Creates the RecordSet.
|
||||
{
|
||||
@@ -471,17 +472,17 @@ private:
|
||||
/// Returns true if the specified row is allowed by the
|
||||
/// currently active filter.
|
||||
|
||||
void filter(RowFilter* pFilter);
|
||||
void filter(const Poco::AutoPtr<RowFilter>& pFilter);
|
||||
/// Sets the filter for the RecordSet.
|
||||
|
||||
const RowFilter* getFilter() const;
|
||||
const Poco::AutoPtr<RowFilter>& getFilter() const;
|
||||
/// Returns the filter associated with the RecordSet.
|
||||
|
||||
std::size_t _currentRow;
|
||||
RowIterator* _pBegin;
|
||||
RowIterator* _pEnd;
|
||||
RowMap _rowMap;
|
||||
RowFilter* _pFilter;
|
||||
Poco::AutoPtr<RowFilter> _pFilter;
|
||||
std::size_t _totalRowCount;
|
||||
|
||||
friend class RowIterator;
|
||||
@@ -636,7 +637,7 @@ inline RecordSet::Iterator RecordSet::end()
|
||||
}
|
||||
|
||||
|
||||
inline const RowFilter* RecordSet::getFilter() const
|
||||
inline const Poco::AutoPtr<RowFilter>& RecordSet::getFilter() const
|
||||
{
|
||||
return _pFilter;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
|
||||
#include "Poco/Data/Data.h"
|
||||
#include "Poco/Data/RecordSet.h"
|
||||
#include "Poco/Dynamic/Var.h"
|
||||
#include "Poco/Tuple.h"
|
||||
#include "Poco/String.h"
|
||||
@@ -36,6 +35,9 @@ namespace Poco {
|
||||
namespace Data {
|
||||
|
||||
|
||||
class RecordSet;
|
||||
|
||||
|
||||
class Data_API RowFilter: public RefCountedObject
|
||||
/// RowFilter class provides row filtering functionality.
|
||||
/// A filter contains a set of criteria (field name, value and
|
||||
@@ -93,7 +95,7 @@ public:
|
||||
void add(const std::string& name, Comparison comparison, const T& value, LogicOperator op = OP_OR)
|
||||
/// Adds value to the filter.
|
||||
{
|
||||
if (_pRecordSet) _pRecordSet->moveFirst();
|
||||
rewindRecordSet();
|
||||
_comparisonMap.insert(ComparisonMap::value_type(toUpper(name),
|
||||
ComparisonEntry(value, comparison, op)));
|
||||
}
|
||||
@@ -164,6 +166,8 @@ private:
|
||||
RecordSet& recordSet() const;
|
||||
|
||||
Comparison getComparison(const std::string& comp) const;
|
||||
|
||||
void rewindRecordSet();
|
||||
|
||||
Comparisons _comparisons;
|
||||
ComparisonMap _comparisonMap;
|
||||
|
||||
Reference in New Issue
Block a user