libpqxx
The C++ client library for PostgreSQL
nontransaction.hxx
Go to the documentation of this file.
1 /* Definition of the pqxx::nontransaction class.
2  *
3  * pqxx::nontransaction provides nontransactional database access
4  *
5  * DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/nontransaction 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_NONTRANSACTION_HXX
14 #define PQXX_NONTRANSACTION_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/connection.hxx"
21 #include "pqxx/result.hxx"
22 #include "pqxx/transaction.hxx"
23 
24 namespace pqxx
25 {
26 using namespace std::literals;
27 
29 
61 {
62 public:
64 
69  explicit nontransaction(
70  connection &cx, std::string_view tname = ""sv, sl loc = sl::current()) :
71  transaction_base{cx, tname, std::shared_ptr<std::string>{}, loc}
72  {
73  register_transaction();
74  }
75 
76  nontransaction() = delete;
77  nontransaction(nontransaction const &) = delete;
79  ~nontransaction() override { close(sl::current()); }
80 
83 
84 private:
85  void do_commit(sl) override {}
86 };
87 } // namespace pqxx
88 #endif
Connection to a database.
Definition: connection.hxx:273
nontransaction & operator=(nontransaction &&)=delete
nontransaction(connection &cx, std::string_view tname=""sv, sl loc=sl::current())
Constructor.
Definition: nontransaction.hxx:69
~nontransaction() override
Definition: nontransaction.hxx:79
nontransaction(nontransaction const &)=delete
nontransaction & operator=(nontransaction const &)=delete
nontransaction(nontransaction &&)=delete
Simple "transaction" class offering no transactional integrity.
Definition: nontransaction.hxx:61
Interface definition (and common code) for "transaction" classes.
Definition: transaction_base.hxx:151
#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