libpqxx  7.2.0
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  // @warning This function will become @c final.
41  virtual void do_commit() override;
42  // @warning This function will become @c final.
43  virtual void do_abort() override;
44 };
45 } // namespace pqxx::internal
46 
47 
48 namespace pqxx
49 {
56 
78 template<isolation_level ISOLATION = read_committed>
80 {
81 public:
87  connection &c, std::string_view name = std::string_view{}) :
88  namedclass{"robusttransaction", name},
90  c,
91  pqxx::internal::begin_cmd<ISOLATION, write_policy::read_write>.c_str()}
92  {}
93 
94  virtual ~robusttransaction() noexcept override { close(); }
95 };
96 
100 } // namespace pqxx
101 
102 #include "pqxx/internal/compiler-internal-post.hxx"
103 #endif
Private namespace for libpqxx&#39;s internal use; do not access.
Definition: composite.hxx:70
Connection to a database.
Definition: connection.hxx:164
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:25
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
virtual ~robusttransaction() noexcept override
Definition: robusttransaction.hxx:94
robusttransaction(connection &c, std::string_view name=std::string_view{})
Definition: robusttransaction.hxx:86
Slightly slower, better-fortified version of transaction.
Definition: robusttransaction.hxx:79