support plpgsql function bodies
once we have #178, we can start looking into this too. pg_query.rs already exposes a basic binding for parsing plpgsql. we should first improve that binding upstream and then start adding language features like autocompletion.
Very much looking forward to this. Given that most of our non-trivial sql code is functions rather than regular schema tables and whatnot, not having the language server parse those means we lose a lot of error checking.
Is there a way one could help you on this without writing/building (rust) code for this repo @psteinroe ? Like researching, specifying, test examples or other sql/plpgsql related tasks?
we have made a bit of progress here! although there is still a lot to do for "proper" support, we have a clearer road ahead of us now:
- the latest version (releasing as we speak) will show plpgsql syntax errors. this is a low-hanging fruit we wanted to get out already now
- unfortunately, proper support will require us to have a proper parser. libpg_query, the underlying postgres parser we use, does support parsing plpgsql, but they do not have a proper binding for it (yet). it returns just unstructured json.
- there is effort over at https://github.com/sbdchd/squawk to build custom parsers. I am a big fan of the project, but it's a huge effort. maybe the plpgsql syntax is simple enough to get there eventually though.
- at the same time, I am exploring ways to add a proper binding for plpgsql to upstream libpg_query. this is I think the simpler and more robust approach, since we are really just using the same parser that Postgres uses internally.
in the next version, we will support plpgsql_check (#469). If you have that extension installed on your local database, we will use the extension to provide diagnostics in your IDE. I will be on vacation next week, and will release it right when I am back!
I kinda forgot about it when I wrote the previous comment, but it works remarkably well and should cover most needs already - without any custom parser!
the new version with plpgsql_check is out now! looking forward to your feedback :)