libpqxx
pqxx::basic_connection< CONNECTPOLICY > Class Template Reference

Base-class template for all libpqxx connection types. More...

#include <basic_connection.hxx>

Inheritance diagram for pqxx::basic_connection< CONNECTPOLICY >:

Public Member Functions

 basic_connection ()
 
 basic_connection (const std::string &opt)
 
 basic_connection (const char opt[])
 See: basic_connection(const std::string &opt) More...
 
 basic_connection (std::nullptr_t)
 
 ~basic_connection () noexcept
 
const std::string & options () const noexcept
 
- Public Member Functions inherited from pqxx::connection_base
void disconnect () noexcept
 Explicitly close connection. More...
 
bool PQXX_PURE is_open () const noexcept
 Is this connection open at the moment? More...
 
void process_notice (const char[]) noexcept
 Invoke notice processor function. The message should end in newline. More...
 
void process_notice (const std::string &) noexcept
 Invoke notice processor function. Newline at end is recommended. More...
 
void trace (std::FILE *) noexcept
 Enable tracing to a given output stream, or nullptr to disable. More...
 
void set_client_encoding (const std::string &Encoding)
 Set client-side character encoding. More...
 
void set_variable (const std::string &Var, const std::string &Value)
 Set session variable. More...
 
std::string get_variable (const std::string &)
 Read session variable. More...
 
template<typename TRANSACTOR >
void perform (const TRANSACTOR &T, int Attempts)
 
template<typename TRANSACTOR >
void perform (const TRANSACTOR &T)
 
std::string adorn_name (const std::string &)
 Suffix unique number to name to make it unique within session context. More...
 
std::string esc (const char str[])
 Escape string for use as SQL string literal on this connection. More...
 
std::string esc (const char str[], size_t maxlen)
 Escape string for use as SQL string literal on this connection. More...
 
std::string esc (const std::string &str)
 Escape string for use as SQL string literal on this connection. More...
 
std::string esc_raw (const unsigned char str[], size_t len)
 Escape binary string for use as SQL string literal on this connection. More...
 
std::string unesc_raw (const std::string &text)
 Unescape binary data, e.g. from a table field or notification payload. More...
 
std::string unesc_raw (const char *text)
 Unescape binary data, e.g. from a table field or notification payload. More...
 
std::string quote_raw (const unsigned char str[], size_t len)
 Escape and quote a string of binary data. More...
 
std::string quote_name (const std::string &identifier)
 Escape and quote an SQL identifier for use in a query. More...
 
template<typename T >
std::string quote (const T &t)
 Represent object as SQL string, including quoting & escaping. More...
 
std::string quote (const binarystring &)
 
void cancel_query ()
 Attempt to cancel the ongoing query, if any. More...
 
void set_verbosity (error_verbosity verbosity) noexcept
 Set session verbosity. More...
 
error_verbosity get_verbosity () const noexcept
 Retrieve current error verbosity. More...
 
std::vector< errorhandler * > get_errorhandlers () const
 Return pointers to the active errorhandlers. More...
 
void activate ()
 Explicitly activate deferred or deactivated connection. More...
 
void deactivate ()
 Explicitly deactivate connection. More...
 
void inhibit_reactivation (bool inhibit)
 Disallow (or permit) connection recovery. More...
 
void simulate_failure ()
 Make the connection fail. More...
 
const char * dbname ()
 Name of database we're connected to, if any. More...
 
const char * username ()
 Database user ID we're connected under, if any. More...
 
const char * hostname ()
 Address of server, or nullptr if none specified (i.e. default or local) More...
 
const char * port ()
 Server port number we're connected to. More...
 
int PQXX_PURE backendpid () const noexcept
 Process ID for backend process. More...
 
int PQXX_PURE sock () const noexcept
 Socket currently used for connection, or -1 for none. Use with care! More...
 
int get_notifs ()
 Check for pending notifications and take appropriate action. More...
 
int await_notification ()
 Wait for a notification to come in. More...
 
int await_notification (long seconds, long microseconds)
 Wait for a notification to come in, or for given timeout to pass. More...
 
void prepare (const std::string &name, const std::string &definition)
 Define a prepared statement. More...
 
void prepare (const std::string &definition)
 Define a nameless prepared statement. More...
 
void unprepare (const std::string &name)
 Drop prepared statement. More...
 
void prepare_now (const std::string &name)
 Request that prepared statement be registered with the server. More...
 
bool supports (capability c) const noexcept
 Does this connection seem to support the given capability? More...
 
int PQXX_PURE protocol_version () const noexcept
 What version of the PostgreSQL protocol is this connection using? More...
 
int PQXX_PURE server_version () const noexcept
 What version of the PostgreSQL server are we connected to? More...
 

Additional Inherited Members

- Public Types inherited from pqxx::connection_base
enum  error_verbosity { terse =0, normal =1, verbose =2 }
 Error verbosity levels. More...
 
enum  capability { cap_end }
 Session capabilities. More...
 
- Protected Member Functions inherited from pqxx::connection_base
 connection_base (connectionpolicy &)
 
void init ()
 
void close () noexcept
 
void wait_read () const
 
void wait_read (long seconds, long microseconds) const
 
void wait_write () const
 

Detailed Description

template<typename CONNECTPOLICY>
class pqxx::basic_connection< CONNECTPOLICY >

Base-class template for all libpqxx connection types.

Combines connection_base (the highly complex class implementing essentially all connection-related functionality) with a connection policy (a simpler helper class determining the rules that govern the process of setting up the underlying connection to the backend).

The pattern used to combine these classes is the same as for basic_transaction. Through use of the template mechanism, the policy object is embedded in the basic_connection object so that it does not need to be allocated separately. This also avoids the need for virtual functions in this class.

Constructor & Destructor Documentation

◆ basic_connection() [1/4]

template<typename CONNECTPOLICY >
pqxx::basic_connection< CONNECTPOLICY >::basic_connection ( )

◆ basic_connection() [2/4]

template<typename CONNECTPOLICY >
pqxx::basic_connection< CONNECTPOLICY >::basic_connection ( const std::string &  opt)
explicit

The parsing of options is the same as libpq's PQconnect. See: https://www.postgresql.org/docs/10/static/libpq-connect.html

References pqxx::connection_base::init().

◆ basic_connection() [3/4]

template<typename CONNECTPOLICY >
pqxx::basic_connection< CONNECTPOLICY >::basic_connection ( const char  opt[])
explicit

◆ basic_connection() [4/4]

template<typename CONNECTPOLICY >
pqxx::basic_connection< CONNECTPOLICY >::basic_connection ( std::nullptr_t  )
explicit

◆ ~basic_connection()

template<typename CONNECTPOLICY >
pqxx::basic_connection< CONNECTPOLICY >::~basic_connection ( )
noexcept

Member Function Documentation

◆ options()

template<typename CONNECTPOLICY >
const std::string& pqxx::basic_connection< CONNECTPOLICY >::options ( ) const
noexcept

The documentation for this class was generated from the following file: