Re: validate synatax

From: Peter Kroon <plakroon(at)gmail(dot)com>
To: Szymon Guz <mabewlun(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: validate synatax
Date: 2013-12-10 21:57:34
Message-ID: CAOh+DOkrd0croacXVtDSg=NvcN+Kn=dH=sJGQr05ZbtK6jgO_g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>Why do you want to do that?
I want to validate the SQL syntax and preferably in the browser using some
kind of linter.

>You can always run it inside transaction and rollback at the end.
Sounds dangerous and will make the server very active because it is
executing the SQL.

Yes, the SQL should be tested even if the syntax is correct.

So 2 things to look for:
- Syntax validator
- Check query logic, like does the table exist

Best,
Peter

2013/12/10 Szymon Guz <mabewlun(at)gmail(dot)com>

>
>
>
> On 10 December 2013 22:40, Peter Kroon <plakroon(at)gmail(dot)com> wrote:
>
>> Hi,
>>
>> How can I validate any query on PostgreSQL without executing the sql.
>> I was able with EXPLAIN to find some errors. However this only worked
>> with a SELECT statement. When i tried to create a TABLE it would not run.
>> I do not wish to install external packages. Preferably use only default
>> present features.
>>
>>
>> http://wiki.postgresql.org/wiki/Introduction_to_VACUUM,_ANALYZE,_EXPLAIN,_and_COUNT#PostgreSQL_EXPLAIN
>>
>> Any suggestions are welcome.
>>
>> Best,
>> Peter
>>
>
> Why do you want to do that? Maybe just test it, there can be many more
> problems then just not executing query, the query logic could be bad, even
> if the syntax is correct. You can always run it inside transaction and
> rollback at the end.
>
> regards,
> Szymon
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jerry Sievers 2013-12-10 22:59:50 Re: validate synatax
Previous Message Szymon Guz 2013-12-10 21:44:55 Re: validate synatax