function to filter out tokens (sql syntax lexical)?

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
Thread:
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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2011-04-14 18:27:34 Re: SSDs with Postgresql?
Previous Message nothing 2011-04-14 18:00:58 Re: Multiple foreign keys with the same name and information_schema