Lists: | pgsql-general |
---|
From: | Wim Bertels <wim(dot)bertels(at)khleuven(dot)be> |
---|---|
To: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | function to filter out tokens (sql syntax lexical)? |
Date: | 2011-04-14 18:06:21 |
Message-ID: | 1302804381.18226.14.camel@zwerfkat |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Hallo,
according to
http://www.postgresql.org/docs/8.4/interactive/sql-syntax-lexical.htm
A token can be a key word, an identifier, a quoted identifier, a literal
(or constant), or a special character symbol.
I suppose these different tokens are used by the internal parser?
So my questions is,
is there a function one could use to filter out the specific tokes?
Example:
Given the statement: INSERT INTO MY_TABLE VALUES (3, 'hi there');
We can do something like:
select filter_tokens($$INSERT INTO MY_TABLE VALUES (3, 'hi there');$$);
With output:
token | type
Insert keyword
into keyword
my_table identifier
values keyword
..
'hi there' literal
or in another way with similar functionality?
mvg,
Wim
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Wim Bertels <wim(dot)bertels(at)khleuven(dot)be> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: function to filter out tokens (sql syntax lexical)? |
Date: | 2011-04-14 20:53:10 |
Message-ID: | 20349.1302814390@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Wim Bertels <wim(dot)bertels(at)khleuven(dot)be> writes:
> is there a function one could use to filter out the specific tokes?
In 8.4 and up, pg_get_keywords() might help.
regards, tom lane
From: | Wim Bertels <wim(dot)bertels(at)khleuven(dot)be> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: function to filter out tokens (sql syntax lexical)? |
Date: | 2011-04-15 08:07:11 |
Message-ID: | 1302854831.18226.18.camel@zwerfkat |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
On Thu, 2011-04-14 at 16:53 -0400, Tom Lane wrote:
> Wim Bertels <wim(dot)bertels(at)khleuven(dot)be> writes:
> > is there a function one could use to filter out the specific tokes?
>
> In 8.4 and up, pg_get_keywords() might help.
indeed something i could use as reference
i'm actually looking for a way to compare two sql statement,
and to check if they are equivalent (not only semantically,
since this usually makes a difference in execution plan).
i suppose the postgresql internal must have some sort of functions
handling this, while parsing the statement.
i would be handy to have this function available as a db user.
tnx,
Wim
>
> regards, tom lane
>