X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8410C329FED for ; Wed, 6 Oct 2004 04:36:37 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 45011-07 for ; Wed, 6 Oct 2004 03:36:33 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id C236A329FDA for ; Wed, 6 Oct 2004 04:36:33 +0100 (BST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id i963aTAC020760; Tue, 5 Oct 2004 23:36:29 -0400 (EDT) To: Theo Galanakis Cc: "Pgsql-Sql@Postgresql. Org" Subject: Re: Regex In-reply-to: <82E30406384FFB44AFD1012BAB230B5505F40D26@shiva.au.lpint.net> References: <82E30406384FFB44AFD1012BAB230B5505F40D26@shiva.au.lpint.net> Comments: In-reply-to Theo Galanakis message dated "Wed, 06 Oct 2004 10:52:46 +1000" Date: Tue, 05 Oct 2004 23:36:29 -0400 Message-ID: <20759.1097033789@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/36 X-Sequence-Number: 19139 Theo Galanakis 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