libpqxx
The C++ client library for PostgreSQL
nontransaction.hxx
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-2025, 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_NONTRANSACTION
14 #define PQXX_H_NONTRANSACTION
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 
60 class PQXX_LIBEXPORT nontransaction final : public transaction_base
61 {
62 public:
64 
69  nontransaction(connection &cx, std::string_view tname = ""sv) :
70  transaction_base{cx, tname, std::shared_ptr<std::string>{}}
71  {
72  register_transaction();
73  }
74 
75  virtual ~nontransaction() override { close(); }
76 
77 private:
78  virtual void do_commit() override {}
79 };
80 } // namespace pqxx
81 #endif
nontransaction(connection &cx, std::string_view tname=""sv)
Constructor.
Definition: nontransaction.hxx:69
The home of all libpqxx classes, functions, templates, etc.
Definition: array.cxx:26
Connection to a database.
Definition: connection.hxx:278
Simple "transaction" class offering no transactional integrity.
Definition: nontransaction.hxx:60
Interface definition (and common code) for "transaction" classes.
Definition: transaction_base.hxx:150