Re: Synthesize support for Statement.getGeneratedKeys()? - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: Synthesize support for Statement.getGeneratedKeys()?
Date
Msg-id Pine.BSO.4.64.0712130158490.10148@leary.csoft.net
Whole thread Raw
In response to Re: Synthesize support for Statement.getGeneratedKeys()?  (Ken Johanson <pg-user@kensystem.com>)
List pgsql-jdbc

On Wed, 12 Dec 2007, Ken Johanson wrote:

> Kris, do you what token parsers utils exists in the current JDBC
> package? E.g the most tried and true way to get the schema and table
> name from:
>
> INSERT INTO foo (col1, col2..) VALUES ..

Most of the parsing code in the driver is focused on finding placeholders
and escape sequences and doesn't care what the query is actually doing.
Deriving the base tables of a query happens in only one place, updatable
resultset support.  See
org.postgresql.jdbc2.AbstractJdbc2ResultSet#parseQuery.  That said, the
current implementation is terrible and is fooled by many queries.  It just
looks for the first " FROM " and takes anything after that as the table
the select is based on.  Clearly this doesn't work for SELECT col AS from
FROM tab; or SELECT /* FROM */ * FROM tab; or SELECT (SELECT col FROM tab)
FROM tab2; and many other ways.  So I doubt modelling new code on it is a
good idea.

Kris Jurka

pgsql-jdbc by date:

Previous
From: Ken Johanson
Date:
Subject: Re: Synthesize support for Statement.getGeneratedKeys()?
Next
From: Altaf Malik
Date:
Subject: JDBC causing the connection to close after executing a COPY command