Skip to content

Possible issue with function types in generated bindings #2115

@Sinjo

Description

@Sinjo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions