Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build upon #902: Spi Error Handling #969

Merged
merged 23 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
72b5b7c
Problem: SPI API panics on most errors
yrashk Nov 30, 2022
e69190d
Problem: anyhow is not being used
yrashk Nov 30, 2022
90387b1
Problem: 'static lifetime for SPI interface is too restrictive
yrashk Nov 30, 2022
d6cd465
Problem: having to unwrap SPI results twice
yrashk Dec 1, 2022
124c05a
Minor error message change
yrashk Dec 1, 2022
e35e2a0
Problem: imposition of spi::Error in Spi::connect
yrashk Dec 1, 2022
2cb4a3c
Problem: cursor API crashes instead of returning errors
yrashk Dec 8, 2022
b84e742
Building upon @yrashk's work in #902, this does a few small things, w…
eeeebbbbrrrr Dec 18, 2022
5862239
Bring the "NullStrict" tests back
eeeebbbbrrrr Dec 18, 2022
b64cb44
Do a better job detecting that a `#[pg_extern]`-style function return…
eeeebbbbrrrr Dec 19, 2022
c74cdc2
Not sure if this will survive, but it seems **much** cleaner for `Spi…
eeeebbbbrrrr Dec 19, 2022
f9b1f9f
cleanup a few more tests
eeeebbbbrrrr Dec 19, 2022
ac6761d
`TryFromDatumError::NullDatumPointer` is dead code
eeeebbbbrrrr Dec 19, 2022
ce927fd
`impl<T> FromDatum for Option<T> where T: FromDatum,` goes away
eeeebbbbrrrr Dec 19, 2022
7bdb794
re-enable `spi_tests::test_open_multiple_tuptables_rev()`
eeeebbbbrrrr Dec 20, 2022
38956b4
this is a little more clear for `spi_tests::test_open_multiple_tuptab…
eeeebbbbrrrr Dec 20, 2022
bae3924
update the `result_tests.rs` to be compatible with new Spi API
eeeebbbbrrrr Dec 20, 2022
6a55550
cleanup tests across the board. No need for most of them to return a…
eeeebbbbrrrr Dec 20, 2022
36c8ef9
cargo fmt
eeeebbbbrrrr Dec 20, 2022
eb74f1c
restore and fix comment
eeeebbbbrrrr Dec 20, 2022
c3858a7
more test cleanup based on reviewing the PR diff
eeeebbbbrrrr Dec 20, 2022
cb9f9f4
oops
eeeebbbbrrrr Dec 20, 2022
b80c289
Remove `Spi::execute()` and use `Spi::connect()` everywhere
eeeebbbbrrrr Dec 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 56 additions & 66 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions pgx-examples/aggregate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,15 @@ mod tests {
fn test_integer_avg_state_sql() {
Spi::run("CREATE TABLE demo_table (value INTEGER);");
Spi::run("INSERT INTO demo_table (value) VALUES (1), (2), (3);");
let retval = Spi::get_one::<i32>("SELECT DEMOAVG(value) FROM demo_table;")
.expect("SQL select failed");
assert_eq!(retval, 2);
let retval = Spi::get_one::<i32>("SELECT DEMOAVG(value) FROM demo_table;");
assert_eq!(retval, Ok(Some(2)));
}
#[pg_test]
fn test_integer_avg_with_null() {
Spi::run("CREATE TABLE demo_table (value INTEGER);");
Spi::run("INSERT INTO demo_table (value) VALUES (1), (NULL), (3);");
let retval = Spi::get_one::<i32>("SELECT DEMOAVG(value) FROM demo_table;")
.expect("SQL select failed");
assert_eq!(retval, 2);
let retval = Spi::get_one::<i32>("SELECT DEMOAVG(value) FROM demo_table;");
assert_eq!(retval, Ok(Some(2)));
}
}

Expand Down
5 changes: 2 additions & 3 deletions pgx-examples/arrays/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ pub mod tests {
#[search_path(@extschema@)]
fn test_vec_of_customtype() {
let customvec =
Spi::get_one::<Vec<SomeStruct>>("SELECT arrays.return_vec_of_customtype();")
.expect("SQL select failed");
assert_eq!(customvec, vec![SomeStruct {}]);
Spi::get_one::<Vec<SomeStruct>>("SELECT arrays.return_vec_of_customtype();");
assert_eq!(customvec, Ok(Some(vec![SomeStruct {}])));
}
}
2 changes: 1 addition & 1 deletion pgx-examples/bgworker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub extern "C" fn background_worker_main(arg: pg_sys::Datum) {

// within a transaction, execute an SQL statement, and log its results
BackgroundWorker::transaction(|| {
Spi::execute(|client| {
Spi::connect(|client| {
let tuple_table = client.select(
"SELECT 'Hi', id, ''||a FROM (SELECT id, 42 from generate_series(1,10) id) a ",
None,
Expand Down
Loading