-
-
Notifications
You must be signed in to change notification settings - Fork 290
Description
Hey, I've been doing some work that involves setting up an fmgr_hook
and I've run into what I think is an issue with the types of the generated function bindings.
In my hook, I'm trying to change the function that Postgres calls in certain situations by setting different values in flinfo
before returning from the hook. Specifically I'm calling a built-in function (pgsql_version
) in those situations.
The issue I've run into is that the generated binding (pg_sys::pgsql_version
) is declared as a "Rust"
function rather than a "C-unwind"
one. I did a little bit of digging in the generated bindings and noticed that the function is wrapped in an unsafe extern "C-unwind"
block
#[pgrx_macros::pg_guard]
unsafe extern "C-unwind" {
... // a tonne of other function definitions
pub fn pgsql_version(fcinfo: FunctionCallInfo) -> Datum;
but that the pg_guard
proc macro intentionally rewrites those functions to not be extern "C-unwind"
. I'm not sure if this is the intended type signature for these function bindings and I'm using PGRX wrong here, or if this is an unintended interaction between the macro and the generated function bindings.
I've made a repo with a minimal reproduction of the issue here, which hopefully makes the situation clear.