From: | Josef Šimánek <josef(dot)simanek(at)gmail(dot)com> |
---|---|
To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: [PATCH] Add --syntax to postgres for SQL syntax checking |
Date: | 2023-12-15 15:20:43 |
Message-ID: | CAFp7Qwq1Aw-cTgi2q58ML+jLZ_Tmf2jk3KH+CnDbOkCNJU6xbQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
pá 15. 12. 2023 v 16:16 odesílatel David G. Johnston
<david(dot)g(dot)johnston(at)gmail(dot)com> napsal:
>
> On Fri, Dec 15, 2023 at 8:05 AM Josef Šimánek <josef(dot)simanek(at)gmail(dot)com> wrote:
>>
>> pá 15. 12. 2023 v 15:50 odesílatel Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> napsal:
>> >
>> > Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)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)?
>>
>> Per my experience, this is mostly useful during development to catch
>> syntax errors super early.
>
>
> I'd suggest helping this project get production capable since it already is trying to integrate with the development ecosystem you describe here.
>
> https://github.com/supabase/postgres_lsp
Indeed LSP is the one of the targets of this feature. Currently it is
using https://github.com/pganalyze/libpg_query under the hood probably
because of the same reasons I have described (parser is not available
in public APIs of postgres_fe.h or libpq). Exposing basic parser
capabilities in postgres binary itself and also on SQL level by
pg_check_syntax function can prevent the need of "hacking" pg parser
to be accessible outside of server binary.
> I agree that developing this as a new executable for the purpose is needed in order to best conform to existing conventions.
>
> David J.
>
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2023-12-15 15:31:32 | Re: [PATCH] Add --syntax to postgres for SQL syntax checking |
Previous Message | David G. Johnston | 2023-12-15 15:16:12 | Re: [PATCH] Add --syntax to postgres for SQL syntax checking |