Re: validate synatax - Mailing list pgsql-general

From Jerry Sievers
Subject Re: validate synatax
Date
Msg-id 86eh5kz509.fsf@jerry.enova.com
Whole thread Raw
In response to validate synatax  (Peter Kroon <plakroon@gmail.com>)
List pgsql-general
Peter Kroon <plakroon@gmail.com> writes:

> 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
aTABLE 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.


/yomama
=# create or replace function foo() returns void as $$create table foo()$$ language sql;
CREATE FUNCTION
/yomama
=# create or replace function foo() returns void as $$create table foo() bogus syntax$$ language sql;
ERROR:  syntax error at or near "bogus"
LINE 1: ...nction foo() returns void as $$create table foo() bogus synt...
                                                             ^
/yomama
=# select version();
                                           version
----------------------------------------------------------------------------------------------
 PostgreSQL 9.1.9 on x86_64-unknown-linux-gnu, compiled by gcc (Debian 4.7.2-5) 4.7.2, 64-bit
(1 row)


>
> Best,
> Peter
>

--
Jerry Sievers
Postgres DBA/Development Consulting
e: postgres.consulting@comcast.net
p: 312.241.7800


pgsql-general by date:

Previous
From: Peter Kroon
Date:
Subject: Re: validate synatax
Next
From: John Melesky
Date:
Subject: Zero dead tuples, when significant apparent bloat