Skip to content

Releases: jtv/libpqxx

libpqxx 7.7.0: lots of new features, lots of fixes.

09 Jan 19:17
@jtv jtv
Compare
Choose a tag to compare

It's going to be a big one. Believe me, I toyed with the idea of calling it 8.0. But I think it's not quite radical enough for that. I'm still hoping to raise the language baseline to C++20 for libpqxx 8.0. We'll see.

But here's what you get:

This version introduces a new class, connecting, for connecting to the database asynchronously. It's not native C++ async support, and it's not based on coroutines, but you can build coroutines on top of it. Kirit Sælensminde has built a sample project for this..

You can now convert SQL range values to and from C++ strings, using the new pqxx::range class.

There is now also support for converting between SQL timestamps (without time zones) and C++ std::chrono::year_month_day values. It's pretty limited, because there are lots of inherent problems with date/time support. For one, it only works with the ISO date format.

If you want fast access to a result's fields without having to go through row objects, the pqxx::result class now has a two-dimensional at() member that takes a row number and a column number. And since there's a proposal for permitting two-dimensional array indexing in C++23, there's a provisional two-dimensional operator[] as well. (However I can't test this yet, so it could be broken.)

The project now has a file requirements.json which lists the minimum major versions of compilers, C++, and PostgreSQL that you need for the current version of libpqxx. It's not going to be too detailed, because the more detail I put in there, the more is going to go wrong in maintenance. But at least it should be easy to see in the future which libpqxx versions require which C++ versions etc.

The Doxygen documentation now uses the (Doxygen-extended) Markdown format. That should make the documentation comments in the libpqxx headers a little more modern and easier to read.

Also, we now build docs in doc/html/, no longer in doc/html/Reference/.

There are also some changes that may affect you without exactly creating serious incompatibilities. More functions are [[nodiscard]]. Some member functions are now lvalue-qualified or rvalue-qualified. You can't call an lvalue-qualified function on an rvalue object — so I lvalue-qualified some functions that sane code would not call as the last operation on an object. I also rvalue-qualified one member function that effectively invalidates its object.

