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
28
pgsql/Pgsql_Canceller.h
Normal file
28
pgsql/Pgsql_Canceller.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef PGSQL_CANCELLER_H
|
||||
#define PGSQL_CANCELLER_H
|
||||
|
||||
#include <string>
|
||||
#include <libpq-fe.h>
|
||||
|
||||
namespace Pgsql {
|
||||
|
||||
/** \brief Wrapper for a cancel object from libpq.
|
||||
*/
|
||||
class Canceller {
|
||||
public:
|
||||
Canceller() = default;
|
||||
Canceller(PGcancel *c);
|
||||
Canceller(const Canceller&) = delete;
|
||||
Canceller& operator=(const Canceller&) = delete;
|
||||
Canceller(Canceller&& rhs);
|
||||
Canceller& operator=(Canceller&& rhs);
|
||||
~Canceller();
|
||||
|
||||
bool cancel(std::string *error);
|
||||
private:
|
||||
PGcancel *m_cancel = nullptr;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // PGSQL_CANCELLER_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue