Query, Explain and Cancel are going throught the asyncdbconnection now.

Todo: Notice processing and error reporting.
This commit is contained in:
Eelke Klein 2017-01-08 09:58:34 +01:00
parent fce51a7b7e
commit a36bf5f7f4
11 changed files with 335 additions and 217 deletions

View file

@ -171,11 +171,15 @@ Canceller::~Canceller()
}
}
void Canceller::cancel()
bool Canceller::cancel(std::string *error)
{
const int errbuf_size = 256;
char errbuf[errbuf_size];
PQcancel(m_cancel, errbuf, errbuf_size);
bool res = PQcancel(m_cancel, errbuf, errbuf_size);
if (!res && error) {
*error = errbuf;
}
return res;
}
@ -272,11 +276,11 @@ bool Connection::sendQuery(const char *query)
return res == 1;
}
std::unique_ptr<Result> Connection::getResult()
std::shared_ptr<Result> Connection::getResult()
{
PGresult *r = PQgetResult(conn);
if (r) {
return std::make_unique<Result>(r);
return std::make_shared<Result>(r);
}
else {
return nullptr;