libpqxx  v4.0-1
C++ library for PostgreSQL
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pqxx Namespace Reference

The home of all libpqxx classes, functions, templates, etc. More...

Namespaces

namespace  internal
 Private namespace for libpqxx's internal use; do not access.
 
namespace  prepare
 Dedicated namespace for helper types related to prepared statements.
 

Classes

class  argument_error
 Invalid argument passed to libpqxx, similar to std::invalid_argument. More...
 
class  basic_connection
 The ultimate template that defines a connection type. More...
 
class  basic_fieldstream
 Input stream that gets its data from a result field. More...
 
class  basic_ilostream
 Input stream that gets its data from a large object. More...
 
class  basic_lostream
 Stream that reads and writes a large object. More...
 
class  basic_olostream
 Output stream that writes data back to a large object. More...
 
class  basic_robusttransaction
 
class  basic_transaction
 
class  binarystring
 
class  broken_connection
 Exception class for lost or failed backend connection. More...
 
class  check_violation
 
class  connect_async
 Asynchronous connection policy; connects "in the background". More...
 
class  connect_direct
 Connection policy; creates an immediate connection to a database. More...
 
class  connect_lazy
 Lazy connection policy; causes connection to be deferred until first use. More...
 
class  connect_null
 Nonfunctional, always-down connection policy for testing/debugging purposes. More...
 
class  connection_base
 connection_base abstract base class; represents a connection to a database. More...
 
class  connectionpolicy
 
class  const_result_iterator
 Iterator for rows (tuples) in a result. Use as result::const_iterator. More...
 
class  const_reverse_result_iterator
 Reverse iterator for result. Use as result::const_reverse_iterator. More...
 
class  const_reverse_tuple_iterator
 Reverse iterator for a tuple. Use as tuple::const_reverse_iterator. More...
 
class  const_tuple_iterator
 Iterator for fields in a tuple. Use as tuple::const_iterator. More...
 
class  conversion_error
 
class  cursor_base
 Common definitions for cursor types. More...
 
class  data_exception
 Error in data provided to SQL statement. More...
 
class  dbtransaction
 
class  disk_full
 
class  errorhandler
 Base class for error-handler callbacks. More...
 
class  failure
 Run-time failure encountered by libpqxx, similar to std::runtime_error. More...
 
class  feature_not_supported
 Database feature not supported in current setup. More...
 
class  field
 Reference to a field in a result set. More...
 
class  field_streambuf
 
class  foreign_key_violation
 
class  icursor_iterator
 Approximate istream_iterator for icursorstream. More...
 
class  icursorstream
 Simple read-only cursor represented as a stream of results. More...
 
class  in_doubt_error
 "Help, I don't know whether transaction was committed successfully!" More...
 
class  insufficient_privilege
 
class  insufficient_resources
 Resource shortage on the server. More...
 
class  integrity_constraint_violation
 
class  internal_error
 Internal error in libpqxx library. More...
 
class  invalid_cursor_name
 
class  invalid_cursor_state
 
class  invalid_sql_statement_name
 
struct  isolation_traits
 Traits class to describe an isolation level; primarly for libpqxx's own use. More...
 
class  items
 Container of items with easy contents initialization and string rendering. More...
 
class  largeobject
 Identity of a large object. More...
 
class  largeobject_streambuf
 Streambuf to use large objects in standard I/O streams. More...
 
class  largeobjectaccess
 Accessor for large object's contents. More...
 
class  nontransaction
 
class  not_null_violation
 
class  notification_receiver
 
class  notify_listener
 Obsolete notification receiver. More...
 
class  out_of_memory
 
class  pipeline
 Processes several queries in FIFO manner, optimized for high throughput. More...
 
class  plpgsql_error
 PL/pgSQL error. More...
 
class  plpgsql_no_data_found
 
class  plpgsql_raise
 Exception raised in PL/pgSQL procedure. More...
 
class  plpgsql_too_many_rows
 
class  pqxx_exception
 Mixin base class to identify libpqxx-specific exception types. More...
 
class  quiet_errorhandler
 An error handler that suppresses any previously registered error handlers. More...
 
class  range_error
 Something is out of range, similar to std::out_of_range. More...
 
class  restrict_violation
 
class  result
 Result set containing data returned by a query or command. More...
 
class  robusttransaction
 Slightly slower, better-fortified version of transaction. More...
 
class  sql_error
 Exception class for failed queries. More...
 
class  stateless_cursor
 "Stateless cursor" class: easy API for retrieving parts of result sets More...
 
struct  string_traits
 Traits class for use in string conversions. More...
 
struct  string_traits< bool >
 
struct  string_traits< char * >
 String traits for non-const C-style string ("pointer to char") More...
 
struct  string_traits< char[N]>
 String traits for C-style string constant ("array of char") More...
 
struct  string_traits< const char * >
 String traits for C-style string ("pointer to const char") More...
 
struct  string_traits< const char[N]>
 String traits for "array of const char.". More...
 
struct  string_traits< const PGSTD::string >
 
struct  string_traits< double >
 
