Skip to content

Releases: pgcentralfoundation/pgrx

v0.8.3

02 May 15:15
92750b4
Compare
Choose a tag to compare

Just a quick release to resolve an issue with the upstream tracing version we were using being yanked. No actual code changes here.

As always, make sure to install with cargo install cargo-pgrx --locked

What's Changed

  • upgrade dependencies, and also loosen up the tracing dep in cargo-pgrx by @eeeebbbbrrrr in #1130

Full Changelog: v0.8.2...v0.8.3

v0.8.2

27 Apr 18:17
39087b4
Compare
Choose a tag to compare

pgrx v0.8.2 is a small bugfix release.

It fixes a bug decoding arrays of enums, and perhaps other pass-by-value datums, that could lead to reading past the end of the backing array structure along with fixing a regression regarding compilation speeds.

When upgrading, please make sure to run cargo install cargo-pgrx --locked.

Changes

  • PR #1125 - the Array<T> type can now properly decode Ts that are enums annotated with #[derive(PostgresEnum)] and should also work properly with other pass-by-value datum types that require going through FromDatum::from_datum(). This is a fairly important bugfix as with v0.8.0/1 it's possible for Array<T> to read past the end of the array.

  • PR #1127 - due to no good deed going unpunished, and some over-zealousness in PR #1111, consecutive "cargo build" commands such as cargo pgx run/test/install would cause the pgrx-pg-sys/build.rs file to run again, causing a full rebuild of (at least) that crate. This was an unintended side-effect and #1127 fixes it.

  • PR #1128 - remove a few unused dependencies

Full Changelog: v0.8.1...v0.8.2

v0.8.1

25 Apr 17:49
5da0ebc
Compare
Choose a tag to compare

This is pgrx v0.8.1. It fixes a UAF issue when working with CStr datums.

As usual, when upgrading, make sure to do cargo install cargo-pgrx --locked.

What's Changed

Full Changelog: v0.8.0...v0.8.1

v0.8.0

24 Apr 15:59
aa1d41d
Compare
Choose a tag to compare

Welcome to pgrx v0.8.0 (formally known as pgx). This release of pgrx comes with a number of bugfixes, features, and breaking API changes.

Upgrading

When upgrading, you'll likely want to remove the old "pgx" from your system:

cargo pgx stop all                # from inside an extension crate still using pgx
cargo uninstall cargo-pgx
cargo install cargo-pgrx --locked
cargo pgrx init

This will remove the old cargo-pgx binary, install the new cargo-pgrx binary, and initialize it. This means your development databases will be re-created in, by default, ~/.pgrx.

What's Changed

Breaking Changes

We Have a New Name

We're working on some exciting near-term plans for pgrx and in order to accomplish these goals it was necessary to rename the project. The last thing we want is direct confusion with other open-source projects and corporations also operating in the PostgreSQL space.

UTF8 Support

Postgres supports numerous database encodings. Rust only supports UTF8, which here in 2023 is generally what everyone uses in Postgres anyways. These commits cause pgrx to raise ERRORs in cases when it tries to convert a Postgres "string" into a Rust string and it's not valid UTF8. Previously, pgrx blindly did this conversion which could have led to undefined behavior. The detection is minimal-to-no overhead in the case where the database is UTF8 -- it's non-UTF8 encodings where we have to validate compatibility string-by-string.

Arrays

The pgrx Array type has been drastically overhauled to be properly safe and nearly zero-copy. This means that pgrx is now capable of directly decoding the binary Postgres array format without asking Postgres to deconstruct it into an array of Datums. In the common cases of pass-by-value Datums (ie, i32, f32), Array is truly zero-copy. For arrays of "varlena" types like String, Datum conversions still occur, but the general overhead is drastically reduced.

The various Array iterators take advantage of this as well.

direct_function_call

The direct_function_call() method now takes a slice for its argument Option<Datum> array instead of a Vec<Option<Datum>>. This will avoid a heap allocation for every usage of this function, making it a little more lightweight.

  • Use a slice instead of a vec in direct_function_call and related functions by @thomcc in #1084

New Things

cargo-pgrx

In their first contribution, @azam taught the various cargo-pgrx commands to understand the lib.name property from the extension's Cargo.toml. If present, this will be used to name the resulting shared library. There's an example for this in ./pgrx-examples/custom_libname, but we're talking about, in Cargo.toml:

[lib]
crate-type = ["cdylib"]
name = "other_name"	# you can rename the extension with this
  • Support for library with different name than crate name by @azam in #1100

And @yrashk, in yet-another-great-contribution, has given cargo-pgrx an info command. cargo pgrx info has a number of subcommands to report various information about the cargo-pgrx runtime like Postgres installation paths, pg_config paths, and version information.

Spi

