libpqxx
robusttransaction.hxx
1 
13 #ifndef PQXX_H_ROBUSTTRANSACTION
14 #define PQXX_H_ROBUSTTRANSACTION
15 
16 #include "pqxx/compiler-public.hxx"
17 #include "pqxx/compiler-internal-pre.hxx"
18 
19 #include "pqxx/dbtransaction.hxx"
20 
21 
22 // Methods tested in eg. test module test01 are marked with "//[t01]".
23 
24 namespace pqxx
25 {
26 
27 namespace internal
28 {
30 class PQXX_LIBEXPORT PQXX_NOVTABLE basic_robusttransaction :
31  public dbtransaction
32 {
33 public:
36 
37  virtual ~basic_robusttransaction() =0; //[t16]
38 
39 protected:
41  connection_base &C,
42  const std::string &IsolationLevel,
43  const std::string &table_name=std::string{}); //[t16]
44 
45 private:
46  using IDType = unsigned long;
47  IDType m_record_id = 0;
48  std::string m_xid;
49  std::string m_log_table;
50  std::string m_sequence;
51  int m_backendpid = -1;
52 
53  virtual void do_begin() override; //[t18]
54  virtual void do_commit() override; //[t16]
55  virtual void do_abort() override; //[t18]
56 
57  PQXX_PRIVATE void CreateLogTable();
58  PQXX_PRIVATE void CreateTransactionRecord();
59  PQXX_PRIVATE std::string sql_delete() const;
60  PQXX_PRIVATE void DeleteTransactionRecord() noexcept;
61  PQXX_PRIVATE bool CheckTransactionRecord();
62 };
63 } // namespace internal
64 
65 
72 
139 template<isolation_level ISOLATIONLEVEL=read_committed>
141 {
142 public:
144 
146 
151  connection_base &C,
152  const std::string &Name=std::string{}) :
153  namedclass{fullname("robusttransaction",isolation_tag::name()), Name},
154  internal::basic_robusttransaction(C, isolation_tag::name())
155  { Begin(); }
156 
157  virtual ~robusttransaction() noexcept
158  { End(); }
159 };
160 
165 } // namespace pqxx
166 
167 #include "pqxx/compiler-internal-post.hxx"
168 #endif
virtual ~robusttransaction() noexcept
Definition: robusttransaction.hxx:157
Helper base class for the robusttransaction class template.
Definition: robusttransaction.hxx:30
connection_base abstract base class; represents a connection to a database.
Definition: connection_base.hxx:139
robusttransaction(connection_base &C, const std::string &Name=std::string{})
Constructor.
Definition: robusttransaction.hxx:150
Slightly slower, better-fortified version of transaction.
Definition: robusttransaction.hxx:140
Abstract base class responsible for bracketing a backend transaction.
Definition: dbtransaction.hxx:62
Traits class to describe an isolation level; primarly for libpqxx&#39;s own use.
Definition: isolation.hxx:65
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:25