Skip to content

Commit

Permalink
Merge pull request pocoproject#11 in FSF_POCO/upstream from ~LUTKOS/u…
Browse files Browse the repository at this point in the history
…pstream:ms-develop to ms-develop

* commit '6021dc6dc522445363c45f01b506cd22164bf517':
  Added support for result sets, which have got zero columns. That can be returned by Sybase sp_help
  • Loading branch information
Kostya Lutsenko authored and Kostya Lutsenko committed Jul 13, 2015
2 parents 44ec0e0 + 6021dc6 commit eeb1882
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Data/ODBC/include/Poco/Data/ODBC/ODBCStatementImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class ODBC_API ODBCStatementImpl: public Poco::Data::StatementImpl

void getData();

void addPreparator();
bool addPreparator(bool addAlways = true);
void fillColumns(size_t dataSetPos);
void checkError(SQLRETURN rc, const std::string& msg="");
bool nextResultSet();
Expand Down
22 changes: 16 additions & 6 deletions Data/ODBC/src/ODBCStatementImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,25 +137,34 @@ void ODBCStatementImpl::makeInternalExtractors()
}


void ODBCStatementImpl::addPreparator()
bool ODBCStatementImpl::addPreparator(bool addAlways)
{
Preparator* prep = 0;
if (0 == _preparations.size())
{
std::string statement(toString());
if (statement.empty())
throw ODBCException("Empty statements are illegal");

Preparator::DataExtraction ext = session().getFeature("autoExtract") ?
Preparator::DataExtraction ext = session().getFeature("autoExtract") ?
Preparator::DE_BOUND : Preparator::DE_MANUAL;

std::size_t maxFieldSize = AnyCast<std::size_t>(session().getProperty("maxFieldSize"));

_preparations.push_back(new Preparator(_stmt, statement, maxFieldSize, ext, _numericConversion, _isPostgres));
prep = new Preparator(_stmt, statement, maxFieldSize, ext, _numericConversion, _isPostgres);
}
else
_preparations.push_back(new Preparator(*_preparations[0]));
prep = new Preparator(*_preparations[0]);
if (addAlways || prep->columns() > 0)
{
_preparations.push_back(prep);
_extractors.push_back(new Extractor(_stmt, _preparations.back()));

_extractors.push_back(new Extractor(_stmt, _preparations.back()));
return true;
}

delete prep;
return false;
}


Expand Down Expand Up @@ -336,7 +345,8 @@ bool ODBCStatementImpl::hasNext()
}
else {
if (nextResultSet()) {
addPreparator();
if (!addPreparator(false)) // skip the result set if it has no columns
continue;
fillColumns(currentDataSet() + 1);
makeExtractors(_preparations.back()->columns(), static_cast<Position::Position_Type>(currentDataSet() + 1));
activateNextDataSet();
Expand Down

0 comments on commit eeb1882

Please sign in to comment.