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 Array<'a, T>::as_slice #672

Merged
merged 10 commits into from
Sep 13, 2022
Merged

Conversation

workingjubilee
Copy link
Member

This marks the formal beginning of the deprecation process for the Array<'_, T>::as_slice function. As currently implemented, it cannot be safe without inducing at minimum these panics, which means it must be unsafe, which would already be a breaking change to introduce. And this does not actually make it fully correct, either, but we can expect code "in the wild" probably exercises this function as it is fairly idiomatic to use in Rust, so removing it abruptly without offering these directions would make the upgrade path for 0.5.0 even more annoying.

I expect we can introduce a new variant of this function in the future which offers a very similar interface and is either safe or unsafe (and arguably RawArray offers the unsafe version already), but I expect that to not happen before 0.6.1 or 0.7.0, as it involves some fairly sweeping structural changes in PGX.

This introduces pgx::Layout (with Size and Align types composing it),
parallel to std::alloc::Layout, but modified to allow describing
the Postgres layouts instead.

Some of the constants in this implementation are recently #defined.
We can simply polyfill simple constants and structs in Postgres 10-12,
to make binding against Postgres slightly easier in pgx itself.
This should be done more cautiously for functions and the like.
@workingjubilee
Copy link
Member Author

I had to add several tests to feel confident merging this but I feel it is ready now.

@workingjubilee workingjubilee merged commit 8d9a1c3 into develop Sep 13, 2022
@eeeebbbbrrrr eeeebbbbrrrr deleted the deprecate-array-as-slice branch June 20, 2023 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant