pgcentralfoundation / pgrx

Build Postgres Extensions with Rust!
Other
3.45k stars 230 forks source link

0.12.0-beta prerelease bug tracking #1769

Open workingjubilee opened 2 weeks ago

workingjubilee commented 2 weeks ago

Please file all your complaints about the beta series of releases here. In addition to breaking certain unsound patterns on purpose, I am expecting considerable bugs or failures to compile extensions that should compile, so if there is a compiler error, then please try to post the full error with the code that appears to produce it. If you cannot post your original code, then please post a reasonable approximation of it, including e.g. linking to a crate in a repository somewhere I can git clone. Fixes for these will be released about as fast as fixes get in, but for some cases it may be decided that the issue is not fixable.

Current versions

0.12.0-beta issues fixed in 0.12.0-beta.3

Other improvements during beta series

the-kenny commented 2 weeks ago

A PgRelation argument for a pg_extern function used to work in 0.11 but triggers a build error in 0.12.0-beta.2:

#[pg_extern(immutable, parallel_safe)]
fn foo(relation: PgRelation) -> Option<&'static str> {
    unimplemented!()
}

0.11 translated this to:

CREATE  FUNCTION "foo"(
    "relation" regclass /* pgrx::rel::PgRelation */
) RETURNS TEXT /* core::option::Option<&str> */
IMMUTABLE STRICT PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'foo_wrapper';

Error in 0.12.0-beta.2:

error[E0277]: the trait bound `pgrx::PgRelation: ArgAbi<'_>` is not satisfied
   --> src/utility_fns.rs:31:31
    |
30  | #[pg_extern(immutable, parallel_safe)]
    | -------------------------------------- in this procedural macro expansion
31  | fn foo(relation: PgRelation) -> Option<&'static str> {
    |        ^^^^^^^^ the trait `ArgAbi<'_>` is not implemented for `pgrx::PgRelation`
    |
    = help: the following other types implement trait `ArgAbi<'fcx>`:
              &'fcx CStr
              &'fcx [u8]
              &'fcx str
              *mut FunctionCallInfoBaseData
              AnyArray
              AnyElement
              AnyNumeric
              BOX
            and 34 others
note: required by a bound in `pgrx::callconv::Args::<'a, 'fcx>::next_arg_unchecked`
   --> .cargo/registry/src/index.crates.io-6f17d22bba15001f/pgrx-0.12.0-beta.2/src/callconv.rs:823:41
    |
823 |     pub unsafe fn next_arg_unchecked<T: ArgAbi<'fcx>>(&mut self) -> Option<T> {
    |                                         ^^^^^^^^^^^^ required by this bound in `Args::<'a, 'fcx>::next_arg_unchecked`
    = note: this error originates in the attribute macro `pg_extern` (in Nightly builds, run with -Z macro-backtrace for more info)

I'm not sure if this is intentional (or expected), but it used to work in 0.11. Workaround should be easy on my side, so feel free to mark this as 'works as intended' :-)

workingjubilee commented 2 weeks ago

Hm. I am trying to decide if it being usable as an argument is useful or correct. I opened that as #1773.

I will impl ArgAbi for it depending on the answers to that.

workingjubilee commented 2 weeks ago

Workaround should be easy on my side, so feel free to mark this as 'works as intended' :-)

We don't make mistakes, we have happy accidents.