function to filter out tokens (sql syntax lexical)? - Mailing list pgsql-general

From Wim Bertels
Subject function to filter out tokens (sql syntax lexical)?
Date
Msg-id 1302804381.18226.14.camel@zwerfkat
Whole thread Raw
Responses Re: function to filter out tokens (sql syntax lexical)?
List 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


pgsql-general by date:

Previous
From: Benjamin Smith
Date:
Subject: Re: SSDs with Postgresql?
Next
From: Scott Marlowe
Date:
Subject: Re: SSDs with Postgresql?