Skip to content

v0.20.1

Latest

Choose a tag to compare

@eeeebbbbrrrr eeeebbbbrrrr released this 22 Nov 16:09
357d758

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

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

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.gz

There are two kinds of bundle:

  • A partial bundle comes from tools/pgrx-collect-partial-bundle.sh, which needs only a POSIX shell and tar. It holds the server headers and what pg_config reports 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-generate on the target, and also holds what pgrx-pg-sys generated 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:

  • --target is gone from package, install, run, bench and schema. A bundle is the only way to name another platform, and only package takes one.
  • cargo pgrx cross is removed, along with cargo pgrx schema --pg-config, which was never read.
  • cargo pgrx package and cargo pgrx install compile against the Postgres they select, which is --pg-config or else the first pg_config on PATH, 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_config no longer works with cargo-pgrx, nor do target headers named through PGRX_* 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

  • Convert LOG and LOG_SERVER_ONLY in PgLogLevel::from by @yocontra in #2515

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.

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 ErrorContext by @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.

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