libpqxx
Escaping-functions

Classes

class  pqxx::binarystring
 Binary data corresponding to PostgreSQL's "BYTEA" binary-string type. More...
 

Functions

std::string pqxx::connection_base::esc (const char str[])
 Escape string for use as SQL string literal on this connection. More...
 
std::string pqxx::connection_base::esc (const char str[], size_t maxlen)
 Escape string for use as SQL string literal on this connection. More...
 
std::string pqxx::connection_base::esc (const std::string &str)
 Escape string for use as SQL string literal on this connection. More...
 
std::string pqxx::connection_base::esc_raw (const unsigned char str[], size_t len)
 Escape binary string for use as SQL string literal on this connection. More...
 
std::string pqxx::connection_base::unesc_raw (const std::string &text)
 Unescape binary data, e.g. from a table field or notification payload. More...
 
std::string pqxx::connection_base::unesc_raw (const char *text)
 Unescape binary data, e.g. from a table field or notification payload. More...
 
std::string pqxx::connection_base::quote_raw (const unsigned char str[], size_t len)
 Escape and quote a string of binary data. More...
 
std::string pqxx::connection_base::quote_name (const std::string &identifier)
 Escape and quote an SQL identifier for use in a query. More...
 
template<typename T >
std::string pqxx::connection_base::quote (const T &t)
 Represent object as SQL string, including quoting & escaping. More...
 
std::string pqxx::connection_base::quote (const binarystring &)
 
std::string pqxx::transaction_base::esc (const char str[]) const
 Escape string for use as SQL string literal in this transaction. More...
 
std::string pqxx::transaction_base::esc (const char str[], size_t maxlen) const
 Escape string for use as SQL string literal in this transaction. More...
 
std::string pqxx::transaction_base::esc (const std::string &str) const
 Escape string for use as SQL string literal in this transaction. More...
 
std::string pqxx::transaction_base::esc_raw (const unsigned char data[], size_t len) const
 Escape binary data for use as SQL string literal in this transaction. More...
 
std::string pqxx::transaction_base::esc_raw (const std::string &) const
 Escape binary data for use as SQL string literal in this transaction. More...
 
std::string pqxx::transaction_base::unesc_raw (const std::string &text) const
 Unescape binary data, e.g. from a table field or notification payload. More...
 
std::string pqxx::transaction_base::unesc_raw (const char *text) const
 Unescape binary data, e.g. from a table field or notification payload. More...
 
template<typename T >
std::string pqxx::transaction_base::quote (const T &t) const
 Represent object as SQL string, including quoting & escaping. More...
 
std::string pqxx::transaction_base::quote_raw (const unsigned char str[], size_t len) const
 Binary-escape and quote a binarystring for use as an SQL constant. More...
 
std::string pqxx::transaction_base::quote_raw (const std::string &str) const
 
std::string pqxx::transaction_base::quote_name (const std::string &identifier) const
 Escape an SQL identifier for use in a query. More...
 

Detailed Description

Function Documentation

◆ esc() [1/6]

std::string pqxx::transaction_base::esc ( const char  str[]) const

Escape string for use as SQL string literal in this transaction.

◆ esc() [2/6]

std::string pqxx::transaction_base::esc ( const char  str[],
size_t  maxlen 
) const

Escape string for use as SQL string literal in this transaction.

◆ esc() [3/6]

std::string pqxx::transaction_base::esc ( const std::string &  str) const

Escape string for use as SQL string literal in this transaction.

◆ esc() [4/6]

std::string pqxx::connection_base::esc ( const char  str[])

Escape string for use as SQL string literal on this connection.

Referenced by pqxx::connection_base::esc().

◆ esc() [5/6]

std::string pqxx::connection_base::esc ( const char  str[],
size_t  maxlen 
)

Escape string for use as SQL string literal on this connection.

References pqxx::connection_base::activate().

◆ esc() [6/6]

std::string pqxx::connection_base::esc ( const std::string &  str)

