libpqxx  7.0.5
robusttransaction.hxx
1 /* Definition of the pqxx::robusttransaction class.
2  *
3  * pqxx::robusttransaction is a slower but safer transaction class.
4  *
5  * DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/robusttransaction instead.
6  *
7  * Copyright (c) 2000-2020, Jeroen T. Vermeulen.
8  *
9  * See COPYING for copyright license. If you did not receive a file called
10  * COPYING with this source code, please notify the distributor of this
11  * mistake, or contact the author.
12  */
13 #ifndef PQXX_H_ROBUSTTRANSACTION
14 #define PQXX_H_ROBUSTTRANSACTION
15 
16 #include "pqxx/compiler-public.hxx"
17 #include "pqxx/internal/compiler-internal-pre.hxx"
18 
19 #include "pqxx/dbtransaction.hxx"
20 
21 namespace pqxx::internal
22 {
24 class PQXX_LIBEXPORT PQXX_NOVTABLE basic_robusttransaction
25  : public dbtransaction
26 {
27 public:
28  virtual ~basic_robusttransaction() override = 0;
29 
30 protected:
31  basic_robusttransaction(connection &c, char const begin_command[]);
32 
33 private:
34  using IDType = unsigned long;
35 
36  std::string m_conn_string;
37  std::string m_xid;
38  int m_backendpid = -1;
39 
40  virtual void do_commit() override;
41  virtual void do_abort() override;
42 };
43 } // namespace pqxx::internal
44 
45 
46 namespace pqxx
47 {
54 
76 template<isolation_level ISOLATION = read_committed>
78 {
79 public:
85  connection &c, std::string_view name = std::string_view{}) :
86  namedclass{"robusttransaction", name},
88  c,
89  pqxx::internal::begin_cmd<ISOLATION, write_policy::read_write>.c_str()}
90  {}
91 
92  virtual ~robusttransaction() noexcept override { close(); }
93 };
94 
98 } // namespace pqxx
99 
100 #include "pqxx/internal/compiler-internal-post.hxx"
101 #endif
Private namespace for libpqxx&#39;s internal use; do not access.
Definition: connection.hxx:59
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:25
Connection to a database.
Definition: connection.hxx:135
Abstract transaction base class: bracket transactions on the database.
Definition: dbtransaction.hxx:52
Helper base class for the robusttransaction class template.
Definition: robusttransaction.hxx:24
robusttransaction(connection &c, std::string_view name=std::string_view{})
Definition: robusttransaction.hxx:84
Slightly slower, better-fortified version of transaction.
Definition: robusttransaction.hxx:77
virtual ~robusttransaction() noexcept override
Definition: robusttransaction.hxx:92