github jtv/libpqxx 7.2.0
libpqxx 7.2.0: Another big bang release.

latest releases: 7.9.2, 7.9.1, 7.9.0...
4 years ago

Many things have changed in this release:

  • You can now implicitly convert a const std::string & to zview.
  • Replaced some overloads for C strings and C++ strings with zview.
  • Deprecating binarystring. Use std::basic_string<std::byte> instead!
  • Array parser did not recognise escaping in unquoted values.
  • Document that string conversions assume non-null values.
  • Sketch out concepts-based PQconnectdbParams support. (#343)
  • Fixed infinite recursion when using std::optional in stream_to. (#364)
  • Catch floating-point negative overflow in check_cast, not underflow.
  • Bit more work on CMake build doc. (#318)
  • Experimental support basics for composite types. (#355)
  • Use stream_from without knowing the number of fields. (#357)
  • Global size_buffer function.
  • quote() now works for always-null types without conversions defined.
  • std::nullopt now converts to an SQL null.
  • New type trait: is_unquoted_safe.
  • Fixed mktemp invocation that broke on FreeBSD.

For a more complete list, see the NEWS file inside the codebase. Several more bugs were fixed, and there were performance improvements as well.

A few highlights in more detail:

String overloads. Many overloaded functions in libpqxx take "strings" of various kinds: there's C-style strings (char const *), C++ strings (std::string), there's std::string_view, and then there's pqxx::zview — which is a string_view where the creator promises that there's a terminating zero behind it. A bunch of these functions have been simplified and now just take zview. You can now implicitly convert a string to a zview too — but be careful to keep the string alive and unchanged while you may still use the zview!

Arrays. There was an important fix in the array parser, which previously did not support escape sequences in unquoted values. On the other hand, generating SQL arrays using to_string now makes fewer allocations, thanks to an optional new type trait.

Binary data. Another significant change is that binarystring is now deprecated. To work with binary values such as SQL's BYTEA type, represent them on the client side using the std::byte type: represent binary values as std::basic_string<std::byte> or std::basic_string_view<std::byte>. The string conversions know about these types, so you can use from_string() and to_string() to convert these types back and forth between their C++ and SQL forms.

Composite types. There is experimental support for SQL "composite types." You can now convert an incoming field of such types into a series of C++ values using the field's composite_to() method. Likewise there is a helper for representing a series of C++ values as an SQL composite-type object. The best way to use these is probably to write your own C++ type, and write custom string conversions for it. See datatypes.md for more about how to do this. The string conversions can call the existing libpqxx functions for convenience.

Enjoy!

Don't miss a new libpqxx release

NewReleases is sending notifications on new releases.