Re: Regex - Mailing list pgsql-sql

From Tom Lane
Subject Re: Regex
Date
Msg-id 20759.1097033789@sss.pgh.pa.us
Whole thread Raw
In response to Regex  (Theo Galanakis <Theo.Galanakis@lonelyplanet.com.au>)
List pgsql-sql
Theo Galanakis <Theo.Galanakis@lonelyplanet.com.au> writes:
> Basically the regex should return TABLEA, TABLEB from:

> Select * 
> from TABLEA
> Inner jon TABLEB on tableb.columna = tablea.columna

You realize of course that this problem is mathematically impossible?
Regexes are less powerful than context-free grammars, and so it is a
certainty that there exist legal SQL statements that will fool any regex
that you invent for this purpose.

If you know that the SQL statements are coming from a query generator
that produces only a certain style of SQL code, then you might be able
to come up with a solution that works reliably for the output of that
query generator.  But I wonder if you wouldn't be better off bypassing
the parse-and-deparse hacking and tapping directly into the query
generator.
        regards, tom lane


pgsql-sql by date:

Previous
From: sreejith s
Date:
Subject: Database Backup
Next
From: Theo Galanakis
Date:
Subject: Re: Regex