Re: [PATCH] Add --syntax to postgres for SQL syntax checking
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: walther@technowledgy.de
Cc: Josef Šimánek <josef.simanek@gmail.com>, Robert Haas <robertmhaas@gmail.com>, Tomas Vondra <tomas.vondra@enterprisedb.com>, "David G. Johnston" <david.g.johnston@gmail.com>, Laurenz Albe <laurenz.albe@cybertec.at>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-05-15T19:01:25Z
Lists: pgsql-hackers
walther@technowledgy.de writes: > Tom Lane: >> BTW, if you do feel that a pure grammar check is worthwhile, you >> should look at the ecpg preprocessor, which does more or less that >> with the SQL portions of its input. > Would working with ecpg allow to get back a parse tree of the query to > do stuff with that? No, ecpg isn't interested in building a syntax tree. > 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? regards, tom lane