fixed GH# #1203: Poco::Data::RecordSet should be reusable

This commit is contained in:
Guenter Obiltschnig
2016-03-16 23:15:36 +01:00
parent 6572db8df0
commit 58751caca0
2 changed files with 27 additions and 34 deletions

View File

@@ -70,6 +70,7 @@ RecordSet::RecordSet(const RecordSet& other):
_pFilter(other._pFilter),
_totalRowCount(other._totalRowCount)
{
if(_pFilter) _pFilter->duplicate();
}
@@ -79,7 +80,7 @@ RecordSet::~RecordSet()
{
delete _pBegin;
delete _pEnd;
if(_pFilter) _pFilter->release();
if (_pFilter) _pFilter->release();
RowMap::iterator it = _rowMap.begin();
RowMap::iterator end = _rowMap.end();
@@ -92,6 +93,22 @@ RecordSet::~RecordSet()
}
void RecordSet::reset(const Statement& stmt)
{
delete _pBegin;
_pBegin = 0;
delete _pEnd;
_pEnd = 0;
_currentRow = 0;
_totalRowCount = UNKNOWN_TOTAL_ROW_COUNT;
Statement::operator = (stmt);
_pBegin = new RowIterator(this, 0 == rowsExtracted());
_pEnd = new RowIterator(this, true);
}
Poco::Dynamic::Var RecordSet::value(std::size_t col, std::size_t row, bool useFilter) const
{
if (useFilter && isFiltered() && !isAllowed(row))