Finally, I promised you a lot of fixes:

  • Fix stream_to for differing table/client encodings. (#473)
  • Use [[likely]] & [[unlikely]] only in C++20, to silence warnings.
  • Fix clang "not a const expression" error in Windows. (#472)
  • Fix warnings about [[likely]] in if constexpr. (#475)
  • Clearer error for ambiguous string conversion of char type. (#481)
  • Statement name in prepare() error was for the wrong statement. (#488)
  • Helper for implementing string traits: generic_to_buf.
  • Work around broken std::filesystem::path in MinGW. (#498)
  • Fix leak when getting client encoding fails. (#500)
  • Re-enable pyflakes testing in tools/lint.
  • Don't run clang-tidy by default. Compatibility issues with gcc options.
  • Disable some std::filesystem features on Windows.
  • Shut up stupid Visual Studio warnings.
  • On gcc, mark rarely-used functions as "cold," to be optimised for size.
  • Glyph scanning for GB18030 encoding was utterly broken. (#517)

Did I promise too much? Hope you all have a great 2022!

libpqxx 7.6.1: Fixing encoding bug.

09 Jan 17:08
@jtv jtv
Compare
Choose a tag to compare

Support for the GB18030 encoding contained a bug that would probably have triggered an exception when trying to stream data or handle SQL arrays, composite values, streaming queries, or SQL range values.

See #517.

libpqxx 7.5.3: Fixing encoding bug in old release series.

09 Jan 17:09
@jtv jtv
Compare
Choose a tag to compare

Support for the GB18030 encoding contained a bug that would probably have triggered an exception when trying to stream data or handle SQL arrays, composite values, streaming queries, or SQL range values.

See #517.

libpqxx 7.4.2: Fixing encoding bug in old release series.

09 Jan 17:09
@jtv jtv
Compare
Choose a tag to compare

Support for the GB18030 encoding contained a bug that would probably have triggered an exception when trying to stream data or handle SQL arrays, composite values, streaming queries, or SQL range values.

See #517.

libpqxx 7.3.2: Fixing encoding bug in old release series.

09 Jan 17:20
@jtv jtv
Compare
Choose a tag to compare

Support for the GB18030 encoding contained a bug that would probably have triggered an exception when trying to stream data or handle SQL arrays, composite values, streaming queries, or SQL range values.

See #517.

libpqxx 6.4.8: bug fix in old release series

15 Dec 08:07
@jtv jtv
Compare
Choose a tag to compare

This bugfix update to the old 6.x series resolves a bug where executing a prepared statement would fail to activate the ongoing transaction.

That is, if the first thing you did in a transaction was execute a prepared statement, the actual transaction would not start at that point. The prepared statement would execute outside it.

Newer versions of libpqxx (as of 7.0) never had this problem because they start transactions as soon as you create them. If your environment supports C++17, please use those newer versions instead.

libpqxx 7.6.0: removing a string conversion, but giving many things in return

28 Jul 11:06
@jtv jtv
Compare
Choose a tag to compare

Bad news first: I just removed the ability to convert a string to std::basic_string_view<std::byte>. I'm sorry: this conversion should never have existed and it's not safe to use. See bug #463. It's not safe because it leaves no object to "own" the converted data. The view points into deallocated memory. If this breaks your code, use std::basic_string<std::byte> instead — so string, not string_view.

Now for the good news, of which there is a lot:

  • Add C++20 concepts: binary, char_string, char_strings.
  • In C++20: generalise binary strings to any contiguous range of std::byte.
  • Mark zview as a view and as a borrowed range.
  • Save a copy step on string fields in stream_to.
  • New helper: pqxx::value_type<CONTAINER>.
  • New helper: pqxx::binary_cast. (#450)
  • Some escaping functions now have "into my buffer" variants.
  • More generic escaping functions, supporting more types of binary.
  • In C++20, accept generic columns list for stream_to. (#447)
  • Renamed <pqxx/prepared_statement> to <pqxx/params>. (Old name still works for now, of course.)
  • Deprecated dynamic_params in favour of params.
  • pqxx::params::append_multi() now calls reserve() if possible.
  • pqxx::params::size() is now noexcept (but sadly, ssize() is not — because std::ssize() isn't).
  • Helper for generating parameter placeholders $1, $2, etc. (#443)
  • Now requires support for C++14 [[deprecated]] attribute.
  • Deprecated unesc_raw() in favour of unesc_bin() variants.
  • Once unesc_raw() is gone, we'll support only the hex escape format for binary data.
  • Work around broken thread_local in MinGW gcc < 11.1.
  • pqxx::blob now supports std::filesystem::path.
  • Fixed check against header/lib version mismatch: check_pqxx_version_7_6
  • More complete documentation, of cursors in particular.

Finally, "result slicing" is now deprecated. It will go away in the future. Was anyone using this? It never felt complete or useful to me, and I haven't heard anyone mention it in at least a decade. Once we get rid of it, that'll shave a tiny bit of complexity out of your inner loops and make them a little more efficient. The main reason though is simplicity. Simpler code means fewer mistakes and surprises.

libpqxx 7.5.2: Serious bug in blob::read(std::vector)!

08 May 10:03
@jtv jtv
Compare
Choose a tag to compare

This is an emergency patch release. The recently added pqxx::blob::read() variant which takes a std::vector<std::byte> was utterly broken. It did not actually read any data from the blob.

This is now fixed, and properly tested.

libpqxx 7.5.1: compiler fixes, more deprecations

08 May 07:51
@jtv jtv
aef63cf
Compare
Choose a tag to compare

This maintenance release of libpqxx works around a <thread> bug in MinGW; fixes some Visual C++ warnings; and makes the code a little easier to build out of the box by including config/compile in revision control.

But also, it deprecates more "legacy" representations of binary data, such as unsigned char *. We keep moving towards std::byte. If your compiler supports it, upcoming releases will move towards generic support for spans and ranges of binary data. If not, you'll need to represent binary data as std::basic_string<std::byte> and std::basic_string_view<std::byte>.

Eventually we'll raise the baseline C++ version to C++20, and at that point, it will be all ranges and spans.

libpqxx 7.5.0: more modern, more efficient, more flexible

24 Apr 04:36
@jtv jtv
Compare
Choose a tag to compare

There are now more ways to pass a BYTEA parameter to a query, and more of them get passed as binary data without intervening encode/decode pass. This last part makes it more efficient, but should not be visible to you otherwise.

When it comes to passing parameters to queries, some people wanted a way to build parameter lists on the fly. This was possible with the old parameter-passing API, but never actually supported. There is now a class for doing this, params, with some optimisation built in to prevent unnecessary copying of string_view and similar values.

"Blobs" (the new BYTEA API) have a new read() method on compilers which support C++20 "spans." It's based on std::span, and you can expect more use of spans soon.

Here's the more complete list:

  • Now requires std::variant support! No longer works with gcc7.
  • When implementing a string conversion, consider specialising param_format.
  • Stop "aborting" nontransaction on closing. (#419)
  • Silence an overzealous Visual C++ warning. (#418)
  • Starting support for C++20 std::span.
  • New blob::read() using std::span. (#429)
  • New params class lets you build parameter lists incrementally. (#387)
  • Pass std::vector<std::byte> params in binary format.
  • Dropped legacy tests 31 and 49 to work around clang C++20 bug.
  • Fixed stream_to test failure in non-English locales. (#440)
  • Clarify transaction_base::stream documentation. (#423)
  • Avoid <thread> on MinGW; it's broken there. (#336, #398, #424, #441)