Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 newcargo-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.
PgXactCallbackEvent
shouldn't have been renamed! by @eeeebbbbrrrr inPgXactCallbackEvent
shouldn't have been renamed! #1108UTF8 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 likeString
, Datum conversions still occur, but the general overhead is drastically reduced.The various
Array
iterators take advantage of this as well.--release
by @workingjubilee in Use zero-copy Arrays in--release
#1116Array::as_slice
unsafe by @thomcc in MakeArray::as_slice
unsafe #1083Array::as_slice
by @workingjubilee in RemoveArray::as_slice
#1119direct_function_call
The
direct_function_call()
method now takes a slice for its argumentOption<Datum>
array instead of aVec<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 thelib.name
property from the extension'sCargo.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, inCargo.toml
:And @yrashk, in yet-another-great-contribution, has given
cargo-pgrx
aninfo
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.cargo pgrx info
command family by @yrashk in Addcargo pgrx info
command family #1092Spi
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 supportssecurity_invoker
andsecurity_definer
properties. If neither is specified,security_invoker
is the default, as per theCREATE FUNCTION
specification.impl Sum/Default for AnyNumeric
The
AnyNumeric
type is now able to be used by thestd::iter::Sum
trait to, for example, sum the values of an iterator ofAnyNumeric
s, perhaps coming fromArray<AnyNumeric>
.Sum
andDefault
forAnyNumeric
by @eeeebbbbrrrr in implSum
andDefault
forAnyNumeric
#1117More Headers
catalog/objectaccess.h
,commands/user.h
,optimizer/plancat.h
,plpgsql.h
, andrewrite/rowsecurity.h
are now included as part of the pgrx Rust bindings.QoL Improvements
clippy::no_mangle_with_rust_abi
in the entity graph by @thomcc in Allowclippy::no_mangle_with_rust_abi
in the entity graph #1080build.rs
and friends issuebuild.rs
requires $PGRX_HOME/config.toml when it doesn't need to #1111 by @eeeebbbbrrrr in Cleanupbuild.rs
and friends issue #1111 #1112Misc Changes
New Contributors
Full Changelog: v0.7.4...v0.8.0