pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Theo Galanakis <Theo.Galanakis@lonelyplanet.com.au>
Cc: Pgsql-Sql@Postgresql. Org <pgsql-sql@postgresql.org>
Subject: Re: Regex
Date: Tue, 05 Oct 2004 23:36:29 -0400
Message-ID: <20759.1097033789@sss.pgh.pa.us> (raw)
In-Reply-To: <82E30406384FFB44AFD1012BAB230B5505F40D26@shiva.au.lpint.net>
References: <82E30406384FFB44AFD1012BAB230B5505F40D26@shiva.au.lpint.net>

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



view thread (4+ messages)  latest in thread

Message-ID: <20759.1097033789@sss.pgh.pa.us>
Permalink:  ../20759.1097033789@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20759.1097033789@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, Theo.Galanakis@lonelyplanet.com.au
  Subject: Re: Regex
  In-Reply-To: <20759.1097033789@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox