Releases: jtv/libpqxx
libpqxx 7.1.0: A whole new way of querying data
Another big update.
The bad news:
- Any
string_traits<TYPE>::size_buffer()
must now benoexcept
. - There's an extra data member in
nullness
:always_null
. You'll need to implement to give your type full functionality.
The good news: there's a new way of retrieving data from the database! It's faster, it's easier, it includes conversion to a type of your choice. Using transaction::stream
, you can query rows from the database straight into a std::tuple
, and so, into local variables:
for (auto const [id, name] : tx.stream<int, std::string_view>("SELECT id, name FROM item"))
process(id, name);
And in other news...
stream_from
now supports more or less arbitrary queries.- Instead of a tuple of fields, you can pass
stream_to
a container as well. - There is now
to_buf
support for string literals. - Streaming data is now more efficient.
- The table name in
stream_from
is now escaped. - You can now "convert" strings to
std::string_view
. Mind your lifetimes! - A
std::variant
will now convert to string, if its member types do. - If a
stream_from
row fails to convert, you can no longer retry it. from_string(field const &)
now handles null values properly.- Obsolete Windows build docs are gone.
- Added
row::to(std::tuple<...>)
— converts the whole row in one go. - Unified the test suites. We no longer need
test/unit/unit_runner
. - New helper:
strip_t<...>
to remove a type's constness and reference. - Replace some custom templating in CMakeFiles with CMake globs.
libpqxx 7.0.7: Build system tweaks
Here's a few improvements to both the "configure" build and the "CMake" build:
- Fix broken
--with-postgres-lib
option inconfigure
script (#311) - Should now build even if neither
pkg-config
norpg_config
is available. - CMake accepts
PostgreSQL_ROOT
, if it's a sufficiently recent version.
libpqxx 7.0.6: Yup, there's more to fix.
In the run-up to a 7.1 release, here's some more fixes:
libpqxx 7.0.5: minor fixes.
libpxx 7.0.4: More fixes, more constructors, more operators.
Another small batch of changes:
- Fix possible crash in
connection::connection_string
(#290). - Fix filtering of default values in
connection::connection_string
(#288). - Deprecate
row::swap
and public inheritance of iterators fromrow
. - More copy/move/default constructors/assignments on result iterators.
- More copy/move/default constructors/assignments on row iterators.
libpqxx 6.4.6: Important bug fix
This patch release fixes an important bug which could happen when reading large objects through the ilostream
class. On systems where char
is a signed type (which I believe includes most desktop systems), if the stream found any byte with value -1
at a buffer boundary, then it would mistake that byte for an end-of-file marker.
A similar fix was released in libpqxx 7.0.3.
libpqxx 7.0.3: Important large objects fix
This new version fixes an important bug which could happen when reading large objects through the ilostream
class. On systems where char
is a signed type (which I believe includes most desktop systems), if the stream found any byte with value -1
at a buffer boundary, then it would mistake that byte for an end-of-file marker.
Thanks to @tomlankhorst for finding and fixing this bug. A similar update for the 6.4 series is forthcoming.
There are also some other fixes: large-object streams open in binary mode. Some compile errors have been fixed (though the tests may not pass) on non-Unicode systems, and in some scenarios, lost database connections are now properly reported as broken_connection
exceptions instead of sql_error
exceptions. Unfortunately this does not cover all scenarios, so more work will be needed.
libpqxx 7.0.2: Small new features.
Here's a new libpqxx release. It's versioned like a bugfix update, but actually it adds a few small features:
- New
query_value
method makes it easy to query a single value, and convert it to a given type in one go. - You can now iterate a
stream_from
stream. This may become very important. - More callable types qualify as transactors, thanks to
std::invoke
.
Why is iterating streams important? Because I'm currently testing a whole new way of querying data based on it. We're talking about streaming typed data straight from a database query.
If this pans out, expect a 7.1 release very soon. Early testing suggests that the new trick will be faster, easier to read, type-safe, and convenient. Of course there's a cost: your query may fail halfway through, after you've already begun processing data; and if it does, you'll just need to discard the entire connection and start over. Is that worth it? You will still have the choice to work either way.
libpqxx 7.0.1: exception hierarchy tweak
No matter how careful you are, there's always some detail you miss. I made the transaction_rollback
a failure
in the new exception hierarchy, when I meant to make it an sql_error
. This exception and its sub-types happen when executing queries, and so they should be able to tell you the query, as well as report the "sqlstate" error code.
Technically this is an ABI break that should have happened in the 7.0.0 release. The constructor is different, which may break code. But only libpqxx should ever throw this exception, and perhaps some tests.
One way you may notice the difference is when catching both sql_error
and transaction_rollback
for the same try
block. In that case, your compiler may warn you that the one is now derived from the other.
libpqxx 7.0: everything has changed!
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!