Well it's not what you were expecting, but your idea sounds interesting too! Maybe you could muster the same open source forces to make it a reality?
https://github.com/wasmerio/wasmer-postgres
It only works for PG10, but I can't imagine it will take much effort to bring it up to the latest version