pgrx's Spi implementation will automatically/transparently use read_only = false statements when it detects the current transaction has previously been modified. We used to handle this via a pair of transaction callback hooks, and its understanding of "has the current transaction been modified" was limited to what might have happened only in the pgrx extension. We now better detect this, regardless of what modified the transaction, and also do it without transaction callback hooks.

#[pg_extern]

#[pg_extern] now supports security_invoker and security_definer properties. If neither is specified, security_invoker is the default, as per the CREATE FUNCTION specification.

  • Add support for explicitly specifying SECURITY INVOKER/DEFINER functions by @JohnHVancouver in #1097

impl Sum/Default for AnyNumeric

The AnyNumeric type is now able to be used by the std::iter::Sum trait to, for example, sum the values of an iterator of AnyNumerics, perhaps coming from Array<AnyNumeric>.

More Headers

catalog/objectaccess.h, commands/user.h, optimizer/plancat.h, plpgsql.h, and rewrite/rowsecurity.h are now included as part of the pgrx Rust bindings.

  • pgrx-pg-sys: include more headers with hooks by @skyzh in #1077

QoL Improvements

Misc Changes

New Contributors

Full Changelog: v0.7.4...v0.8.0

v0.7.4

14 Mar 14:53
73a831a
Compare
Choose a tag to compare

This is pgx v0.7.4. It is a very minor update.

As always, when upgrading please install the latest cargo-pgx like so:

$ cargo install cargo-pgx --locked

What's Changed

  • Make ErrorReportWithLevel::detail_with_backtrace an Option by @ewencp in #1071
  • Remove several unnecessary deps from pgx-sql-entity-graph by @thomcc in #1070
  • Upgrade dependencies 5e02e7a

Full Changelog: v0.7.3...v0.7.4

v0.7.3

09 Mar 16:03
68fe53c
Compare
Choose a tag to compare

Welcome to pgx v0.7.3. It has a few minor bugfixes and API additions, along with an API-breaking change related to GUCs.

When upgrading please install cargo-pgx with cargo install cargo-pgx --locked.

What's New

New functions (pgx::spi::{quote_identifier, quote_qualified_identifier, quote_literal}) have been added to quote SQL identifiers and literals. These all delegate back into Postgres, so Postgres' quoting rules apply.

This adds a new pgx::gucs::GucFlags struct along with a new flags: GucFlags argument to the various GucRegistry::define_xxx_guc() functions. This is a user-facing API change, but it allows, among other things, for a GUC to indicate that maybe its unit is a byte or seconds. Specifying GucFlags::default() as this argument will quickly migrate your code while maintaining backwards compatibility.

Now, when running a cargo pgx init where pgx compiles Postgres, it'll include all the contrib/ packages as well. This will let you also use extensions like hstore or citext in the databases managed by cargo-pgx.

If you'd like to do this now, just run cargo pgx init again. Your existing databases will be preserved.

Bug Fixes

The IntoDatum implementation for these types made an awful assumption that the backing pointer was already palloc'd by Postgres. This is not what CString and CStr mean, and this assumption could have led to UAF. They've been re-implemented to copy the backing pointer to a palloc'd memory.

If you are wanting to convert a raw, palloc'd pointer into a Datum, just use Datum::from(ptr).

The cargo-pgx CLI tool can use a proxy when it makes network requests. This generalizes the proxy url parsing such that "https" is not hardcoded and is instead intuited from the proxy string itself.

Other Changes

  • Bump tempfile dep to 3.4.0, and several other deps. by @thomcc in #1059

New Contributors

Full Changelog: v0.7.2...v0.7.3

v0.7.2

23 Feb 20:21
809132b
Compare
Choose a tag to compare

This is pgx v0.7.2. It contains quite a few bugfixes and API changes (some of which are breaking).

When updating please make sure to update your crate dependencies and also:

$ cargo install cargo-pgx --version 0.7.2 --locked

API Changes

There's quite a bit of changes to trigger support. PgTrigger is now parameterized with a lifetime and #[pg_trigger] functions will need to adapt to this. Additionally, #[pg_trigger] functions must now return an Option<PgHeapTuple>> (or Result<Option<PgHeapTuple>, E>) as previously it wasn't possible to return a NULL tuple (ie, Option::None), indicating that the row being acted upon should not be modified.

Range support has been changed quite a bit to be more ergonomic and provide conversion from Rust std::ops::Range* types. Check out the new example in pgx-examples/range/.

  • a better Error type when conversion from Date to time::Date doesn't work by @eeeebbbbrrrr in #1052

This is only relevant when the pgx/time-crate feature is used

Correctness Issues

  • By default, require superuser privileges to install a pgx extension by @vadim2404 in #1056

