libpqxx
The C++ client library for PostgreSQL
connection-transaction.hxx
Go to the documentation of this file.
1 #ifndef PQXX_INTERNAL_GATES_CONNECTION_TRANSACTION_HXX
2 #define PQXX_INTERNAL_GATES_CONNECTION_TRANSACTION_HXX
3 
5 
6 namespace pqxx
7 {
8 class connection;
9 } // namespace pqxx
10 
11 namespace pqxx::internal::gate
12 {
13 class PQXX_PRIVATE connection_transaction final : callgate<connection>
14 {
15  friend class pqxx::transaction_base;
16 
17  explicit constexpr connection_transaction(reference x) noexcept : super(x) {}
18 
19  template<typename STRING>
20  result exec(STRING const &query, std::string_view desc, sl loc)
21  {
22  return home().exec(query, desc, loc);
23  }
24 
25  template<typename STRING> result exec(STRING query, sl loc)
26  {
27  return home().exec(query, "", loc);
28  }
29 
31  {
32  home().register_transaction(t);
33  }
34  void unregister_transaction(transaction_base *t) noexcept
35  {
36  home().unregister_transaction(t);
37  }
38 
39  auto read_copy_line(sl loc) { return home().read_copy_line(loc); }
40  void write_copy_line(std::string_view line, sl loc)
41  {
42  home().write_copy_line(line, loc);
43  }
44  void end_copy_write(sl loc) { home().end_copy_write(loc); }
45 
46  result exec_prepared(
47  std::string_view statement, internal::c_params const &args, sl loc)
48  {
49  return home().exec_prepared(statement, args, loc);
50  }
51 
52  result
53  exec_params(std::string_view query, internal::c_params const &args, sl loc)
54  {
55  return home().exec_params(query, args, loc);
56  }
57 };
58 } // namespace pqxx::internal::gate
59 #endif
Connection to a database.
Definition: connection.hxx:273
Base class for call gates.
Definition: callgate.hxx:55
Definition: connection-transaction.hxx:14
Result set containing data returned by a query or command.
Definition: result.hxx:101
result exec_prepared(zview statement, Args &&...args)
Execute a prepared statement, with optional arguments.
Definition: transaction_base.hxx:972
auto query(std::string_view query, sl loc=sl::current())
Execute query, read full results, then iterate rows of data.
Definition: transaction_base.hxx:678
void register_transaction()
Register this transaction with the connection.
Definition: transaction_base.cxx:101
result exec_params(std::string_view query, Args &&...args)
Execute an SQL statement with parameters.
Definition: transaction_base.hxx:745
result exec(std::string_view query, std::string_view desc, sl=sl::current())
Execute a command.
Definition: transaction_base.cxx:286
Interface definition (and common code) for "transaction" classes.
Definition: transaction_base.hxx:151
#define PQXX_PRIVATE
Definition: header-pre.hxx:207
Definition: connection.hxx:94
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