Releases: pgcentralfoundation/pgrx
v0.8.3
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
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 throughFromDatum::from_datum()
. This is a fairly important bugfix as with v0.8.0/1 it's possible forArray<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 thepgrx-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
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
- fix bug with
impl<'a> FromDatum for &'a CStr
by @eeeebbbbrrrr in #1123
Full Changelog: v0.8.0...v0.8.1
v0.8.0
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.
- Rename to pgrx by @eeeebbbbrrrr in #1107
PgXactCallbackEvent
shouldn't have been renamed! by @eeeebbbbrrrr in #1108- Fix broken links to zombodb/pgrx by @syvb in #1109
- Fix [email protected] link in CONTRIBUTING.md by @workingjubilee in #1110
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.
- Enforce UTF-8 correctness by @workingjubilee in #1094
- Memoize DB encoding for faster validation by @workingjubilee in #1095
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.
- Use zero-copy Arrays in
--release
by @workingjubilee in #1116 - Fixup iterator impls for Array by @workingjubilee in #1115
- Carry less usizes in Array by @workingjubilee in #1120
- Make
Array::as_slice
unsafe by @thomcc in #1083 - Remove
Array::as_slice
by @workingjubilee in #1119
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.
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
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.
- No xact callback for spi mutability by @eeeebbbbrrrr in #1104
#[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 AnyNumeric
s, perhaps coming from Array<AnyNumeric>
.
- impl
Sum
andDefault
forAnyNumeric
by @eeeebbbbrrrr in #1117
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.
QoL Improvements
- Allow
clippy::no_mangle_with_rust_abi
in the entity graph by @thomcc in #1080 - Bump openssl/openssl-sys by @thomcc in #1089
- Avoid some slow HashMap usage where possible by @thomcc in #1075
- An example of how to create a custom type from scratch. by @eeeebbbbrrrr in #1113
- Cleanup
build.rs
and friends issue #1111 by @eeeebbbbrrrr in #1112
Misc Changes
- Discuss multithreading ergonomics by @workingjubilee in #1081
- Add links to recently published posts on tcdioss.tcdi.com by @rustprooflabs in #1088
New Contributors
- @JohnHVancouver made their first contribution in #1097
- @azam made their first contribution in #1100
Full Changelog: v0.7.4...v0.8.0
v0.7.4
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
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
- fix
IntoDatum
forCString
andCStr
by @eeeebbbbrrrr in #1063
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)
.
- Don't assume HTTPS_PROXY is HTTPS. by @higuoxing in #1061
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
New Contributors
- @ewencp made their first contribution in #1065
- @higuoxing made their first contribution in #1061
Full Changelog: v0.7.2...v0.7.3
v0.7.2
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
-
Made
Date::to_unix_epoch_days()
public by @osawyerr in #1039 -
Cleanup
PgTrigger
such that its public API can now be safe. by @eeeebbbbrrrr in #1055
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.
- overhaul our Postgres Range support by @eeeebbbbrrrr in #1050
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 bothpg_sys::Point
andpg_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
- Remove plrust-related feature flags by @workingjubilee in #1053, Some cleanups around postgrestd and memctx handling by @thomcc in #1051
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 throughcargo
incargo-pgx
andpgx-test
by @thomcc in #1038 -
Fix some warnings when the time-crate feature is disabled by @thomcc in #1054
New Contributors
- @sumerman made their first contribution in #1041
- @skyzh made their first contribution in #1044
- @JelteF made their first contribution in #1035
- @vadim2404 made their first contribution in #1056
Thanks everyone!
Full Changelog: v0.7.1...0.7.2
v0.7.1
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>
andAnyNumeric
against primitives (and each other) by @eeeebbbbrrrr in #1029
Breaking API Change
- remove the dependency on
cstr_core
by @eeeebbbbrrrr in #1025
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
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
- Add support for emit_log_hook by @feikesteenbergen in #979
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
aboutrustup target add
vsrustup 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
- add
PgHeapTuple::into_pg(self)
by @eeeebbbbrrrr in #1018 - Fix version in pg15 help text by @rustprooflabs in #1013
- Bump the Nix flake.lock by @workingjubilee in #1021
New Contributors
- @feikesteenbergen made their first contribution in #979
Full Changelog: v0.7.0-beta.1...v0.7.0
v0.7.0-beta.1
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 returnResult<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