This only impacts new extension crates made with cargo pgx new. It's better that pgx assume the extension you're about to make is wildly unsafe and for you to change that assumption in its extname.control file if you disagree.

  • Fix the IntoDatum implementations for both pg_sys::Point and pg_sys::BOX by @eeeebbbbrrrr in #1042

  • Extend UTF-8 detection in PGX init and test by @sumerman in #1041

Bug Fixes

pgx extensions can now be built against Postgres forks, but you'll need to turn on the pgx/unsafe-postgres feature for your pgx dependency.

  • Use SPITupleTable->numvals when available by @yrashk in #1037

  • Support in FromDatum for binary coercible types (including domain types) by @EdMcBane in #1028

This allows slightly more automatic conversions between data types for Spi. Especially when the Postgres type is a DOMAIN over something like TEXT and the desired Rust type is a String

pgx no longer knows that it's being used with postgrestd

cargo pgx init no longer assumes a user named "root" exists on the system

Miscellaneous

If you run Postgres or cargo pgx run with RUST_BACKTRACE=1 set in the environment, then whenever pgx catches a panic, it'll include a full backtrace!

  • Ensure the libpq{,N}-dev package is removed in CI by @thomcc in #1034

  • Fix outdated documentation for pgx::name! by @Smittyvb in #1036

  • Disable thin lto for dev builds by default in template by @JelteF in #1035

  • Respect RUSTC/CARGO environment variables, and handle calls through cargo in cargo-pgx and pgx-test by @thomcc in #1038

  • Fix some warnings when the time-crate feature is disabled by @thomcc in #1054

New Contributors

Thanks everyone!

Full Changelog: v0.7.1...0.7.2

v0.7.1

02 Feb 18:56
4b9467a
Compare
Choose a tag to compare

Welcome to pgx v0.7.1. It is a small point release that primarily finishes Numeric support. That said, it wouldn't be a proper pgx release without at least one possible breaking API change.

As always, make sure to install cargo-pgx with cargo install cargo-pgx --version 0.7.1 --locked and update crate dependencies as well.

New Trait Impls

  • Support all the Rust "math" operations (Add, Sub, Mul, Div, Rem) for Numeric<P, S> and AnyNumeric against primitives (and each other) by @eeeebbbbrrrr in #1029

Breaking API Change

Our prior usages of cstr_core were to work around the fact that Rust's CStr/CString types required std. As of Rust v1.64, they can be used in no_std environments (which pgx, surprisingly!, supports), so there is no longer a need for us to rely on cstr_core and to re-export it as our own type.

You may run into compilation issues if you implement custom Aggregates.

Something Interesting

This ought to be considered experimental. If you do need to make a 32bit pgx extension and run into problems, please let us know.

Full Changelog: v0.7.0...v0.7.1

v0.7.0

25 Jan 15:37
b5806e3
Compare
Choose a tag to compare

After two betas with minimal (reported) issues, pgx v0.7.0 is finally here!

The full set of code changes since pgx' previous version series (0.6.x) can be found here. It might also be beneficial to review the release notes for the 0.7.0-betas at beta0 and beta1

Below is the small set of changes since beta1.

As always, please make sure to install the latest cargo-pgx with cargo install cargo-pgx --version 0.7.0 --locked and update your extension crate dependencies.

Thanks to all the contributors and users. pgx wouldn't be possible without your participation!

What's Changed

A New Hook

This allows extensions to intercept "ereport" messages as they're emitted by either Postgres or pgx. Maybe you've always wanted to send log messages to some external collection system? Now you can!

Cross Compilation Support

  • Allow manually choosing the scratch directory in cargo pgx cross pgx-target by @thomcc in #1016
  • Fix confusing typo in CROSS_COMPILE.md about rustup target add vs rustup toolchain add by @thomcc in #1017
  • enhance PgConfig to be able to construct itself from a set of environment variables by @eeeebbbbrrrr in #1019 and #1020

Other Cleanups

New Contributors

Full Changelog: v0.7.0-beta.1...v0.7.0

v0.7.0-beta.1

15 Jan 22:35
90d0fce
Compare
Choose a tag to compare
v0.7.0-beta.1 Pre-release
Pre-release

This is pgx v0.7.0-beta.1. It's a minor update that fixes a few behind-the-scenes issues discovered with beta0. It also starts to improve our cross-compilation story a bit more.

As always, install with cargo install cargo-pgx --version 0.7.0-beta.1 --locked and update your extension crate dependencies accordingly.

What's Changed

  • Fully qualify some use statements emitted by code generation by @eeeebbbbrrrr in #1006
  • feature flags can also be delimited by a comma by @eeeebbbbrrrr in #1008
  • Add the ability for #[pg_extern]-style functions to return Result<Option<SetOfIterator>>. by @eeeebbbbrrrr in #1007
  • Allow overriding the binding generator and work on a better CROSS_COMPILE.md by @thomcc in #1010

Full Changelog: v0.7.0-beta.0...v0.7.0-beta.1