Update version to 0.7.0-beta.0 #1000
Merged
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-pgxby version:$ cargo install cargo-pgx --version 0.7.0-beta.0 --lockedand make sure to update your extension crate dependencies to use0.7.0-beta.0too.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 anyTby @eeeebbbbrrrr inWhoAllocated<T>doesn't need to be generic over anyT#901UnwindSafe + RefUnwindSafebounds in PgMemoryContexts by @eeeebbbbrrrr in Lift UnwindSafe + RefUnwindSafe bounds in PgMemoryContexts #986impl Clone for PgTupleDescby @mhov in clone implementation for PgTupleDesc #962AnyElement::into()needs to be unsafe by @eeeebbbbrrrr inAnyElement::into()needs to be unsafe #928pg_guard_ffi_boundarypublic for everyone to enjoy! by @eeeebbbbrrrr in Lets makepg_guard_ffi_boundarypublic for everyone to enjoy! #942unsafethat should be by @eeeebbbbrrrr in Mark functionsunsafethat 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::Oidis now a newtype wrapper around au32by @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
SpiandSpiTupleTableandSpiHeapTupleDatanow returnpgx::spi::Result<Option<T>>. The error type ispgx::spi::Errorand can not only report Postgres-specificSPI_ERROR_XXXerrors from Postgres but also represent runtime situations where the requested Rust typeTisn't compatible with the backing Datum type.Cursor Support Changes
&self mutby @yrashk in Cursor API should not require &self mut #934Prepared Statement Support
Spi Statement "readonly" Management
readonlyuntil transaction end unless there was a prior mutation by @yrashk/@eeeebbbbrrrr in Make non-updating queries usereadonlyunless 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::selectnot seeing changes fromSpi::runin 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
Okthen its payload is converted into a Datum. If the result isErr, then pgx will automatically raise a PostgresERROR. Furthermore, if theErrvariant'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 + Displayby @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_boundaryby @thomcc in Improve the safety documentation forpg_guard_ffi_boundary#957pgx-version-updaterby @workingjubilee in Silence clippy in pgx-version-updater #930pgx-utilscrate renamed topgx-sql-entity-graphby @eeeebbbbrrrr inpgx-utilsgoes away! #911cargo-pgxversion matching requirement by @yrashk in Document and simplifycargo-pgxversion 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.rsto detectcargo testfeature arguments by @eeeebbbbrrrr in Teachpgx-tests/src/framework.rsto detectcargo testfeature arguments #967Stability, Correctness, and Performance
pg_guardon parameterized functions by @yrashk in Problem: can't usepg_guardon parameterized functions #918syn::Errors by @thomcc in Improve error handling a bit, by converting some panics intosyn::Errors #919#[pg_extern]functions can cause segfault by @eeeebbbbrrrr in Set returning#[pg_extern]functions can cause segfault #982elogcall in postgres code by @EdMcBane in PgLwLock: skip releasing the lock when unwinding from anelogcall in postgres code #989StringInfoby @eeeebbbbrrrr in Rewrite string info #903Feature Flags
pgx/no-schema-generationfeature flag by @eeeebbbbrrrr in Ano-schema-generationfeature flag #915When enabled, pgx will not generate any code related to the "sql entity graph", thereby causing
cargo-pgxto generate an empty schema.pgx/cshimfeature flag by @eeeebbbbrrrr in Add a defaultcshimfeature flag #958cshimfeature should not be a default inpgx-pg-sys. by @eeeebbbbrrrr in Thecshimfeature 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,namespaceandspinlock.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, andHeapTupleHeaderGetRawCommandIdto Rust by @eeeebbbbrrrr in Port c-shim.cheap_getattr,HeapTupleHeaderGetXmin, andHeapTupleHeaderGetRawCommandIdto Rust #953pgx_GETSTRUCTandpgx_HeapTupleHeaderGetOidto Rust by @eeeebbbbrrrr in Port c-shim.cpgx_GETSTRUCTandpgx_HeapTupleHeaderGetOidto 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