4 ms·
This looks very cool and it's nice to see some finicky details like PG_GETARG abstracted away. Are there any plans to make pgzx a Trusted Language so that Zig
by michelpp 3y ago
This looks very cool and it's nice to see some finicky details like PG_GETARG abstracted away.
Are there any plans to make pgzx a Trusted Language so that Zig functions could be written with CREATE FUNCTION? Rust recently achieved this milestone and AWS RDS now supports PL/Rust.
Being a trusted language would mean it could be used to create Trusted Language Extensions (TLEs) and could be installed on cloud hosted databases without filesystem access.
- tudorg 3y agoIt would be amazing if we could could use Zig for TLEs, and we'll look into it, but I worry it might not be possible because Zig can't guarantee memory safety in the same way that Rust can.
- deleted 3y ago[deleted]
- zombodb 3y agoIf you build it, they'll come. The only limit is yourself!
- bear9628 3y agoNo TLE support is a not a goal. Languages/extensions in Postgres should only be marked as trusted if you can guarantee that they do not access Postgres internals or even the file filesystem. With Zig and in pgzx in particular we can not guarantee this to be the case. With pgzx we provide you a number of utilities on top of the C API. But depending on the extension you are working on you might heavily use the Postgres internals and their C APIs as is. Postgres has support for a number of languages. Some having their own strenghts or weaknesses. One strength of Zig is its closeness to C, while providing a many quality of live improvements over C (optional types instead of null pointer, generic data structures, ...). This makes it a formidable choice for extensions that want to integrate deeply with the Postgres internals.
- anarazel 3y agoIf I suddenly had unlimited resources and attention, I'd really like to provide infrastructure to write trusted functions by running them via a webassembly runtime, with a small injected safe surface for accessing postgres functionality. That'd make it a lot easier to write trusted PLs in a variety of languages. Still probably needs a bit of per-language sugar on top, but a lot less than doing it from scratch. Edit: Minor grammar fix
- bear9628 3y agoHehe :) I also have WASM in mind when thinking about future TLE support :)
- michelpp 3y agoI don't know much about it, but I think this has been tried? https://dylibso.com/blog/pg-extism/ https://dylibso.com/blog/pg-extism/ Looking at the repo though it looks like it hasn't been updated in a while.
- pjmlp 3y agoOracle, IBM and Microsoft have been doing that for decades with JVM, CLR and TIMI, yet another use case where Webassembly is a follower.