Repository navigation
Welcome to pgrx v0.20.1. This release supports the final Postgres 19 release, teaches cargo pgrx package to build for another platform from a target bundle, and fixes several problems in how pgrx reports and catches Postgres ERRORs.
As always, please install cargo-pgrx with cargo install cargo-pgrx --version 0.20.1 --locked and run cargo pgrx upgrade to fixup your extension crates.
One thing to know before upgrading: the cross-compiling work removes --target and cargo pgrx cross from cargo-pgrx, even though this is a patch release. If you cross-compile, read that section below first.
Postgres 19
- Support the PostgreSQL 19 release by @eeeebbbbrrrr in #2523
Postgres 19.0 was released on November 19, and pgrx now treats 19 like 15 through 18. cargo pgrx init --pg19=download gets the latest 19 release, which is 19.0 today, and will pick up minor releases as they come out. On Windows it downloads EnterpriseDB's binaries, as it does for the other versions.
If you have a 19 beta or release candidate that cargo pgrx init downloaded, run cargo pgrx init --pg19=download to replace it.
Cross-Compiling with Target Bundles
- Name extension libraries after --target in cargo-pgrx by @eeeebbbbrrrr in #2510
- Package for another platform from a target bundle by @eeeebbbbrrrr in #2512
- Test cross-platform PG18 packages nightly by @eeeebbbbrrrr in #2507
Cross-compiling an extension used to be correct only if you copied the target's Postgres headers and pg_config values by hand, and it didn't work to another operating system at all. cargo pgrx package now builds for another platform from a target bundle: one file made on that platform from its real pg_config and headers.
# on the target platform
$ sh pgrx-collect-partial-bundle.sh --target=aarch64-unknown-linux-gnu
# on the build host
$ cargo pgrx package --bundle pgrx-pg18-aarch64-unknown-linux-gnu.partial.tar.gzThere are two kinds of bundle:
- A partial bundle comes from
tools/pgrx-collect-partial-bundle.sh, which needs only a POSIX shell andtar. It holds the server headers and whatpg_configreports and nothing generated, so it serves every pgrx version. The build host needs Clang and the target's system headers. - A full bundle comes from
cargo pgrx package --bundle-generateon the target, and also holds whatpgrx-pg-sysgenerated there. The build host then needs only a linker, but the bundle has to be made again after each pgrx upgrade.
Either way the build host needs a Rust toolchain that can link for the target, and no Postgres, pg_config or cargo pgrx init. Library names, package layout and RPM and DEB packages follow the bundle's target, so you can build Linux packages from macOS. A nightly CI workflow now packages PG18 extensions between Linux, macOS and Windows. The rewritten cross-compiling guide has the details and a recipe for each route.
This changes a few things you may need to act on:
--targetis gone frompackage,install,run,benchandschema. A bundle is the only way to name another platform, and onlypackagetakes one.cargo pgrx crossis removed, along withcargo pgrx schema --pg-config, which was never read.cargo pgrx packageandcargo pgrx installcompile against the Postgres they select, which is--pg-configor else the firstpg_configonPATH, so its server headers must be installed. Before, an extension could be compiled against one installation and laid out for another.- An emulated or scripted
pg_configno longer works withcargo-pgrx, nor do target headers named throughPGRX_*environment variables.
The v0.20.0 Migration Guide is updated for these in this release. See Cross-compiling and PostgreSQL for cargo pgrx package and install.
The first of these PRs is @Vinnu124's work from #2506.
Error Reporting
PgLogLevel::from turned LOG and LOG_SERVER_ONLY into ERROR. It now converts both. PgLogLevel also gains WARNING_CLIENT_ONLY and, on Postgres 19, FATAL_CLIENT_ONLY, so a match on it needs arms for them or a wildcard.
- Free an
ereportdomain when Postgres discards its ERROR by @eeeebbbbrrrr in #2520
Every ERROR reported with a domain leaked a copy of that domain. pgrx now frees it when Postgres discards the error. An ERROR whose domain contained a NUL byte aborted the backend. A domain now ends at its first NUL, as the message, detail and hint already do.
- Keep the scratch context for a caught ERROR out of
ErrorContextby @eeeebbbbrrrr in #2521
pgrx copies a caught Postgres ERROR in a scratch memory context. If that copy ran out of memory while Postgres was already handling another error, Postgres deleted the context it was running in, and pgrx deleted it a second time. The scratch context is now a child of TopMemoryContext, which that reset doesn't touch.
- Catch an ERROR raised while reporting a lower level by @eeeebbbbrrrr in #2522
notice!(), warning!() and the other levels below ERROR run Postgres' error context callbacks, and a callback can raise an ERROR. That ERROR used to jump past the Rust frames that made the report, so their destructors didn't run. pgrx now catches it and unwinds those frames as a panic, like an ERROR from any pg_sys call.
That means a report below ERROR can now panic. In a destructor that runs while another panic unwinds, that's a second panic, and Rust aborts the backend.
@yocontra found the problems behind the last three of these, in #2517, #2516 and #2518.
New Contributors
Thanks also to @Vinnu124. Your work is appreciated!
Full Changelog: v0.20.0...v0.20.1