Re: Regex

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Theo Galanakis <Theo(dot)Galanakis(at)lonelyplanet(dot)com(dot)au>
Cc: "Pgsql-Sql(at)Postgresql(dot) Org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Regex
Date: 2004-10-06 03:36:29
Message-ID: 20759.1097033789@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Theo Galanakis <Theo(dot)Galanakis(at)lonelyplanet(dot)com(dot)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

In response to

  • Regex at 2004-10-06 00:52:46 from Theo Galanakis

Browse pgsql-sql by date

  From Date Subject
Next Message sad 2004-10-06 05:01:42 Re: Howto turn an integer into an interval?
Previous Message sreejith s 2004-10-06 02:39:38 Database Backup