v1.2.0
PL/Rust v1.2.0 brings a number of new features. It is backwards compatible with all existing LANGUAGE plrust
functions, both the source and compiled forms.
What's Changed
More Data Type Support
Date/Time/Interval
- Date/time/interval support by @eeeebbbbrrrr in #316
PL/Rust v1.2.0 now supports Postgres date
, time
, time with time zone
, timestamp
, timestamp with time zone
, and interval
types as both function arguments and return types.
These types map to similarly named Rust types via plrust-trusted-pgrx
and are fairly feature complete. Please see the data types documentation for their mappings.
- Expose various date/time functions from pgrx by @eeeebbbbrrrr in #316
PL/Rust now exposes Postgres' various date/time construction functions such as now()
, current_timestamp()
, and many more. They're documented in the plrust-trusted-pgx API documentation.
Arrays as Slices
Function arguments which are arrays of primitive types (ie, Array<i32 | i64 | f32 | f64>
) now have an as_slice()
method, providing direct read-only access to the array contents as a &[i32 | i64 | f32 | f64]
. This can greatly improve performance when iterating or doing random access with these types of arrays.
The arrays chapter provides some examples.
Set Returning Functions
- Support
RETURNS TABLE (...)
functions by @eeeebbbbrrrr in #326
PL/Rust now supports RETURNS TABLE (...)
, allowing LANGUAGE plrust
functions to return wide rows of disparate data.
A user function returns a TableIterator
whose's item is a Rust tuple of values matching the data types declared in the RETURNS TABLE (...)
clause. PL/Rust takes care of the rest!
User Defined Types Support
PL/Rust now supports working with composite types created in SQL via the CREATE TABLE ... AS (...)
statement. These types can be used as both function arguments and return types. They can be constructed, by name, in PL/Rust functions, and have their attributes are accessible and mutable. This happened in PR #311.
The documentation, with a detailed example is in the new UDTs chapter
Dependency Allow List Changes
- In response to issue #325, rework the dependency allow-list. by @eeeebbbbrrrr in #332
The dependency allow-list has been redesigned to allow much more flexibility in defining dependencies, the specific versions (or version ranges) allowed, and any other dependency related properties such as features.
Remember that by default PL/Rust allows all 3rd party crates. It is recommended to configure an allow-list. The allow-list is documented here.
Lints
v1.2.0 adds another lint to guard against potential "I-Unsound" bugs in the Rust compiler and also does some cleanup along the way.
- Add a lint for the Self tuple struct soundness hole by @thomcc in #320
- Fully resolve aliases in plrust-suspicious-trait-object by @thomcc in #335
- Remove the
unaligned_references
lint (it's now a compiler error) by @eeeebbbbrrrr in #328 - Improve plrustc lint messages by @thomcc in #333
- Don't require a loaded function to have "compile lints" applied. by @eeeebbbbrrrr in #327
This last one (#327) allows existing compiled PL/Rust functions to be loaded by new PL/Rust versions that now have lints the previous version didn't.
Trusted Support on MacOS
PL/Rust v1.2.0 can now be used as a trusted language handler on MacOS!
Previous versions could be compiled/installed on MacOS but not in the trusted form. Most of the work for this happened by @thomcc in the postgrestd
library.
- Support
--features trusted
on macOS by @eeeebbbbrrrr in #334
Operational Changes
PL/Rust now requires rust v1.70.0. In order to compile and install PL/Rust v1.2.0 you'll first need to update to exactly rust v1.70.0.
Project Management
- Various updates to CI by @BradyBonnette in #331
Our CI is nearly 2x faster now and also includes testing on MacOS.
Upgrading
Upgrading to PL/Rust v1.2.0 is as simple as installing the new plrust.so
. If you're using our pre-built .deb packages, simply install them with dpkg
and restart the Postgres cluster.
If you've installed PL/Rust manually, simply follow that process again, making sure to compile the new postgrestd
and plrustc
crates, both with Rust 1.70.0.
Full Changelog: v1.1.3...v1.2.0