libpqxx
The C++ client library for PostgreSQL
subtransaction.hxx
Go to the documentation of this file.
1 /* Definition of the pqxx::subtransaction class.
2  *
3  * pqxx::subtransaction is a nested transaction, i.e. one within a transaction.
4  *
5  * DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/subtransaction instead.
6  *
7  * Copyright (c) 2000-2026, 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_SUBTRANSACTION_HXX
14 #define PQXX_SUBTRANSACTION_HXX
15 
16 #if !defined(PQXX_HEADER_PRE)
17 # error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
18 #endif
19 
20 #include "pqxx/dbtransaction.hxx"
21 
22 namespace pqxx
23 {
24 // NOLINTBEGIN(fuchsia-multiple-inheritance)
25 
30 
81  public dbtransaction
82 {
83 public:
85  explicit subtransaction(
86  dbtransaction &t, std::string_view tname, sl = sl::current());
87 
89  explicit subtransaction(dbtransaction &t, sl loc = sl::current()) :
90  subtransaction(t, "", loc)
91  {}
92 
95  subtransaction &t, std::string_view name = ""sv, sl loc = sl::current());
96 
97  subtransaction(subtransaction const &) = delete;
99 
100  ~subtransaction() noexcept override;
101 
102  subtransaction &operator=(subtransaction const &) = delete;
103  subtransaction &operator=(subtransaction &&) = delete;
104 
105 private:
106  [[nodiscard]] std::string quoted_name() const
107  {
108  return quote_name(transaction_focus::name());
109  }
110  void do_commit(sl) override;
111 };
112 
113 // NOLINTEND(fuchsia-multiple-inheritance)
114 } // namespace pqxx
115 #endif
Base class for things that monopolise a transaction's attention.
Definition: transaction_focus.hxx:29
std::string_view name() const &noexcept
Name for this object, if the caller passed one; empty string otherwise.
Definition: transaction_focus.hxx:61
subtransaction(dbtransaction &t, sl loc=sl::current())
Nest a subtransaction nested in another transaction.
Definition: subtransaction.hxx:89
subtransaction(subtransaction &&)=delete
subtransaction(subtransaction const &)=delete
Abstract transaction base class: bracket transactions on the database.
Definition: dbtransaction.hxx:54
"Transaction" nested within another transaction
Definition: subtransaction.hxx:82
#define PQXX_LIBEXPORT
Definition: header-pre.hxx:206
The home of all libpqxx classes, functions, templates, etc.
Definition: array.cxx:26
std::source_location sl
Convenience alias for std::source_location. It's just too long.
Definition: types.hxx:38