-
-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issues with error handling across FFI boundaries (#250)
* Fix issues with error handling across FFI boundaries This also makes a few functions unsafe, so we had to litter parts of the code with unsafe{} blocks. The primary user-facing change here is if users are using `pgx::direct_function_call()` to call Rust-based functions with the `#[pg_extern]` annotation, those functions now need to be called using `pgx::direct_pg_extern_function_call()`. In general, this is yet another follow-up to issue #241. * bump version to 0.1.25
- Loading branch information
1 parent
3ee5839
commit f38ab31
Showing
20 changed files
with
260 additions
and
119 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "pgx-parent" | ||
version = "0.1.24" | ||
version = "0.1.25" | ||
authors = ["ZomboDB, LLC <[email protected]>"] | ||
edition = "2018" | ||
license = "MIT" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "cargo-pgx" | ||
version = "0.1.24" | ||
version = "0.1.25" | ||
authors = ["ZomboDB, LLC <[email protected]>"] | ||
edition = "2018" | ||
license = "MIT" | ||
|
@@ -19,7 +19,7 @@ clap = { version = "2.33.3", features = [ "yaml" ] } | |
colored = "2.0.0" | ||
env_proxy = "0.4.1" | ||
num_cpus = "1.13.0" | ||
pgx-utils = { path = "../pgx-utils", version = "0.1.24" } | ||
pgx-utils = { path = "../pgx-utils", version = "0.1.25" } | ||
proc-macro2 = { version = "1.0.28", features = [ "span-locations" ] } | ||
quote = "1.0.9" | ||
rayon = "1.5.1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "pgx-macros" | ||
version = "0.1.24" | ||
version = "0.1.25" | ||
authors = ["ZomboDB, LLC <[email protected]>"] | ||
edition = "2018" | ||
license = "MIT" | ||
|
@@ -14,7 +14,7 @@ readme = "README.md" | |
proc-macro = true | ||
|
||
[dependencies] | ||
pgx-utils = { path = "../pgx-utils", version = "0.1.24" } | ||
pgx-utils = { path = "../pgx-utils", version = "0.1.25" } | ||
proc-macro2 = "1.0.28" | ||
quote = "1.0.9" | ||
syn = { version = "1.0.75", features = [ "extra-traits", "full", "fold", "parsing" ] } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "pgx-pg-sys" | ||
version = "0.1.24" | ||
version = "0.1.25" | ||
authors = ["ZomboDB, LLC <[email protected]>"] | ||
edition = "2018" | ||
license = "MIT" | ||
|
@@ -25,14 +25,14 @@ targets = ["x86_64-unknown-linux-gnu"] | |
[dependencies] | ||
memoffset = "0.6.4" | ||
once_cell = "1.8.0" | ||
pgx-macros = { path = "../pgx-macros/", version = "0.1.24" } | ||
pgx-macros = { path = "../pgx-macros/", version = "0.1.25" } | ||
|
||
[build-dependencies] | ||
bindgen = "0.59.1" | ||
build-deps = "0.1.4" | ||
colored = "2.0.0" | ||
num_cpus = "1.13.0" | ||
pgx-utils = { path = "../pgx-utils/", version = "0.1.24" } | ||
pgx-utils = { path = "../pgx-utils/", version = "0.1.25" } | ||
proc-macro2 = "1.0.28" | ||
quote = "1.0.9" | ||
rayon = "1.5.1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "pgx-tests" | ||
version = "0.1.24" | ||
version = "0.1.25" | ||
authors = ["ZomboDB, LLC <[email protected]>"] | ||
edition = "2018" | ||
license = "MIT" | ||
|
@@ -29,9 +29,9 @@ no-default-features = true | |
colored = "2.0.0" | ||
lazy_static = "1.4.0" | ||
libc = "0.2.101" | ||
pgx = { path = "../pgx", default-features = false, version= "0.1.24" } | ||
pgx-macros = { path = "../pgx-macros", version= "0.1.24" } | ||
pgx-utils = { path = "../pgx-utils", version= "0.1.24" } | ||
pgx = { path = "../pgx", default-features = false, version= "0.1.25" } | ||
pgx-macros = { path = "../pgx-macros", version= "0.1.25" } | ||
pgx-utils = { path = "../pgx-utils", version= "0.1.25" } | ||
postgres = "0.19.1" | ||
regex = "1.5.4" | ||
serde = "1.0.130" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,41 @@ | ||
// Copyright 2020 ZomboDB, LLC <[email protected]>. All rights reserved. Use of this source code is | ||
// governed by the MIT license that can be found in the LICENSE file. | ||
|
||
use pgx::*; | ||
|
||
// if our Postgres ERROR and Rust panic!() handling is incorrect, this little bit of useless code | ||
// will crash postgres. If things are correct it'll simply raise an ERROR saying "panic in walker". | ||
#[pg_extern] | ||
fn crash() { | ||
unsafe { | ||
let mut node = PgList::<pg_sys::Node>::new(); | ||
node.push(PgList::<pg_sys::Node>::new().into_pg() as *mut pg_sys::Node); | ||
|
||
pg_sys::raw_expression_tree_walker( | ||
node.into_pg() as *mut pg_sys::Node, | ||
Some(walker), | ||
std::ptr::null_mut(), | ||
); | ||
} | ||
} | ||
|
||
#[pg_guard] | ||
extern "C" fn walker() -> bool { | ||
panic!("panic in walker"); | ||
} | ||
|
||
#[cfg(any(test, feature = "pg_test"))] | ||
mod tests { | ||
#[allow(unused_imports)] | ||
use crate as pgx_tests; | ||
|
||
use pgx::*; | ||
|
||
#[pg_test(error = "panic in walker")] | ||
fn test_panic_in_extern_c_fn() { | ||
Spi::get_one::<()>("SELECT crash()"); | ||
} | ||
|
||
#[pg_test] | ||
fn test_pg_try_unwrap_no_error() { | ||
let result = pg_try(|| 42).unwrap(); | ||
|
Oops, something went wrong.