Created Pgsql::Transaction class for handling of transactions. It auto rollsback if no commit has been done.
Also moved some code out of the connection files to their own files.
This commit is contained in:
parent
255b2ec970
commit
e32c82ac6f
12 changed files with 394 additions and 130 deletions
|
|
@ -7,49 +7,6 @@
|
|||
|
||||
using namespace Pgsql;
|
||||
|
||||
|
||||
|
||||
|
||||
Canceller::Canceller(PGcancel *c)
|
||||
: m_cancel(c)
|
||||
{}
|
||||
|
||||
Canceller::Canceller(Canceller&& rhs)
|
||||
: m_cancel(rhs.m_cancel)
|
||||
{
|
||||
rhs.m_cancel = nullptr;
|
||||
}
|
||||
|
||||
Canceller& Canceller::operator=(Canceller&& rhs)
|
||||
{
|
||||
if (m_cancel) {
|
||||
PQfreeCancel(m_cancel);
|
||||
}
|
||||
m_cancel = rhs.m_cancel;
|
||||
rhs.m_cancel = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Canceller::~Canceller()
|
||||
{
|
||||
if (m_cancel) {
|
||||
PQfreeCancel(m_cancel);
|
||||
}
|
||||
}
|
||||
|
||||
bool Canceller::cancel(std::string *error)
|
||||
{
|
||||
const int errbuf_size = 256;
|
||||
char errbuf[errbuf_size];
|
||||
bool res = PQcancel(m_cancel, errbuf, errbuf_size);
|
||||
if (!res && error) {
|
||||
*error = errbuf;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Connection::Connection() = default;
|
||||
|
||||
Connection::~Connection()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue