Added getResultNoThrow as the AsyncDBCOnnection doesn't like exceptions.

This commit is contained in:
eelke 2018-12-23 12:39:53 +01:00
parent 43f8117bbd
commit 471139ba4d
3 changed files with 13 additions and 1 deletions

View file

@ -138,7 +138,7 @@ void ASyncDBConnection::async_query_handler(boost::system::error_code ec, std::s
bool finished = false; bool finished = false;
if (m_connection.consumeInput()) { if (m_connection.consumeInput()) {
while ( ! finished && ! m_connection.isBusy()) { while ( ! finished && ! m_connection.isBusy()) {
auto res = m_connection.getResult(); auto res = m_connection.getResultNoThrow();
qint64 ms = m_timer.restart(); qint64 ms = m_timer.restart();
on_result(res, ms); on_result(res, ms);
if (res == nullptr) { if (res == nullptr) {

View file

@ -159,6 +159,17 @@ std::shared_ptr<Result> Connection::getResult()
} }
} }
std::shared_ptr<Result> Connection::getResultNoThrow()
{
PGresult *r = PQgetResult(conn);
if (r) {
return std::make_shared<Result>(r);
}
else {
return nullptr;
}
}
bool Connection::consumeInput() bool Connection::consumeInput()
{ {
int res = PQconsumeInput(conn); int res = PQconsumeInput(conn);

View file

@ -98,6 +98,7 @@ namespace Pgsql {
bool sendQueryParams(const char * command, const Params &params); bool sendQueryParams(const char * command, const Params &params);
std::shared_ptr<Result> getResult(); std::shared_ptr<Result> getResult();
std::shared_ptr<Result> getResultNoThrow();
bool consumeInput(); bool consumeInput();
bool isBusy(); bool isBusy();