struct  string_traits< float >
 
struct  string_traits< int >
 
struct  string_traits< long >
 
struct  string_traits< PGSTD::string >
 
struct  string_traits< PGSTD::stringstream >
 
struct  string_traits< short >
 
struct  string_traits< unsigned int >
 
struct  string_traits< unsigned long >
 
struct  string_traits< unsigned short >
 
class  subtransaction
 "Transaction" nested within another transaction More...
 
class  syntax_error
 
class  tablereader
 
class  tablestream
 
class  tablewriter
 
struct  thread_safety_model
 Descriptor of library's thread-safety model. More...
 
class  too_many_connections
 
class  transaction
 Standard back-end transaction, templatized on isolation level. More...
 
class  transaction_base
 
class  transactor
 
class  tuple
 Reference to one row in a result. More...
 
class  undefined_column
 
class  undefined_function
 
class  undefined_table
 
class  unique_violation
 
class  usage_error
 Error in usage of libpqxx library, similar to std::logic_error. More...
 

Typedefs

typedef basic_connection
< connect_async
asyncconnection
 "Asynchronous" connection type: start connecting, but don't wait for it More...
 
typedef basic_connection
< connect_direct
connection
 The "standard" connection type: connect to database right now. More...
 
typedef basic_fieldstream< char > fieldstream
 
typedef basic_ilostream< char > ilostream
 
typedef basic_connection
< connect_lazy
lazyconnection
 A "lazy" connection type: connect to database only when needed. More...
 
typedef basic_lostream< char > lostream
 
typedef basic_connection
< connect_null
nullconnection
 A "dummy" connection type: don't connect to any database at all. More...
 
typedef unsigned int oid
 PostgreSQL database row identifier. More...
 
typedef basic_olostream< char > olostream
 
typedef transaction
< read_committed, read_only
read_transaction
 Read-only transaction. More...
 
typedef notify_listener trigger
 
typedef signed int tuple_difference_type
 
typedef unsigned int tuple_size_type
 
typedef transaction work
 Bog-standard, default transaction type. More...
 

Enumerations

enum  isolation_level {
  read_committed,
  serializable
}
 Transaction isolation levels; PostgreSQL doesn't implement all SQL levels. More...
 
enum  readwrite_policy {
  read_only,
  read_write
}
 

Functions

thread_safety_model PQXX_LIBEXPORT describe_thread_safety () throw ()
 Describe thread safety available in this build. More...
 
PGSTD::string PQXX_LIBEXPORT encrypt_password (const PGSTD::string &user, const PGSTD::string &password)
 Encrypt password for given user. Requires libpq 8.2 or better. More...
 
PGSTD::string PQXX_LIBEXPORT escape_binary (const PGSTD::string &bin)
 Escape binary string for inclusion in SQL. More...
 
PGSTD::string PQXX_LIBEXPORT escape_binary (const char bin[])
 Escape binary string for inclusion in SQL. More...
 
PGSTD::string PQXX_LIBEXPORT escape_binary (const char bin[], size_t len)
 Escape binary string for inclusion in SQL. More...
 
PGSTD::string PQXX_LIBEXPORT escape_binary (const unsigned char bin[])
 Escape binary string for inclusion in SQL. More...
 
PGSTD::string PQXX_LIBEXPORT escape_binary (const unsigned char bin[], size_t len)
 Escape binary string for inclusion in SQL. More...
 
template<>
bool field::to< PGSTD::string > (PGSTD::string &Obj) const
 Specialization: to(string &). More...
 
template<typename T >
void from_string (const char Str[], T &Obj)
 Attempt to convert postgres-generated string to given built-in type. More...
 
template<typename T >
void from_string (const char Str[], T &Obj, size_t)
 Conversion with known string length (for strings that may contain nuls) More...
 
template<typename T >
void from_string (const PGSTD::string &Str, T &Obj)
 
template<typename T >
void from_string (const PGSTD::stringstream &Str, T &Obj)
 
template<>
void from_string (const PGSTD::string &Str, PGSTD::string &Obj)
 
template<typename T >
void from_string (const field &F, T &Obj)
 Convert a field's string contents to another type. More...
 
template<>
void from_string< PGSTD::string > (const char Str[], PGSTD::string &Obj, size_t len)
 
const_tuple_iterator operator+ (const_tuple_iterator::difference_type o, const_tuple_iterator i)
 
const_result_iterator operator+ (result::difference_type o, const_result_iterator i)
 
const_reverse_result_iterator operator+ (result::difference_type n, const const_reverse_result_iterator &i)
 
template<typename CHAR >
PGSTD::basic_ostream< CHAR > & operator<< (PGSTD::basic_ostream< CHAR > &S, const pqxx::field &F)
 Write a result field to any type of stream. More...
 
template<typename ITER , typename ACCESS >
PGSTD::string separated_list (const PGSTD::string &sep, ITER begin, ITER end, ACCESS access)
 Access iterators using ACCESS functor, returning separator-separated list. More...
 
template<typename ITER >
PGSTD::string separated_list (const PGSTD::string &sep, ITER begin, ITER end)
 Render sequence as a string, using given separator between items. More...
 
