Skip to content

libpqxx 7.0: everything has changed!

Compare
Choose a tag to compare
@jtv jtv released this 30 Jan 17:41
· 1113 commits to master since this release

Today we're releasing libpqxx 7.0. It's a radical change, and you may find that your software needs changes to compile.

For starters, C++17 is the minimum now. You'll find std::string_view everywhere, and I hope that you'll find libpqxx faster and more modern than before. If your compiler doesn't implement C++17 fully, that's probably okay — but you may have to pass an option such as -std=c++17.

If you implemented your own string_traits to support additional string conversions, you'll need major changes. The new system is faster, friendlier in some ways, but also a bit more complicated. There's a separate null_traits template, and conversions to and from char buffers.

Connections lost many of their advanced features. It's now a single, much lighter class. No inheritance hierarchy, no automatic connection reactivation. If you want to reconnect, create a new connection. Prepared statements and session variables are no longer cached, so when you define or undefine them, that goes straight to the server.

Invoking prepared or parameterised statements is now easier, thanks to template parameter packs.

The tablereader and tablewriter classes finally have worthy successors: stream_from and stream_to.

Transactors are much simpler: you create your transaction (and even your connection if you like), you commit it when done. A simple lambda can now be a complete transactor!

Exception classes have been rearranged. There is no longer a pqxx_exception base class, either.

Lots of enums have been moved out of classes, some have become enum classes.

Large objects now support 64-bit object sizes. Not for reads and writes though — writing multi-gigabyte chunks at a time is probably a bad idea.

Custom build files for Visual Studio or MinGW are gone. On systems that don't support configure, use CMake.

Then, the robusttransaction class no longer needs to create its own working table. It does require PostgreSQL 10 or better.

And that's not even all! The 7.0 development cycle took the better part of a year, and I'm sure there will still be things to improve. In the future I'm hoping to go C++20, with Concepts, async execution, and the many many other improvements we're expecting in the language. For now though, enjoy libpqxx 7.0 and C++17!