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

From Tom Lane
Subject Re: [PATCH] Add --syntax to postgres for SQL syntax checking
Date
Msg-id 2980108.1702651820@sss.pgh.pa.us
Whole thread Raw
In response to Re: [PATCH] Add --syntax to postgres for SQL syntax checking  (Laurenz Albe <laurenz.albe@cybertec.at>)
Responses Re: [PATCH] Add --syntax to postgres for SQL syntax checking
Re: [PATCH] Add --syntax to postgres for SQL syntax checking
List pgsql-hackers
Laurenz Albe <laurenz.albe@cybertec.at> writes:
> On Fri, 2023-12-15 at 13:21 +0100, Josef Šimánek wrote:
>> Inspired by Simon Riggs' keynote talk at PGCounf.eu 2023 sharing list
>> of ideas for PostgreSQL
>> (https://riggs.business/blog/f/postgresql-todo-2023), I have crafted a
>> quick patch to do SQL syntax validation.
>> 
>> What do you think?

> I like the idea.  But what will happen if the SQL statement references
> tables or other objects, since we have no database?

This seems like a fairly useless wart to me.  What does it do that
you can't do better with existing facilities (psql etc)?

In the big picture a command line switch in the postgres executable
doesn't feel like the right place for this.  There's no good reason
to assume that the server executable will be installed where you want
this capability; not to mention the possibility of version skew
between that executable and whatever installation you're actually
running on.

Another thing I don't like is that this exposes to the user what ought
to be purely an implementation detail, namely the division of labor
between gram.y (raw_parser()) and the rest of the parser.  There are
checks that a user would probably see as "syntax checks" that don't
happen in gram.y, and conversely there are some things we reject there
that seem more like semantic than syntax issues.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: [meson] expose buildtype debug/optimization info to pg_config
Next
From: Josef Šimánek
Date:
Subject: Re: [PATCH] Add --syntax to postgres for SQL syntax checking