[SF 2593784] SVN trunk RowIterator

This commit is contained in:
Aleksandar Fabijanic 2009-02-12 19:43:22 +00:00
parent 08efaa0572
commit a8c39370be
6 changed files with 44 additions and 10 deletions

View File

@ -3036,6 +3036,13 @@ void SQLExecutor::rowIterator()
v.push_back(Tuple<int, double, std::string>(3, 3.5f, "5"));
v.push_back(Tuple<int, double, std::string>(4, 4.5f, "6"));
try { session() << "DELETE FROM Vectors", now; }
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
RecordSet rset0(session(), "SELECT * FROM Vectors");
assert (rset0.begin() == rset0.end());
try { session() << "INSERT INTO Vectors VALUES (?,?,?)", use(v), now; }
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
@ -3058,7 +3065,7 @@ void SQLExecutor::rowIterator()
RowFilter::Ptr pRF = new RowFilter(&rset);
assert (pRF->isEmpty());
pRF->add("str0", RowFilter::VALUE_EQUAL, 1);
pRF->add("str0", RowFilter::VALUE_EQUAL, "3");
assert (!pRF->isEmpty());
it = rset.begin();
end = rset.end();
@ -3067,7 +3074,6 @@ void SQLExecutor::rowIterator()
assert (it->get(0) == i);
assert (1 == i);
}
}

View File

@ -450,8 +450,7 @@ inline Data_API std::ostream& operator << (std::ostream &os, const RecordSet& rs
inline std::size_t RecordSet::totalRowCount() const
{
poco_assert (extractions().size());
return extractions()[0].get()->numOfRowsHandled();
return rowsExtracted();
}

View File

@ -369,6 +369,10 @@ public:
const std::string& getStorage() const;
/// Returns the internal storage type for the stamement.
std::size_t rowsExtracted(int dataSet = -1) const;
/// Returns the number of rows returned for current data set.
/// Default value (-1) indicates current data set (if any).
std::size_t extractionCount() const;
/// Returns the number of extraction storage buffers associated
/// with the current data set.
@ -701,6 +705,12 @@ inline std::size_t Statement::extractionCount() const
}
inline std::size_t Statement::rowsExtracted(int dataSet) const
{
return _pImpl->rowsExtracted(dataSet);
}
inline std::size_t Statement::dataSetCount() const
{
return _pImpl->dataSetCount();

View File

@ -218,9 +218,13 @@ protected:
virtual AbstractBinder& binder() = 0;
/// Returns the concrete binder used by the statement.
int columnsExtracted() const;
std::size_t columnsExtracted() const;
/// Returns the number of columns that the extractors handle.
std::size_t rowsExtracted(int dataSet = -1) const;
/// Returns the number of rows returned for current data set.
/// Default value (-1) indicates current data set (if any).
const AbstractBindingVec& bindings() const;
/// Returns the bindings.
@ -486,7 +490,7 @@ inline AbstractExtractionVec& StatementImpl::extractions()
}
inline int StatementImpl::columnsExtracted() const
inline std::size_t StatementImpl::columnsExtracted() const
{
poco_assert (_curDataSet < _columnsExtracted.size());
return _columnsExtracted[_curDataSet];

View File

@ -54,7 +54,7 @@ namespace Data {
RecordSet::RecordSet(const Statement& rStatement):
Statement(rStatement),
_currentRow(0),
_pBegin(new RowIterator(this, 0 == extractionCount())),
_pBegin(new RowIterator(this, 0 == rowsExtracted())),
_pEnd(new RowIterator(this, true)),
_pFilter(0)
{
@ -66,7 +66,7 @@ RecordSet::RecordSet(Session& rSession,
RowFormatter* pRowFormatter):
Statement((rSession << query, now)),
_currentRow(0),
_pBegin(new RowIterator(this, 0 == extractionCount())),
_pBegin(new RowIterator(this, 0 == rowsExtracted())),
_pEnd(new RowIterator(this, true)),
_pFilter(0)
{
@ -77,7 +77,7 @@ RecordSet::RecordSet(Session& rSession,
RecordSet::RecordSet(const RecordSet& other):
Statement(other.impl().duplicate()),
_currentRow(other._currentRow),
_pBegin(new RowIterator(this, 0 == extractionCount())),
_pBegin(new RowIterator(this, 0 == rowsExtracted())),
_pEnd(new RowIterator(this, true)),
_pFilter(other._pFilter)
{
@ -161,7 +161,8 @@ Poco::Dynamic::Var RecordSet::value(const std::string& name, std::size_t row, bo
Row& RecordSet::row(std::size_t pos)
{
if (pos > rowCount() - 1)
std::size_t rowCnt = rowCount();
if (0 == rowCnt || pos > rowCnt - 1)
throw RangeException("Invalid recordset row requested.");
RowMap::const_iterator it = _rowMap.find(pos);

View File

@ -394,6 +394,20 @@ void StatementImpl::removeBind(const std::string& name)
}
std::size_t StatementImpl::rowsExtracted(int dataSet) const
{
if (-1 == dataSet) dataSet = _curDataSet;
if (extractions().size() > 0)
{
poco_assert (dataSet >= 0);
if (_extractors[dataSet].size() > 0)
return _extractors[dataSet][0]->numOfRowsHandled();
}
return 0;
}
void StatementImpl::formatSQL(std::vector<Any>& arguments)
{
std::string sql;