Escape string for use as SQL string literal on this connection.

References pqxx::connection_base::esc().

◆ esc_raw() [1/3]

std::string pqxx::transaction_base::esc_raw ( const unsigned char  data[],
size_t  len 
) const

Escape binary data for use as SQL string literal in this transaction.

Raw, binary data is treated differently from regular strings. Binary strings are never interpreted as text, so they may safely include byte values or byte sequences that don't happen to represent valid characters in the character encoding being used.

The binary string does not stop at the first zero byte, as is the case with textual strings. Instead, they may contain zero bytes anywhere. If it happens to contain bytes that look like quote characters, or other things that can disrupt their use in SQL queries, they will be replaced with special escape sequences.

◆ esc_raw() [2/3]

std::string pqxx::transaction_base::esc_raw ( const std::string &  str) const

Escape binary data for use as SQL string literal in this transaction.

References pqxx::transaction_base::conn(), and pqxx::connection_base::esc_raw().

◆ esc_raw() [3/3]

std::string pqxx::connection_base::esc_raw ( const unsigned char  str[],
size_t  len 
)

Escape binary string for use as SQL string literal on this connection.

References pqxx::connection_base::activate().

Referenced by pqxx::transaction_base::esc_raw(), and pqxx::connection_base::quote_raw().

◆ quote() [1/3]

template<typename T >
std::string pqxx::transaction_base::quote ( const T &  t) const

Represent object as SQL string, including quoting & escaping.

Nulls are recognized and represented as SQL nulls.

Referenced by pqxx::internal::basic_robusttransaction::~basic_robusttransaction().

◆ quote() [2/3]

template<typename T >
std::string pqxx::connection_base::quote ( const T &  t)

Represent object as SQL string, including quoting & escaping.

Nulls are recognized and represented as SQL nulls.

References pqxx::to_string().

◆ quote() [3/3]

std::string pqxx::connection_base::quote ( const binarystring b)

◆ quote_name() [1/2]

std::string pqxx::transaction_base::quote_name ( const std::string &  identifier) const

Escape an SQL identifier for use in a query.

◆ quote_name() [2/2]

std::string pqxx::connection_base::quote_name ( const std::string &  identifier)

◆ quote_raw() [1/3]

std::string pqxx::transaction_base::quote_raw ( const unsigned char  str[],
size_t  len 
) const

Binary-escape and quote a binarystring for use as an SQL constant.

◆ quote_raw() [2/3]

std::string pqxx::transaction_base::quote_raw ( const std::string &  str) const

◆ quote_raw() [3/3]

std::string pqxx::connection_base::quote_raw ( const unsigned char  str[],
size_t  len 
)

Escape and quote a string of binary data.

References pqxx::connection_base::esc_raw().

Referenced by pqxx::connection_base::quote(), and pqxx::transaction_base::quote_raw().

◆ unesc_raw() [1/4]

std::string pqxx::transaction_base::unesc_raw ( const std::string &  text) const

Unescape binary data, e.g. from a table field or notification payload.

Takes a binary string as escaped by PostgreSQL, and returns a restored copy of the original binary data.

◆ unesc_raw() [2/4]

std::string pqxx::transaction_base::unesc_raw ( const char *  text) const

Unescape binary data, e.g. from a table field or notification payload.

Takes a binary string as escaped by PostgreSQL, and returns a restored copy of the original binary data.

◆ unesc_raw() [3/4]

std::string pqxx::connection_base::unesc_raw ( const std::string &  text)

Unescape binary data, e.g. from a table field or notification payload.

Takes a binary string as escaped by PostgreSQL, and returns a restored copy of the original binary data.

◆ unesc_raw() [4/4]

std::string pqxx::connection_base::unesc_raw ( const char *  text)

Unescape binary data, e.g. from a table field or notification payload.

Takes a binary string as escaped by PostgreSQL, and returns a restored copy of the original binary data.