Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wv6Le-0001m4-2Z for pgsql-jdbc@arkaria.postgresql.org; Thu, 12 Jun 2014 14:51:26 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Wv6Ld-0007pv-Es for pgsql-jdbc@arkaria.postgresql.org; Thu, 12 Jun 2014 14:51:25 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Wv6Lb-0007n3-Uj for pgsql-jdbc@postgresql.org; Thu, 12 Jun 2014 14:51:24 +0000 Received: from sam.nabble.com ([216.139.236.26]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1Wv6LU-0000nh-7w for pgsql-jdbc@postgresql.org; Thu, 12 Jun 2014 14:51:22 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1Wv6LS-0002kq-Ot for pgsql-jdbc@postgresql.org; Thu, 12 Jun 2014 07:51:14 -0700 Date: Thu, 12 Jun 2014 07:51:14 -0700 (PDT) From: David G Johnston To: pgsql-jdbc@postgresql.org Message-ID: <1402584674602-5807018.post@n5.nabble.com> 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> Subject: Re: Problem with prepareStatement and Statement.RETURN_GENERATED_KEYS in PostgreSQL JDBC driver 8.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: 0.8 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org 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. -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc