Thanks Tom,
I attacked the issue another way which appears to work...
I used :
explain select * from nodes left join node_names on node_names.node_id = nodes.node_id
which returned :
query
QUERY PLAN
1 Merge Right Join (cost=429.16..793.48 rows=4510 width=193)
2 Merge Cond: ("outer".node_id = "inner".node_id)
3 -> Index Scan using node_names_node_id_key on node_names (cost=0.00..278.58 rows= 7253 width=110)
4 -> Sort (cost=429.16..438.89 rows=3894 width=83)
5 Sort Key: nodes.node_id
6 -> Seq Scan on nodes (cost=0.00..196.94 rows=3894 width=83)
and then programatically searched for lines that begin with :
Seq Scan on #table_name#
Index Scan using #indexname# on #table_name#
obtaining the #table_name#
Being : nodes, node_names
Theo
-----Original Message-----
From: Tom Lane [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 6 October 2004 1:36 PM
To: Theo Galanakis
Cc: [EMAIL PROTECTED] Org
Subject: Re: [SQL] Regex
Theo Galanakis <[EMAIL PROTECTED]> 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
______________________________________________________________________ This email, including attachments, is intended only for the addressee and may be confidential, privileged and subject to copyright. If you have received this email in error, please advise the sender and delete it. If you are not the intended recipient of this email, you must not use, copy or disclose its content to anyone. You must not copy or communicate to others content that is confidential or subject to copyright, unless you have the consent of the content owner. |