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.
This is pgx v0.7.0-beta.0. Other than pgx' initial release, this is our biggest release yet! It contains a number of safety improvements, segfault fixes, API changes, minor performance improvements, and an overhauled Spi interface now with prepared statements and cursors!
Quite a number of people have contributed to this release, so a big thank you is necessary right here at the top. Some notable names are @yrashk and @EdMcBane for their work on Spi. And a shout-out to the new contributors: @jaskij, @kianmeng, and @ChuckHend.
To use this beta release, install
cargo-pgx
by version:$ cargo install cargo-pgx --version 0.7.0-beta.0 --locked
and make sure to update your extension crate dependencies to use0.7.0-beta.0
too.API Changes
v0.7.0 contains some backwards incompatible API changes and your extension code may need to be updated as a result. Leaning on the compiler should help you through the changes.
pgbox::WhoAllocated<T>
doesn't need to be generic over anyT
by @eeeebbbbrrrr inWhoAllocated<T>
doesn't need to be generic over anyT
#901UnwindSafe + RefUnwindSafe
bounds in PgMemoryContexts by @eeeebbbbrrrr in Lift UnwindSafe + RefUnwindSafe bounds in PgMemoryContexts #986impl Clone for PgTupleDesc
by @mhov in clone implementation for PgTupleDesc #962AnyElement::into()
needs to be unsafe by @eeeebbbbrrrr inAnyElement::into()
needs to be unsafe #928pg_guard_ffi_boundary
public for everyone to enjoy! by @eeeebbbbrrrr in Lets makepg_guard_ffi_boundary
public for everyone to enjoy! #942unsafe
that should be by @eeeebbbbrrrr in Mark functionsunsafe
that should be #995#![forbid(unsafe_op_in_unsafe_fn)]
to work with pgx-generated… by @eeeebbbbrrrr in allow#![forbid(unsafe_op_in_unsafe_fn)]
to work with pgx-generated… #996pg_sys::Oid
is now a newtype wrapper around au32
by @workingjubilee in Update version to 0.7.0-beta.0 #1000 & impl Display forpg_sys::Oid
#1004Spi
Spi has received a major overhaul in v0.7.0. It now supports cursors, prepared statements, and runtime datum conversion error detection.
Much of the Spi API has been overhauled in a backwards-incompatible way, and is too much to document in release notes. However, the biggest change is that the various getter functions on
Spi
andSpiTupleTable
andSpiHeapTupleData
now returnpgx::spi::Result<Option<T>>
. The error type ispgx::spi::Error
and can not only report Postgres-specificSPI_ERROR_XXX
errors from Postgres but also represent runtime situations where the requested Rust typeT
isn't compatible with the backing Datum type.Cursor Support Changes
&self mut
by @yrashk in Cursor API should not require &self mut #934Prepared Statement Support
Spi Statement "readonly" Management
readonly
until transaction end unless there was a prior mutation by @yrashk/@eeeebbbbrrrr in Make non-updating queries usereadonly
unless there was a mutation before #963 & Extend Spi's understanding of "readonly" to transaction #992fix issue(was replaced by Extend Spi's understanding of "readonly" to transaction #992)SpiClient::select
not seeing changes fromSpi::run
in same transaction #983 by @eeeebbbbrrrr in fix issue #983 #984Spi Error Handling
Because most Spi-related functions now return
spi::Result<T>
, pgx now knows how to convert aResult<T: IntoDatum, E: Any + Display>
into aDatum
. This means#[pg_extern]
-style functions (including#[pg_test]
functions) can now return a Result. This makes working with Spi much more "rust-like" and fluent.If result is
Ok
then its payload is converted into a Datum. If the result isErr
, then pgx will automatically raise a PostgresERROR
. Furthermore, if theErr
variant's payload is a pgxErrorReport
, then that'll be raised, which can include a specific SQL error code, detail, hint, and context message.The general work on Spi error handling happened in these PRs, with much help from @yrashk and @EdMcBane:
And the generalized support for handling Results-as-Datums came in through:
impl IntoDatum for Result<T: IntoDatum, E: Display>
by @eeeebbbbrrrr inimpl IntoDatum for Result<T: IntoDatum, E: Display>
#972IntoDatum for Result<T, E>
such thatE: Any + Display
by @eeeebbbbrrrr in Change bounds onIntoDatum for Result<T, E>
such thatE: Any + Display
#973Result<TableIterator/SetOfIterator, E>
by @eeeebbbbrrrr in Support returningResult<TableIterator/SetOfIterator, E>
#975Result<pg_sys::Oid>
by @eeeebbbbrrrr in Fix a bug trying to returnResult<pg_sys::Oid>
#976General Cleanups
pg_guard_ffi_boundary
by @thomcc in Improve the safety documentation forpg_guard_ffi_boundary
#957pgx-version-updater
by @workingjubilee in Silence clippy in pgx-version-updater #930pgx-utils
crate renamed topgx-sql-entity-graph
by @eeeebbbbrrrr inpgx-utils
goes away! #911cargo-pgx
version matching requirement by @yrashk in Document and simplifycargo-pgx
version matching requirement #964This one is particularly interesting as it now allows
cargo test --all --features "pgXX ... ..."
to work from a top-level workspace crate:pgx-tests/src/framework.rs
to detectcargo test
feature arguments by @eeeebbbbrrrr in Teachpgx-tests/src/framework.rs
to detectcargo test
feature arguments #967Stability, Correctness, and Performance
pg_guard
on parameterized functions by @yrashk in Problem: can't usepg_guard
on parameterized functions #918syn::Error
s by @thomcc in Improve error handling a bit, by converting some panics intosyn::Error
s #919#[pg_extern]
functions can cause segfault by @eeeebbbbrrrr in Set returning#[pg_extern]
functions can cause segfault #982elog
call in postgres code by @EdMcBane in PgLwLock: skip releasing the lock when unwinding from anelog
call in postgres code #989StringInfo
by @eeeebbbbrrrr in Rewrite string info #903Feature Flags
pgx/no-schema-generation
feature flag by @eeeebbbbrrrr in Ano-schema-generation
feature flag #915When enabled, pgx will not generate any code related to the "sql entity graph", thereby causing
cargo-pgx
to generate an empty schema.pgx/cshim
feature flag by @eeeebbbbrrrr in Add a defaultcshim
feature flag #958cshim
feature should not be a default inpgx-pg-sys
. by @eeeebbbbrrrr in Thecshim
feature should not be a default inpgx-pg-sys
. #990When enabled (which is the default),
pgx
(specifically,pgx-pg-sys
) will compile its "cshim" code and have it statically linked into the extension. Disabling this feature flag might make pgx compilation easier for platforms where the necessary Postgres C extension build requirements aren't available, however you'll lose access to a few pgx modules:hooks
,list
,namespace
andspinlock
.Our ultimate goal is to not have a "cshim" at all, and to that end much of the old "cshim" has been ported to Rust:
heap_getattr
,HeapTupleHeaderGetXmin
, andHeapTupleHeaderGetRawCommandId
to Rust by @eeeebbbbrrrr in Port c-shim.cheap_getattr
,HeapTupleHeaderGetXmin
, andHeapTupleHeaderGetRawCommandId
to Rust #953pgx_GETSTRUCT
andpgx_HeapTupleHeaderGetOid
to Rust by @eeeebbbbrrrr in Port c-shim.cpgx_GETSTRUCT
andpgx_HeapTupleHeaderGetOid
to Rust #950SET_VARSIZE*
functions to Rust by @eeeebbbbrrrr in Port various c-shim.cSET_VARSIZE*
functions to Rust #949PgMemoryContexts::get_context_for_pointer()
is wildly unsafe. by @eeeebbbbrrrr inPgMemoryContexts::get_context_for_pointer()
is wildly unsafe. #947c-shim.c
'spgx_ereport()
function to rust by @eeeebbbbrrrr in Portc-shim.c
'spgx_ereport()
function to rust #946ARR_*
functions to Rust by @eeeebbbbrrrr in Port various c-shim.cARR_*
functions to Rust #948More Postgres Headers
CI Updates
New Contributors
Full Changelog: v0.6.1...v0.7.0-beta.0