Alvaro Herrera-9 wrote
> Heikki Linnakangas wrote:
>
>> But that's not very bullet-proof, and will fail to detect the statement
>> as an INSERT if it e.g begins with a comment. We could add a mini-parser
>> to detect comments too, but it's not a very robust approach.
>
> It will also fail to work with WITH clauses,
>
> alvherre=# create table r (f int);
> CREATE TABLE
> alvherre=# insert into r values (42), (142857);
> INSERT 0 2
> alvherre=# with t as (select 1) update r set f = f + t."?column?" from t
> returning r.*;
> f
> --------
> 43
> 142858
> (2 filas)
>
> UPDATE 2
Check for insert/update/delete (IUD) at query start (ignoring whitespace) or
immediately following a close parenthesis, and for added measure check for
into/set/from appropriately subsequent to (i.e, need to account for relation
name in the set case)?
Can anchor off of */ for block comment detection and ignoring anything
following a -- should be straight forward.
Nested block comments will be a problem though...does the parser even
effectively allow them?
Given the end result of a bad guess is a parser error getting it 98%
accurate is acceptable. Even if it is somewhat expensive I'm less inclined
to worry about punishing those who blindly set the option. I imagine a
typical IUD statement should be able to quickly match any regex we use so
the typical use case should still be performant.
David J.
--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Problem-with-prepareStatement-and-Statement-RETURN-GENERATED-KEYS-in-PostgreSQL-JDBC-driver-8-4-tp2172722p5807018.html
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.