pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedParsed Query Trees
4+ messages / 3 participants
[nested] [flat]
* Parsed Query Trees
@ 2007-11-05 18:46 Kevin Neufeld <kneufeld@refractions.net>
0 siblings, 1 reply; 4+ messages in thread
From: Kevin Neufeld @ 2007-11-05 18:46 UTC (permalink / raw)
To: pgsql-jdbc
Does anyone know if a parsed query tree object is exposed in the jdbc
API? I couldn't find any such thing, nor could I find it in the
developers roadmap.
My particular requirement is that I need to be able to parse /
deconstruct an arbitrary SELECT query (which may be overly complicated)
and add custom filters to the WHERE clause depending on what columns
(optionally schema-qualified) and server datatypes are specified in the
select clause.
I'm currently use a sql parser that I wrote, but it seems silly to have
to re-invent the wheel. I suppose I could use a 3rd party jar, like
sql4j or Zsql, but these are rather old and simplistic and don't seem to
do what I need them to do. Postgres is already parsing my sql queries -
it would just be nice to have access to these parsed query trees so I
can edit and then resend them to the database.
Cheers,
Kevin
-------------
Kevin Neufeld
Software Developer
Refractions Research Inc.
300-1207 Douglas St.
Victoria, B.C., V8W 2E7
Phone: (250) 383-3022
Email: kneufeld@refractions.net
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Parsed Query Trees
@ 2007-11-05 22:53 Oliver Jowett <oliver@opencloud.com>
parent: Kevin Neufeld <kneufeld@refractions.net>
0 siblings, 1 reply; 4+ messages in thread
From: Oliver Jowett @ 2007-11-05 22:53 UTC (permalink / raw)
To: Kevin Neufeld <kneufeld@refractions.net>; +Cc: pgsql-jdbc
Kevin Neufeld wrote:
> Does anyone know if a parsed query tree object is exposed in the jdbc
> API? I couldn't find any such thing, nor could I find it in the
> developers roadmap.
No, and the reason is that the JDBC driver doesn't actually parse the
query beyond some basic manipulations to find parameter placeholders and
so on. All the real parsing happens on the server side, and I don't know
of a way to get access to the server's query tree as a client. (It's
debatable how useful that would be, anyway)
-O
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Parsed Query Trees
@ 2007-11-06 03:25 Tom Lane <tgl@sss.pgh.pa.us>
parent: Oliver Jowett <oliver@opencloud.com>
0 siblings, 1 reply; 4+ messages in thread
From: Tom Lane @ 2007-11-06 03:25 UTC (permalink / raw)
To: Oliver Jowett <oliver@opencloud.com>; +Cc: Kevin Neufeld <kneufeld@refractions.net>; pgsql-jdbc
Oliver Jowett <oliver@opencloud.com> writes:
> Kevin Neufeld wrote:
>> Does anyone know if a parsed query tree object is exposed in the jdbc
>> API? I couldn't find any such thing, nor could I find it in the
>> developers roadmap.
> No, and the reason is that the JDBC driver doesn't actually parse the
> query beyond some basic manipulations to find parameter placeholders and
> so on. All the real parsing happens on the server side, and I don't know
> of a way to get access to the server's query tree as a client. (It's
> debatable how useful that would be, anyway)
I'd very strongly resist exposing the server's parsetrees to clients,
because then changing them would represent a protocol break, and we
change them constantly.
If you're desperate to have an editing facility like this, put it into
server-side code ... and expect to revise it at every major release.
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Parsed Query Trees
@ 2007-11-06 04:47 Kevin Neufeld <kneufeld@refractions.net>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 4+ messages in thread
From: Kevin Neufeld @ 2007-11-06 04:47 UTC (permalink / raw)
To: pgsql-jdbc
Hmmm.
Thanx guys. I didn't clue in that the parsetrees underwent constant
change - they obviously do since query syntax changes all the time. I'm
clearly going to have to approach my problem from a different angle.
Cheers,
Kevin
Tom Lane wrote:
> Oliver Jowett <oliver@opencloud.com> writes:
>
>> Kevin Neufeld wrote:
>>
>>> Does anyone know if a parsed query tree object is exposed in the jdbc
>>> API? I couldn't find any such thing, nor could I find it in the
>>> developers roadmap.
>>>
>
>
>> No, and the reason is that the JDBC driver doesn't actually parse the
>> query beyond some basic manipulations to find parameter placeholders and
>> so on. All the real parsing happens on the server side, and I don't know
>> of a way to get access to the server's query tree as a client. (It's
>> debatable how useful that would be, anyway)
>>
>
> I'd very strongly resist exposing the server's parsetrees to clients,
> because then changing them would represent a protocol break, and we
> change them constantly.
>
> If you're desperate to have an editing facility like this, put it into
> server-side code ... and expect to revise it at every major release.
>
> regards, tom lane
>
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2007-11-06 04:47 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-11-05 18:46 Parsed Query Trees Kevin Neufeld <kneufeld@refractions.net>
2007-11-05 22:53 ` Oliver Jowett <oliver@opencloud.com>
2007-11-06 03:25 ` Tom Lane <tgl@sss.pgh.pa.us>
2007-11-06 04:47 ` Kevin Neufeld <kneufeld@refractions.net>
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