Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s7Jsq-004zHR-OV for pgsql-hackers@arkaria.postgresql.org; Wed, 15 May 2024 19:01:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1s7Jsq-004nkS-9k for pgsql-hackers@arkaria.postgresql.org; Wed, 15 May 2024 19:01:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s7Jsq-004ni9-03 for pgsql-hackers@lists.postgresql.org; Wed, 15 May 2024 19:01:48 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s7Jsi-000PXs-Ek for pgsql-hackers@lists.postgresql.org; Wed, 15 May 2024 19:01:47 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 44FJ1PrU1815339; Wed, 15 May 2024 15:01:25 -0400 From: Tom Lane To: walther@technowledgy.de cc: =?UTF-8?B?Sm9zZWYgxaBpbcOhbmVr?= , Robert Haas , Tomas Vondra , "David G. Johnston" , Laurenz Albe , PostgreSQL Hackers Subject: Re: [PATCH] Add --syntax to postgres for SQL syntax checking In-reply-to: <43eeedd7-51a6-4520-8848-247341566e3d@technowledgy.de> References: <965e2e5482378229d846181bba6ffd384257b0cc.camel@cybertec.at> <2980108.1702651820@sss.pgh.pa.us> <64f4c421-12ea-4801-ba0a-9e227b6014bb@enterprisedb.com> <1809846.1715798387@sss.pgh.pa.us> <43eeedd7-51a6-4520-8848-247341566e3d@technowledgy.de> Comments: In-reply-to walther@technowledgy.de message dated "Wed, 15 May 2024 20:49:17 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1815337.1715799685.1@sss.pgh.pa.us> Date: Wed, 15 May 2024 15:01:25 -0400 Message-ID: <1815338.1715799685@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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