pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David G Johnston <david.g.johnston@gmail.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: Problem with prepareStatement and Statement.RETURN_GENERATED_KEYS in PostgreSQL JDBC driver 8.4
Date: Thu, 12 Jun 2014 07:51:14 -0700 (PDT)
Message-ID: <1402584674602-5807018.post@n5.nabble.com> (raw)
In-Reply-To: <20140612142231.GA27193@eldon.alvh.no-ip.org>
References: <4BD196B4.3040607@smilehouse.com>
	<4BD1C357.90506@enterprisedb.com>
	<20140612142231.GA27193@eldon.alvh.no-ip.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>

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...
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.


-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



view thread (4+ messages)

Message-ID: <1402584674602-5807018.post@n5.nabble.com>
Permalink:  ../1402584674602-5807018.post@n5.nabble.com/
Also on:    postgresql.org/message-id/1402584674602-5807018.post@n5.nabble.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: david.g.johnston@gmail.com
  Subject: Re: Problem with prepareStatement and Statement.RETURN_GENERATED_KEYS in PostgreSQL JDBC driver 8.4
  In-Reply-To: <1402584674602-5807018.post@n5.nabble.com>
  References: <4BD196B4.3040607@smilehouse.com> <4BD1C357.90506@enterprisedb.com> <20140612142231.GA27193@eldon.alvh.no-ip.org> <1402584674602-5807018.post@n5.nabble.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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