Re: validate synatax

From: Jerry Sievers <gsievers19(at)comcast(dot)net>
To: Peter Kroon <plakroon(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 22:59:50
Message-ID: 86eh5kz509.fsf@jerry.enova.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Peter Kroon <plakroon(at)gmail(dot)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 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.

/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(dot)consulting(at)comcast(dot)net
p: 312.241.7800

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John Melesky 2013-12-11 01:05:26 Zero dead tuples, when significant apparent bloat
Previous Message Peter Kroon 2013-12-10 21:57:34 Re: validate synatax