You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This pulls out some commits from pgcentralfoundation#969 into its own PR to add support for `#[pg_extern]`-style functions returning a `Result` of some kind.
We don't care about the type of the Error, so long as it implements `Display`. If the returned value is the Err variant, the `IntoDatum` impl for `Result<T, E>` will raise a Postgres ERROR using `ereport!(ERROR, PgSqlErrorCode::ERRCODE_DATA_EXCEPTION, &format!("{}", e))`.
It's tested to also work with the [`eyre::Result`](https://docs.rs/eyre/latest/eyre/type.Result.html) type along with returning `Result<Option<T>, E>`.
The case of returning a `Result<(), E>` uncovered some issues with how pgx converts `()` into a Datum, so those have been fixed along the way.
It also allows `#[pg_test]` functions to return Results which makes writing unit tests a little nicer.
0 commit comments