template<typename OBJ >
PGSTD::string separated_list (const PGSTD::string &sep, OBJ *begin, OBJ *end)
 Render array as a string, using given separator between items. More...
 
template<typename CONTAINER >
PGSTD::string separated_list (const PGSTD::string &sep, const CONTAINER &c)
 Render items in a container as a string, using given separator. More...
 
template<typename T >
PGSTD::string to_string (const T &Obj)
 Convert built-in type to a readable string that PostgreSQL will understand. More...
 
template<>
PGSTD::string to_string (const field &Obj)
 Convert a field to a string. More...
 

Variables

const oid oid_none = 0
 The "null" oid. More...
 

Detailed Description

The home of all libpqxx classes, functions, templates, etc.

Typedef Documentation

typedef unsigned int pqxx::oid

PostgreSQL database row identifier.

Deprecated:
The trigger class from libpqxx 1.x/2.x has been replaced with notification_receiver.
typedef signed int pqxx::tuple_difference_type
typedef unsigned int pqxx::tuple_size_type

Enumeration Type Documentation

Transaction isolation levels; PostgreSQL doesn't implement all SQL levels.

The only levels implemented in postgres are read_committed and serializable; SQL also defines read_uncommitted and repeatable_read. Unless you're bent on using nasty tricks to communicate between ongoing transactions and such, you won't really need isolation levels for anything except performance optimization. In that case, you can safely emulate read_uncommitted by using read_committed and repeatable_read by using serializable. In general, serializable is the safest choice.

Enumerator
read_committed 
serializable 
Enumerator
read_only 
read_write 

Function Documentation

thread_safety_model PQXX_LIBEXPORT pqxx::describe_thread_safety ( ) throw ()

Describe thread safety available in this build.

PGSTD::string PQXX_LIBEXPORT pqxx::encrypt_password ( const PGSTD::string &  user,
const PGSTD::string &  password 
)

Encrypt password for given user. Requires libpq 8.2 or better.

Use this when setting a new password for the user if password encryption is enabled. Inputs are the username the password is for, and the plaintext password.

Returns
encrypted version of the password, suitable for encrypted PostgreSQL authentication.

Thus the password for a user can be changed with:

void setpw(transaction_base &t, const string &user, const string &pw)
{
t.exec("ALTER USER " + user + " "
"PASSWORD '" + encrypt_password(user,pw) + "'");
}
Since
libpq 8.2
template<>
bool pqxx::field::to< PGSTD::string > ( PGSTD::string &  Obj) const
inline

Specialization: to(string &).

template<typename T >
void pqxx::from_string ( const field &  F,
T &  Obj 
)
inline

Convert a field's string contents to another type.

References pqxx::field::c_str(), and pqxx::field::size().

Referenced by from_string(), and pqxx::field::to().

Here is the call graph for this function:

Here is the caller graph for this function:

const_tuple_iterator pqxx::operator+ ( const_tuple_iterator::difference_type  o,
const_tuple_iterator  i 
)
inline
const_result_iterator pqxx::operator+ ( result::difference_type  o,
const_result_iterator  i 
)
inline
const_reverse_result_iterator pqxx::operator+ ( result::difference_type  n,
const const_reverse_result_iterator &  i 
)
inline

References pqxx::const_reverse_result_iterator::base().

Here is the call graph for this function:

template<typename CHAR >
PGSTD::basic_ostream<CHAR>& pqxx::operator<< ( PGSTD::basic_ostream< CHAR > &  S,
const pqxx::field F 
)
inline

Write a result field to any type of stream.

This can be convenient when writing a field to an output stream. More importantly, it lets you write a field to e.g. a stringstream which you can then use to read, format and convert the field in ways that to() does not support.

Example: parse a field into a variable of the nonstandard "<tt>long long</tt>" type.

extern result R;
long long L;
stringstream S;
// Write field's string into S
S << R[0][0];
// Parse contents of S into L
S >> L;

References pqxx::field::c_str(), and pqxx::field::size().

Here is the call graph for this function:

template<typename ITER , typename ACCESS >
PGSTD::string pqxx::separated_list ( const PGSTD::string &  sep,
ITER  begin,
ITER  end,
ACCESS  access 
)
inline

Access iterators using ACCESS functor, returning separator-separated list.

Parameters
sepseparator string (to be placed between items)
beginbeginning of items sequence
endend of items sequence
accessfunctor defining how to dereference sequence elements

References to_string().

Referenced by pqxx::tablestream::columnlist(), pqxx::tablewriter::generate(), and separated_list().

Here is the call graph for this function:

Here is the caller graph for this function:

template<>
PGSTD::string pqxx::to_string ( const field &  Obj)
inline

Convert a field to a string.

References pqxx::field::c_str(), and pqxx::field::size().

Referenced by pqxx::internal::statement_parameters::add_param(), pqxx::internal::EscapeAny(), pqxx::connection_base::quote(), separated_list(), and to_string().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

const oid pqxx::oid_none = 0

The "null" oid.