robusttransaction.hxx
#ifndef PQXX_H_ROBUSTTRANSACTION
#define PQXX_H_ROBUSTTRANSACTION
#include "pqxx/compiler-public.hxx"
#include "pqxx/compiler-internal-pre.hxx"
#include "pqxx/dbtransaction.hxx"
// Methods tested in eg. test module test01 are marked with "//[t01]".
namespace pqxx
{
namespace internal
{
class PQXX_LIBEXPORT PQXX_NOVTABLE basic_robusttransaction :
public dbtransaction
{
public:
using isolation_tag = isolation_traits<read_committed>;
virtual ~basic_robusttransaction() =0; //[t16]
protected:
basic_robusttransaction(
connection_base &C,
const std::string &IsolationLevel,
const std::string &table_name=std::string{}); //[t16]
private:
using IDType = unsigned long;
IDType m_record_id = 0;
std::string m_xid;
std::string m_log_table;
std::string m_sequence;
int m_backendpid = -1;
virtual void do_begin() override; //[t18]
virtual void do_commit() override; //[t16]
virtual void do_abort() override; //[t18]
PQXX_PRIVATE void CreateLogTable();
PQXX_PRIVATE void CreateTransactionRecord();
PQXX_PRIVATE std::string sql_delete() const;
PQXX_PRIVATE void DeleteTransactionRecord() noexcept;
PQXX_PRIVATE bool CheckTransactionRecord();
};
} // namespace internal
template<isolation_level ISOLATIONLEVEL=read_committed>
class robusttransaction : public internal::basic_robusttransaction
{
public:
using isolation_tag = isolation_traits<ISOLATIONLEVEL>;
explicit robusttransaction(
connection_base &C,
const std::string &Name=std::string{}) :
namedclass{fullname("robusttransaction",isolation_tag::name()), Name},
internal::basic_robusttransaction(C, isolation_tag::name())
{ Begin(); }
virtual ~robusttransaction() noexcept
{ End(); }
};
} // namespace pqxx
#include "pqxx/compiler-internal-post.hxx"
#endif
pqxx::internal::basic_robusttransaction
Helper base class for the robusttransaction class template.
Definition: robusttransaction.hxx:30
pqxx::internal::basic_robusttransaction::basic_robusttransaction
basic_robusttransaction(connection_base &C, const std::string &IsolationLevel, const std::string &table_name=std::string{})
Definition: robusttransaction.cxx:25
pqxx::internal
Private namespace for libpqxx's internal use; do not access.
Definition: connection_base.hxx:43
pqxx::internal::sleep_seconds
void sleep_seconds(int)
Sleep for the given number of seconds.
Definition: util.cxx:118
pqxx::read_committed
@ read_committed
Definition: isolation.hxx:59
pqxx::dbtransaction::do_abort
virtual void do_abort() override
Sensible default implemented here: abort backend transaction.
Definition: dbtransaction.cxx:88
pqxx::internal::basic_robusttransaction::~basic_robusttransaction
virtual ~basic_robusttransaction()=0
Definition: robusttransaction.cxx:38
pqxx::robusttransaction
Slightly slower, better-fortified version of transaction.
Definition: robusttransaction.hxx:140
pqxx::dbtransaction::do_begin
virtual void do_begin() override
Sensible default implemented here: begin backend transaction.
Definition: dbtransaction.cxx:66
pqxx::robusttransaction::~robusttransaction
virtual ~robusttransaction() noexcept
Definition: robusttransaction.hxx:157
pqxx::internal::reactivation_avoidance_exemption
Scoped exemption to reactivation avoidance.
Definition: connection_base.hxx:915
pqxx::internal::namedclass
Helper base class: object descriptions for error messages and such.
Definition: util.hxx:233
pqxx::to_string
std::string to_string(const field &Obj)
Convert a field to a string.
Definition: result.cxx:451
pqxx::connection_base
connection_base abstract base class; represents a connection to a database.
Definition: connection_base.hxx:139
pqxx::dbtransaction
Abstract base class responsible for bracketing a backend transaction.
Definition: dbtransaction.hxx:62
pqxx::robusttransaction::robusttransaction
robusttransaction(connection_base &C, const std::string &Name=std::string{})
Constructor.
Definition: robusttransaction.hxx:150
pqxx
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:25
pqxx::isolation_level
isolation_level
Transaction isolation levels.
Definition: isolation.hxx:56
pqxx::isolation_traits
Traits class to describe an isolation level; primarly for libpqxx's own use.
Definition: isolation.hxx:65