Tom Lane:
This is really what is missing for the ecosystem. A libpqparser for
tools to use: Formatters, linters, query rewriters, simple syntax
checkers... they are all missing access to postgres' own parser.

To get to that, you'd need some kind of agreement on what the syntax
tree is.  I doubt our existing implementation would be directly useful
to very many tools, and even if it is, do they want to track constant
version-to-version changes?

Correct, on top of what the syntax tree currently has, one would probably need:
- comments
- locations (line number / character) for everything, including those of comments

Otherwise it's impossible to print proper SQL again without losing information.

And then on top of that, to be really really useful, you'd need to be able to parse partial statements, too, to support all kinds of "language server" applications.

Tracking version-to-version changes is exactly the reason why it would be good to have that from upstream, imho. New syntax is added in (almost?) every release and everyone outside core trying to write their own parser and staying up2date with **all** the new syntax.. will eventually fail.

Yes, there could be changes to the produced parse tree as well and you'd also need to adjust, for example, your SQL-printers. But it should be easier to stay up2date than right now.

Best,

Wolfgang


Reply via email to