From: | Theo Galanakis <Theo(dot)Galanakis(at)lonelyplanet(dot)com(dot)au> |
---|---|
To: | "Pgsql-Sql(at)Postgresql(dot) Org" <pgsql-sql(at)postgresql(dot)org> |
Cc: | 'Tom Lane' <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Subject: | Re: Regex |
Date: | 2004-10-06 05:44:13 |
Message-ID: | 82E30406384FFB44AFD1012BAB230B5505F40D29@shiva.au.lpint.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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:tgl(at)sss(dot)pgh(dot)pa(dot)us]
Sent: Wednesday, 6 October 2004 1:36 PM
To: Theo Galanakis
Cc: Pgsql-Sql(at)Postgresql(dot) Org
Subject: Re: [SQL] Regex
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
______________________________________________________________________
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.
From | Date | Subject | |
---|---|---|---|
Next Message | Erik Wasser | 2004-10-06 08:13:27 | Re: Howto turn an integer into an interval? |
Previous Message | sad | 2004-10-06 05:01:42 | Re: Howto turn an integer into an interval? |