libpqxx 7.7.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-2022, 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/dbtransaction.hxx"
16
17namespace pqxx::internal
18{
20class PQXX_LIBEXPORT basic_transaction : public dbtransaction
21{
22protected:
24 connection &c, zview begin_command, std::string_view tname);
25 basic_transaction(connection &c, zview begin_command, std::string &&tname);
26 basic_transaction(connection &c, zview begin_command);
27
28 virtual ~basic_transaction() noexcept override = 0;
29
30private:
31 virtual void do_commit() override;
32};
33} // namespace pqxx::internal
34
35
36namespace pqxx
37{
42
44
64template<
65 isolation_level ISOLATION = isolation_level::read_committed,
68{
69public:
71
76 transaction(connection &c, std::string_view tname) :
77 internal::basic_transaction{
78 c, internal::begin_cmd<ISOLATION, READWRITE>, tname}
79 {}
80
82
86 explicit transaction(connection &c) :
87 internal::basic_transaction{
88 c, internal::begin_cmd<ISOLATION, READWRITE>}
89 {}
90
91 virtual ~transaction() noexcept override { close(); }
92};
93
94
97
101
103} // namespace pqxx
104#endif
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:23
write_policy
Should a transaction be read-only, or read-write?
Definition: isolation.hxx:23
isolation_level
Transaction isolation levels.
Definition: isolation.hxx:62
Internal items for libpqxx' own use. Do not use these yourself.
Definition: composite.hxx:80
const zview begin_cmd
The SQL command for starting a given type of transaction.
Connection to a database.
Definition: connection.hxx:181
Abstract transaction base class: bracket transactions on the database.
Definition: dbtransaction.hxx:50
Helper base class for the transaction class template.
Definition: transaction.hxx:21
virtual ~basic_transaction() noexcept override=0
Standard back-end transaction, templatised on isolation level.
Definition: transaction.hxx:68
virtual ~transaction() noexcept override
Definition: transaction.hxx:91
transaction(connection &c, std::string_view tname)
Begin a transaction.
Definition: transaction.hxx:76
transaction(connection &c)
Begin a transaction.
Definition: transaction.hxx:86
Marker-type wrapper: zero-terminated std::string_view.
Definition: zview.hxx:38