libpqxx
The C++ client library for PostgreSQL
|
Internal items for libpqxx' own use. Do not use these yourself. More...
Namespaces | |
namespace | pq |
Forward declarations of libpq types as needed in libpqxx headers. |
Typedefs | |
template<typename T> | |
using | composite_field_parser |
Pointer to an encoding-specific specialisation of parse_composite_field. | |
using | glyph_scanner_func |
Function type: "find the end of the current glyph.". | |
using | char_finder_func |
Function type: "find first occurrence of specific any of ASCII characters.". | |
template<typename CALLABLE> | |
using | args_t = decltype(args_f(std::declval<CALLABLE>())) |
A callable's parameter types, as a tuple. | |
template<typename... TYPES> | |
using | strip_types_t = decltype(strip_types(std::declval<TYPES...>())) |
Take a tuple type and apply strip_t to its component types. |
Enumerations | |
enum class | encoding_group { MONOBYTE , BIG5 , EUC_CN , EUC_JP , EUC_KR , EUC_TW , GB18030 , GBK , JOHAB , MULE_INTERNAL , SJIS , UHC , UTF8 } |
Functions | |
pqxx::internal::encoding_group | enc_group (std::string_view encoding_name) |
Convert libpq encoding name to its libpqxx encoding group. | |
__attribute__ ((pure)) char const *name_encoding(int encoding_id) | |
encoding_group | enc_group (int) |
Convert libpq encoding enum value to its libpqxx group. | |
std::string | demangle_type_name (char const []) |
Attempt to demangle std::type_info::name() to something human-readable. | |
void | throw_null_conversion (std::string const &type) |
Throw exception for attempt to convert SQL NULL to given type. | |
void | throw_null_conversion (std::string_view type) |
Throw exception for attempt to convert SQL NULL to given type. | |
std::string | state_buffer_overrun (int have_bytes, int need_bytes) |
Summarize buffer overrun. | |
template<typename T> | |
std::string | to_string_float (T value) |
Floating-point implementations for pqxx::to_string() . | |
template std::string | to_string_float (float) |
template std::string | to_string_float (double) |
template std::string | to_string_float (long double) |
__attribute__ ((visibility("default"))) skip_init_ssl(int skips) noexcept | |
Control OpenSSL/crypto library initialisation. | |
template<encoding_group ENC> | |
std::size_t | scan_double_quoted_string (char const input[], std::size_t size, std::size_t pos) |
template<encoding_group ENC> | |
std::string | parse_double_quoted_string (char const input[], std::size_t end, std::size_t pos) |
Un-quote and un-escape a double-quoted SQL string. | |
template<pqxx::internal::encoding_group ENC, char... STOP> | |
std::size_t | scan_unquoted_string (char const input[], std::size_t size, std::size_t pos) |
Find the end of an unquoted string in an array or composite-type value. | |
template<pqxx::internal::encoding_group ENC> | |
std::string_view | parse_unquoted_string (char const input[], std::size_t end, std::size_t pos) |
Parse an unquoted array entry or cfield of a composite-type field. | |
template<encoding_group ENC, typename T> | |
void | parse_composite_field (std::size_t &index, std::string_view input, std::size_t &pos, T &field, std::size_t last_field) |
Parse a field of a composite-type value. | |
template<typename T> | |
composite_field_parser< T > | specialize_parse_composite_field (encoding_group enc) |
Look up implementation of parse_composite_field for ENC. | |
template<typename T> | |
std::size_t | size_composite_field_buffer (T const &field) |
Conservatively estimate buffer size needed for a composite field. | |
template<typename T> | |
void | write_composite_field (char *&pos, char *end, T const &field) |
template<typename TYPE> | |
void | render_item (TYPE const &item, char *&here, char *end) |
Convert item to a string, write it into [here, end). | |
template<typename... TYPE> | |
std::string | concat (TYPE... item) |
Efficiently combine a bunch of items into one big string. | |
constexpr char | number_to_digit (int i) noexcept |
Convert a number in [0, 9] to its ASCII digit. | |
constexpr int | digit_to_number (char c) noexcept |
Compute numeric value of given textual digit (assuming that it is a digit). | |
template<typename HAVE, typename NEED> | |
std::string | state_buffer_overrun (HAVE have_bytes, NEED need_bytes) |
template<typename T> | |
PQXX_LIBEXPORT std::string | to_string_float (T) |
Floating-point implementations for pqxx::to_string() . | |
template<typename T> | |
char * | generic_into_buf (char *begin, char *end, T const &value) |
Generic implementation for into_buf, on top of to_buf. | |
PQXX_PURE char const * | name_encoding (int encoding_id) |
Return PostgreSQL's name for encoding enum value. | |
PQXX_LIBEXPORT glyph_scanner_func * | get_glyph_scanner (encoding_group) |
Look up the glyph scanner function for a given encoding group. | |
template<char... NEEDLE> | |
std::size_t | find_char (glyph_scanner_func *scanner, std::string_view haystack, std::size_t here=0u) |
Find any of the ASCII characters NEEDLE in haystack. | |
template<typename CALLABLE> | |
void | for_glyphs (encoding_group enc, CALLABLE callback, char const buffer[], std::size_t buffer_len, std::size_t start=0) |
Iterate over the glyphs in a buffer. | |
template<encoding_group ENC, char... NEEDLE> | |
PQXX_PURE std::size_t | find_s_ascii_char (std::string_view haystack, std::size_t here) |
Find first of NEEDLE ASCII chars in haystack. | |
constexpr encoding_group | map_ascii_search_group (encoding_group enc) noexcept |
Just for searching an ASCII character, what encoding can we use here? | |
template<char... NEEDLE> | |
PQXX_PURE constexpr char_finder_func * | get_char_finder (encoding_group enc) |
Look up a character search function for an encoding group. | |
template<char... NEEDLE> | |
PQXX_PURE constexpr char_finder_func * | get_s_char_finder (encoding_group enc) |
Look up a "sentry" character search function for an encoding group. | |
PQXX_LIBEXPORT result_size_type | obtain_stateless_cursor_size (sql_cursor &) |
PQXX_LIBEXPORT result | stateless_cursor_retrieve (sql_cursor &, result::difference_type size, result::difference_type begin_pos, result::difference_type end_pos) |
template<typename... TYPE> | |
bool | operator== (stream_query_end_iterator, stream_query_input_iterator< TYPE... > const &i) |
template<typename... TYPE> | |
bool | operator!= (stream_query_end_iterator, stream_query_input_iterator< TYPE... > const &i) |
void PQXX_LIBEXPORT | wait_for (unsigned int microseconds) |
Wait. | |
PQXX_LIBEXPORT void | wait_fd (int fd, bool for_read, bool for_write, unsigned seconds=1, unsigned microseconds=0) |
Wait for a socket to be ready for reading/writing, or timeout. | |
PQXX_LIBEXPORT void | clear_result (pq::PGresult const *) noexcept |
C++ wrapper for libpq's PQclear. | |
template<typename LEFT, typename RIGHT> | |
constexpr bool | cmp_less (LEFT lhs, RIGHT rhs) noexcept |
Same as std::cmp_less, or a workaround where that's not available. | |
template<typename LEFT, typename RIGHT> | |
constexpr bool | cmp_greater (LEFT lhs, RIGHT rhs) noexcept |
C++20 std::cmp_greater, or workaround if not available. | |
template<typename LEFT, typename RIGHT> | |
constexpr bool | cmp_less_equal (LEFT lhs, RIGHT rhs) noexcept |
C++20 std::cmp_less_equal, or workaround if not available. | |
template<typename LEFT, typename RIGHT> | |
constexpr bool | cmp_greater_equal (LEFT lhs, RIGHT rhs) noexcept |
C++20 std::cmp_greater_equal, or workaround if not available. | |
std::string | cat2 (std::string_view x, std::string_view y) |
Efficiently concatenate two strings. | |
template<typename CHAR> | |
constexpr bool | is_digit (CHAR c) noexcept |
A safer and more generic replacement for std::isdigit. | |
std::string | describe_object (std::string_view class_name, std::string_view name) |
Describe an object for humans, based on class name and optional name. | |
void | check_unique_register (void const *old_guest, std::string_view old_class, std::string_view old_name, void const *new_guest, std::string_view new_class, std::string_view new_name) |
Check validity of registering a new "guest" in a "host.". | |
void | check_unique_unregister (void const *old_guest, std::string_view old_class, std::string_view old_name, void const *new_guest, std::string_view new_class, std::string_view new_name) |
Like check_unique_register, but for un-registering a guest. | |
constexpr std::size_t | size_esc_bin (std::size_t binary_bytes) noexcept |
Compute buffer size needed to escape binary data for use as a BYTEA. | |
constexpr std::size_t | size_unesc_bin (std::size_t escaped_bytes) noexcept |
Compute binary size from the size of its escaped version. | |
void PQXX_LIBEXPORT | esc_bin (bytes_view binary_data, char buffer[]) noexcept |
Hex-escape binary data into a buffer. | |
std::string PQXX_LIBEXPORT | esc_bin (bytes_view binary_data) |
Hex-escape binary data into a std::string. | |
void PQXX_LIBEXPORT | unesc_bin (std::string_view escaped_data, std::byte buffer[]) |
Reconstitute binary data from its escaped version. | |
bytes PQXX_LIBEXPORT | unesc_bin (std::string_view escaped_data) |
Reconstitute binary data from its escaped version. | |
template<typename T> | |
auto | ssize (T const &c) |
Transitional: std::ssize(), or custom implementation if not available. | |
template<typename RETURN, typename... ARGS> | |
std::tuple< ARGS... > | args_f (RETURN(&func)(ARGS...)) |
Helper for determining a function's parameter types. | |
template<typename RETURN, typename... ARGS> | |
std::tuple< ARGS... > | args_f (std::function< RETURN(ARGS...)> const &) |
Helper for determining a std::function's parameter types. | |
template<typename CLASS, typename RETURN, typename... ARGS> | |
std::tuple< ARGS... > | member_args_f (RETURN(CLASS::*)(ARGS...)) |
Helper for determining a member function's parameter types. | |
template<typename CALLABLE> | |
auto | args_f (CALLABLE const &f) -> decltype(member_args_f(&CALLABLE::operator())) |
Helper for determining a callable type's parameter types. | |
template<typename... TYPES> | |
std::tuple< strip_t< TYPES >... > | strip_types (std::tuple< TYPES... > const &) |
Helper: Apply strip_t to each of a tuple type's component types. | |
constexpr char | unescape_char (char escaped) noexcept |
Return original byte for escaped character. | |
template<std::size_t BYTES> | |
char const *PQXX_COLD | error_string (int err_num, std::array< char, BYTES > &buffer) |
Get error string for a given errno value. | |
PQXX_LIBEXPORT int | check_pqxx_version_7_10 () noexcept |
Library version check stub. | |
constexpr char const * | as_c_string (char const str[]) noexcept |
Get a raw C string pointer. | |
template<std::size_t N> | |
constexpr char const * | as_c_string (char(&str)[N]) noexcept |
Get a raw C string pointer. | |
constexpr char const * | as_c_string (pqxx::zview str) noexcept |
Get a raw C string pointer. | |
char const * | as_c_string (std::string const &str) noexcept |
Get a raw C string pointer. |
Variables | |
constexpr char | empty_composite_str [] {"()"} |
template<typename ITERATOR> | |
constexpr auto const | iterator_identity |
template<pqxx::isolation_level isolation, pqxx::write_policy rw> | |
const zview | begin_cmd |
The SQL command for starting a given type of transaction. | |
template<> | |
constexpr zview | begin_cmd< read_committed, write_policy::read_write > |
template<> | |
constexpr zview | begin_cmd< read_committed, write_policy::read_only > |
template<> | |
constexpr zview | begin_cmd< repeatable_read, write_policy::read_write > |
template<> | |
constexpr zview | begin_cmd< repeatable_read, write_policy::read_only > |
template<> | |
constexpr zview | begin_cmd< serializable, write_policy::read_write > |
template<> | |
constexpr zview | begin_cmd< serializable, write_policy::read_only > |
Internal items for libpqxx' own use. Do not use these yourself.
Private namespace for libpqxx's internal use; do not access.
Version check.
Copyright (c) 2000-2025, Jeroen T. Vermeulen.
See COPYING for copyright license. If you did not receive a file called COPYING with this source code, please notify the distributor of this mistake, or contact the author.
Enum type for supporting encodings in libpqxx
Copyright (c) 2000-2025, Jeroen T. Vermeulen.
See COPYING for copyright license. If you did not receive a file called COPYING with this source code, please notify the distributor of this mistake, or contact the author.
Internal wrapper for SQL cursors. Supports higher-level cursor classes.
DO NOT INCLUDE THIS FILE DIRECTLY. Other headers include it for you.
Copyright (c) 2000-2025, Jeroen T. Vermeulen.
See COPYING for copyright license. If you did not receive a file called COPYING with this source code, please notify the distributor of this mistake, or contact the author.
Common implementation for statement parameter lists.
These are used for both prepared statements and parameterized statements.
DO NOT INCLUDE THIS FILE DIRECTLY. Other headers include it for you.
Copyright (c) 2000-2025, Jeroen T. Vermeulen.
See COPYING for copyright license. If you did not receive a file called COPYING with this source code, please notify the distributor of this mistake, or contact the author.
This namespace hides definitions internal to libpqxx. These are not supposed to be used by client programs, and they may change at any time without notice.
Conversely, if you find something in this namespace tremendously useful, by all means do lodge a request for its publication.
class pqxx::internal::stream_query_end_iterator |
The end() iterator for a stream_query.
Function type: "find first occurrence of specific any of ASCII characters.".
This type of function takes a text buffer, and a location in that buffer, and returns the location of the first occurrence within that string of any of a specific set of ASCII characters.
For efficiency, it's up to the function to know which those special ASCII characters are.
The start offset marks the beginning of the current glyph. It must fall within the buffer.
Returns the offset of the first matching character, or if there is none, the end of haystack.
using pqxx::internal::composite_field_parser |
Pointer to an encoding-specific specialisation of parse_composite_field.
Function type: "find the end of the current glyph.".
This type of function takes a text buffer, and a location in that buffer, and returns the location one byte past the end of the current glyph.
The start offset marks the beginning of the current glyph. It must fall within the buffer.
There are multiple different glyph scanner implementations, for different kinds of encodings.
|
noexcept |
Control OpenSSL/crypto library initialisation.
This is an internal helper. Unless you're working on libpqxx itself, use pqxx::skip_init_ssl instead.
flags | a bitmask of 1 << flag for each of the skip_init flags. |
Ignores the skip_init::nothing flag.
auto pqxx::internal::args_f | ( | CALLABLE const & | f | ) | -> decltype(member_args_f(&CALLABLE::operator())) |
Helper for determining a callable type's parameter types.
This specialisation should work for lambdas.
This function has no definition. It's not meant to be actually called. It's just there for pattern-matching in the compiler, so we can use its hypothetical return value.
std::tuple< ARGS... > pqxx::internal::args_f | ( | RETURN(&)(ARGS...) | func | ) |
Helper for determining a function's parameter types.
This function has no definition. It's not meant to be actually called. It's just there for pattern-matching in the compiler, so we can use its hypothetical return value.
std::tuple< ARGS... > pqxx::internal::args_f | ( | std::function< RETURN(ARGS...)> const & | ) |
Helper for determining a std::function's parameter types.
This function has no definition. It's not meant to be actually called. It's just there for pattern-matching in the compiler, so we can use its hypothetical return value.
|
inlinenodiscard |
Efficiently concatenate two strings.
This is a special case of concatenate(), needed because dependency management does not let us use that function here.
|
noexcept |
Library version check stub.
Helps detect version mismatches between libpqxx headers and the libpqxx library binary.
Sometimes users run into trouble linking their code against libpqxx because they build their own libpqxx, but the system also has a different version installed. The declarations in the headers against which they compile their code will differ from the ones used to build the libpqxx version they're using, leading to confusing link errors. The solution is to generate a link error when the libpqxx binary is not the same version as the libpqxx headers used to compile the code.
This function's definition is in the libpqxx binary, so it's based on the version as found in the binary. The headers contain a call to the function, whose name contains the libpqxx version as found in the headers. (The library build process will use its own local headers even if another version of the headers is installed on the system.)
If the libpqxx binary was compiled for a different version than the user's code, linking will fail with an error: check_pqxx_version_*_* will not exist for the given version number.
void pqxx::internal::check_unique_register | ( | void const * | old_guest, |
std::string_view | old_class, | ||
std::string_view | old_name, | ||
void const * | new_guest, | ||
std::string_view | new_class, | ||
std::string_view | new_name ) |
Check validity of registering a new "guest" in a "host.".
The host might be e.g. a connection, and the guest a transaction. The host can only have one guest at a time, so it is an error to register a new guest while the host already has a guest.
If the new registration is an error, this function throws a descriptive exception.
Pass the old guest (if any) and the new guest (if any), for both, a type name (at least if the guest is not null), and optionally an object name (but which may be omitted if the caller did not assign one).
void pqxx::internal::check_unique_unregister | ( | void const * | old_guest, |
std::string_view | old_class, | ||
std::string_view | old_name, | ||
void const * | new_guest, | ||
std::string_view | new_class, | ||
std::string_view | new_name ) |
Like check_unique_register, but for un-registering a guest.
Pass the guest which was registered, as well as the guest which is being unregistered, so that the function can check that they are the same one.
|
inlinenodiscard |
Efficiently combine a bunch of items into one big string.
Use this as an optimised version of string concatentation. It takes just about any type; it will represent each item as a string according to its string_traits.
This is a simpler, more specialised version of separated_list for a statically known series of items, possibly of different types.
|
nodiscard |
Describe an object for humans, based on class name and optional name.
Interprets an empty name as "no name given."
|
noexcept |
Hex-escape binary data into a buffer.
The buffer must be able to accommodate size_esc_bin(std::size(binary_data)) bytes, and the function will write exactly that number of bytes into the buffer. This includes a trailing zero.
|
inline |
Find any of the ASCII characters NEEDLE in haystack.
Scans through haystack until it finds a single-byte character that matches any value in NEEDLE.
If it finds one, returns its offset. If not, returns the end of the haystack.
PQXX_PURE std::size_t pqxx::internal::find_s_ascii_char | ( | std::string_view | haystack, |
std::size_t | here ) |
Find first of NEEDLE ASCII chars in haystack.
|
inline |
Iterate over the glyphs in a buffer.
Scans the glyphs in the buffer, and for each, passes its begin and its one-past-end pointers to callback.
|
inlineconstexpr |
Look up a character search function for an encoding group.
We only define a few individual instantiations of this function, as needed.
Returns a pointer to a function which looks for the first instance of any of the ASCII characters in NEEDLE. Returns its offset, or the end of the haystack if it found none.
PQXX_LIBEXPORT glyph_scanner_func * pqxx::internal::get_glyph_scanner | ( | encoding_group | ) |
Look up the glyph scanner function for a given encoding group.
To identify the glyph boundaries in a buffer, call this to obtain the scanner function appropriate for the buffer's encoding. Then, repeatedly call the scanner function to find the glyphs.
|
inlineconstexpr |
Look up a "sentry" character search function for an encoding group.
This version returns a finder function that does not check buffer bounds. It just assumes that one of the NEEDLE characters will be there.
|
inlineconstexprnoexcept |
A safer and more generic replacement for std::isdigit.
Turns out std::isdigit isn't as easy to use as it sounds. It takes an int, but requires it to be nonnegative. Which means it's an outright liability on systems where char is signed.
|
inlineconstexprnoexcept |
Just for searching an ASCII character, what encoding can we use here?
Maps an encoding group to an encoding group that we can apply for the specific purpose of looking for a given ASCII character.
The "difficult" encoding groups will map to themselves. But the ones that work like "ASCII supersets" have the wonderful property that even a multibyte character cannot contain a byte that happens to be in the ASCII range. This holds for the single-byte encodings, for example, but also for UTF-8.
For those encodings, we can just pretend that we're dealing with a single-byte encoding and scan byte-by-byte until we find a byte with the value we're looking for. We don't actually need to know where the boundaries between the characters are.
std::tuple< ARGS... > pqxx::internal::member_args_f | ( | RETURN(CLASS::* | )(ARGS...) | ) |
Helper for determining a member function's parameter types.
Helper for determining a const member function's parameter types.
This function has no definition. It's not meant to be actually called. It's just there for pattern-matching in the compiler, so we can use its hypothetical return value.
|
inline |
Parse a field of a composite-type value.
T is the C++ type of the field we're parsing, and index is its zero-based number.
Strip off the leading parenthesis or bracket yourself before parsing. However, this function will parse the lcosing parenthesis or bracket.
After a successful parse, pos will point at std::end(text).
For the purposes of parsing, ranges and arrays count as compositve values, so this function supports parsing those. If you specifically need a closing parenthesis, check afterwards that text did not end in a bracket instead.
index | Index of the current field, zero-based. It will increment for the next field. |
input | Full input text for the entire composite-type value. |
pos | Starting position (in input) of the field that we're parsing. After parsing, this will point at the beginning of the next field if there is one, or one position past the last character otherwise. |
field | Destination for the parsed value. |
scan | Glyph scanning function for the relevant encoding type. |
last_field | Number of the last field in the value (zero-based). When parsing the last field, this will equal index. |
|
inline |
input[pos] must be the opening double quote.
The backend double-quotes strings in composites or arrays, when needed. Special characters are escaped using backslashes.
Returns the offset of the first position after the closing quote.
|
inline |
Find the end of an unquoted string in an array or composite-type value.
Stops when it gets to the end of the input; or when it sees any of the characters in STOP which has not been escaped.
For array values, STOP is an array element separator (typically comma, or semicolon), or a closing brace. For a value of a composite type, STOP is a comma or a closing parenthesis.
|
inlineconstexprnoexcept |
Compute buffer size needed to escape binary data for use as a BYTEA.
This uses the hex-escaping format. The return value includes room for the "\x" prefix.
|
inlineconstexprnoexcept |
Compute binary size from the size of its escaped version.
Do not include a terminating zero in escaped_bytes.
std::string PQXX_LIBEXPORT pqxx::internal::state_buffer_overrun | ( | int | have_bytes, |
int | need_bytes ) |
Summarize buffer overrun.
Don't worry about the exact parameter types: the sizes will be reasonably small, and nonnegative.
std::tuple< strip_t< TYPES >... > pqxx::internal::strip_types | ( | std::tuple< TYPES... > const & | ) |
Helper: Apply strip_t to each of a tuple type's component types.
This function has no definition. It is not meant to be called, only to be used to deduce the right types.
void pqxx::internal::wait_for | ( | unsigned int | microseconds | ) |
Wait.
This is normally std::this_thread::sleep_for(). But MinGW's thread header doesn't work, so we must be careful about including it.
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |