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

Deprecate pg_extern on non-pub fn? #1471

Open
workingjubilee opened this issue Jan 9, 2024 · 1 comment
Open

Deprecate pg_extern on non-pub fn? #1471

workingjubilee opened this issue Jan 9, 2024 · 1 comment
Labels
deprecation macro rust+sql Interop between Rust and SQL schema

Comments

@workingjubilee
Copy link
Member

workingjubilee commented Jan 9, 2024

In a very real sense, when you expose a function via pg_extern, you are making it public in every way that really matters: it is now a callable symbol in the binary with a predictable name! Admittedly, it is using a different ABI, so if we were truly writing these in Rust, they might be written

pub extern "Postgres" fn wrapper_around_rust_fn() -> Type {
    rust_fn()
}

( And we might be able to have people write that if we wanted, too, but we would have to consume the extern "Postgres" before rustc can complain about it. )

The real problem is that every proposed Rust compile-time reflection scheme I have seen, and even several macro-based solutions for problems in pgrx like schema generation, either inherently respects privacy or tends to respect it. So I have begun thinking that perhaps we should require these fn to be pub, so that we can use those solutions in the future (see also #1468).

However, this is a change that is likely to break a lot of code. Accordingly, it would be... extremely rude to land this outright. If this is done, it has to be incremental, with a deprecation warning first.

Even landing the deprecation warning, however, should not happen until 0.13, for two reasons:

  • 0.12 is going to keep people busy enough fixing code due to the lifetime fixes.
  • This needs more time to be thought over, for other considerations. For instance, the real problem is arguably that the arguments and return types are public information at this point: if these fn were written using their own real ABI string like above, then calling a private function would be fine, but using a non-public return type would cause reachability problems, so perhaps we want to do something more complicated and more precise?
@workingjubilee workingjubilee added deprecation rust+sql Interop between Rust and SQL macro labels Jan 9, 2024
@workingjubilee
Copy link
Member Author

#1549 is another example of someone expecting pgrx to not change the symbol name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecation macro rust+sql Interop between Rust and SQL schema
Projects
None yet
Development

No branches or pull requests

1 participant