Description
Some code that can be written for trusted language handlers might still soundly call unsafe
code, technically speaking (in Rust terms), but PL/Rust should probably provide a suite of blessed functions that do the typical things we expect safely. There are many ways to lock down Safe Rust, but we should probably develop a plan for allowing easily auditing and eliminating unsafe
code, including in dependencies (see #26), and thereby prevent PL/Rust code from using unsafe
to escape any boxes we put it in.
For dependencies, I believe this may be easy to do with cargo build --build-plan
or --unit-graph
or a similar functionality and simply using rustc --forbid unsafe_code
.
Slightly more complicated is the code handed directly to PL/Rust. We can't simply ban unsafe
code in that because using pgx
expands to include unsafe
code currently! We instead probably need to audit the code for unsafe
while it is flowing through the slightly misleadingly named pgx-utils
, which is PGX's SQL generation proc macro. We could hypothetically make sure everything we expand is safe code but that might be misleading and/or unsound so I am not inclined to presume that is on the table. Instead, we should find some approach to auditing the way pgx
expands.
[ ] Checkingunsafe
deps- Checking
unsafe
in user fn itself - Auditing the PGX expansions we expect
- Guarding against proc macro cleverness in general