You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried using pg_query::parse (rust) but the body of plpgsql functions comes up as a string "begin <SQL stuff> end". Moreover to use parse_plpgsql I have to use a full function definition, not just what is in between begin and end. Is there a way to parse both of these, a full fledged sql file that will have queries, triggers, and functions and fully parse the function bodies?
Thanks you
The text was updated successfully, but these errors were encountered:
@rex-remind101 There isn't any function like that today - technically it should be possible to add, but the challenge is with the resulting parse tree (the regular SQL AST is independent of the PL/pgSQL AST).
The easiest approach today, which is a bit of a hack, would be to parse the SQL first, then identify the relevant CreateFunctionStmts and then either (1) Use the location field of the top-level node to identify where the statement starts/end in the source string, (2) use the deparser (which is pretty complete) to turn the function definition back into SQL, and then pass that to the PL/pgSQL parser.
The easiest way to improve this (different than your suggestion), would be to have a function that takes a CreateFunctionStmt parse node and does the PL/pgSQL parsing based on that. PRs welcome :)
I tried using
pg_query::parse
(rust) but the body of plpgsql functions comes up as a string"begin <SQL stuff> end"
. Moreover to useparse_plpgsql
I have to use a full function definition, not just what is in betweenbegin
andend
. Is there a way to parse both of these, a full fledged sql file that will have queries, triggers, and functions and fully parse the function bodies?Thanks you
The text was updated successfully, but these errors were encountered: