libpqxx
The C++ client library for PostgreSQL
connection.hxx File Reference
#include <cstddef>
#include <ctime>
#include <format>
#include <functional>
#include <initializer_list>
#include <list>
#include <map>
#include <memory>
#include <ranges>
#include <string_view>
#include <tuple>
#include <utility>
#include "pqxx/errorhandler.hxx"
#include "pqxx/except.hxx"
#include "pqxx/internal/connection-string.hxx"
#include "pqxx/params.hxx"
#include "pqxx/result.hxx"
#include "pqxx/separated_list.hxx"
#include "pqxx/strconv.hxx"
#include "pqxx/types.hxx"
#include "pqxx/util.hxx"
#include "pqxx/zview.hxx"
#include "pqxx/internal/ignore-deprecated-pre.hxx"
#include "pqxx/internal/ignore-deprecated-post.hxx"
+ Include dependency graph for connection.hxx:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  pqxx::notification
 An incoming notification. More...
 
class  pqxx::connection
 Connection to a database. More...
 
class  pqxx::connecting
 An ongoing, non-blocking stepping stone to a connection. More...
 

Namespaces

 pqxx
 The home of all libpqxx classes, functions, templates, etc.
 
 pqxx::internal
 Private namespace for libpqxx's internal use; do not access.
 
 pqxx::internal::gate
 

Typedefs

using pqxx::table_path = std::initializer_list< std::string_view >
 Representation of a PostgreSQL table path. More...
 

Enumerations

enum  pqxx::skip_init : int { pqxx::nothing , pqxx::openssl , pqxx::crypto }
 Flags for skipping initialisation of SSL-related libraries. More...
 
enum class  pqxx::error_verbosity : int { pqxx::terse = 0 , pqxx::normal = 1 , pqxx::verbose = 2 }
 Error verbosity levels. More...
 

Functions

PQXX_COLD PQXX_LIBEXPORT void pqxx::internal::skip_init_ssl (int skips) noexcept
 Control OpenSSL/crypto library initialisation. More...
 
template<skip_init... SKIP>
void pqxx::skip_init_ssl () noexcept
 Control initialisation of OpenSSL and libcrypto libraries. More...
 

Variables

template<typename T >
concept pqxx::ZKey_ZValues
 Concept: T is a range of pairs of zero-terminated strings. More...
 

Class Documentation

◆ pqxx::notification

struct pqxx::notification

An incoming notification.

PostgreSQL extends SQL with a "message bus" using the LISTEN and NOTIFY commands. In libpqxx you use connection::listen() and (optionally) transaction_base::notify().

When you receive a notification for which you have been listening, your handler receives it in the form of a notification object.

Warning
These structs are meant for extremely short lifespans: the fields reference memory that may become invalid as soon as your handler has been called.
+ Collaboration diagram for pqxx::notification:
Class Members
int backend_pid Process ID of the backend that sent the notification.

This can be useful in situations where a multiple clients are listening on the same channel, and also send notifications on it.

In those situations, it often makes sense for a client to ignore its own incoming notifications, but handle all others on the same channel in some way.

To check for that, compare this process ID to the return value of the connection's backendpid().

zview channel Channel name.

The notification logic will only pass the notification to a handler which was registered to listen on this exact name.

connection & conn The connection which received the notification.

There will be no backend transaction active on the connection when your handler gets called, but there may be a nontransaction. (This is a special transaction type in libpqxx which does not start a transaction on the backend.)

zview payload Optional payload text.

If the notification did not carry a payload, the string will be empty.