Re: [PATCH] Add --syntax to postgres for SQL syntax checking - Mailing list pgsql-hackers

From walther@technowledgy.de
Subject Re: [PATCH] Add --syntax to postgres for SQL syntax checking
Date
Msg-id b4429432-2a90-49e3-b963-dac8b19fd87e@technowledgy.de
Whole thread Raw
In response to Re: [PATCH] Add --syntax to postgres for SQL syntax checking  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [PATCH] Add --syntax to postgres for SQL syntax checking
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: add function argument names to regex* functions.
Next
From: Peter Geoghegan
Date:
Subject: Re: Incorrect Assert in BufFileSize()?