libpqxx  7.5.0
transaction.hxx
1 /* Definition of the pqxx::transaction class.
2  * pqxx::transaction represents a standard database transaction.
3  *
4  * DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/transaction instead.
5  *
6  * Copyright (c) 2000-2021, Jeroen T. Vermeulen.
7  *
8  * See COPYING for copyright license. If you did not receive a file called
9  * COPYING with this source code, please notify the distributor of this
10  * mistake, or contact the author.
11  */
12 #ifndef PQXX_H_TRANSACTION
13 #define PQXX_H_TRANSACTION
14 
15 #include "pqxx/compiler-public.hxx"
16 #include "pqxx/internal/compiler-internal-pre.hxx"
17 
18 #include "pqxx/dbtransaction.hxx"
19 
20 namespace pqxx::internal
21 {
23 class PQXX_LIBEXPORT basic_transaction : public dbtransaction
24 {
25 protected:
27  connection &c, zview begin_command, std::string_view tname);
28  basic_transaction(connection &c, zview begin_command, std::string &&tname);
29  basic_transaction(connection &c, zview begin_command);
30 
31  virtual ~basic_transaction() noexcept override = 0;
32 
33 private:
34  virtual void do_commit() override;
35 };
36 } // namespace pqxx::internal
37 
38 
39 namespace pqxx
40 {
45 
47 
67 template<
68  isolation_level ISOLATION = isolation_level::read_committed,
71 {
72 public:
74 
79  transaction(connection &c, std::string_view tname) :
80  internal::basic_transaction{
81  c, internal::begin_cmd<ISOLATION, READWRITE>, tname}
82  {}
83 
85 
90  explicit transaction(connection &c) :
91  internal::basic_transaction{
92  c, internal::begin_cmd<ISOLATION, READWRITE>}
93  {}
94 
95  virtual ~transaction() noexcept override { close(); }
96 };
97 
98 
101 
103 using read_transaction =
105 
107 } // namespace pqxx
108 
109 #include "pqxx/internal/compiler-internal-post.hxx"
110 #endif
write_policy
Should a transaction be read-only, or read-write?
Definition: isolation.hxx:25
Standard back-end transaction, templatised on isolation level.
Definition: transaction.hxx:70
Internal items for libpqxx&#39; own use. Do not use these yourself.
Definition: composite.hxx:73
isolation_level
Transaction isolation levels.
Definition: isolation.hxx:64
transaction(connection &c)
Begin a transaction.
Definition: transaction.hxx:90
Helper base class for the transaction class template.
Definition: transaction.hxx:23
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:25
virtual ~transaction() noexcept override
Definition: transaction.hxx:95
Connection to a database.
Definition: connection.hxx:183
Marker-type wrapper: zero-terminated std::string_view.
Definition: zview.hxx:37
transaction(connection &c, std::string_view tname)
Begin a transaction.
Definition: transaction.hxx:79
Abstract transaction base class: bracket transactions on the database.
Definition: dbtransaction.hxx:52