pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeppe Sommer <jso@trifork.com>
To: pgsql-jdbc@postgresql.org
Subject: Here's a fix to AbstractJdbc3Statement.getGeneratedKeys
Date: Fri, 24 Apr 2009 10:17:42 +0200
Message-ID: <49F175A6.9080401@trifork.com> (raw)

Frustrations over a 4 hour database script with MySQL forced me into 
this :-)

Porting a project from MySQL to PostgreSQL, I discovered that the jdbc3 
facility of returning the generated keys from an insert statement does 
not work. On a fresh cvs checkout, there is partial support, however, 
all fields are returned, not only the field that are autogenerated.

Here is a patch that fixes this. I hope someone will take a look, and 
consider whether it can be adopted into the project. Or improved. It 
works for me :-)

The strategy of the patch is simply to inspect the metadata of the 
returned (initially full) resultset, and then strip out any fields that 
are not marked as autoincrement.

BTW the 4 hour db script finishes after 2m 19s on PostgreSQL.


Best Regards,
Jeppe





view thread (8+ messages)  latest in thread

Message-ID: <49F175A6.9080401@trifork.com>
Permalink:  ../49F175A6.9080401@trifork.com/
Also on:    postgresql.org/message-id/49F175A6.9080401@trifork.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: jso@trifork.com
  Subject: Re: Here's a fix to AbstractJdbc3Statement.getGeneratedKeys
  In-Reply-To: <49F175A6.9080401@trifork.com>
  References: <49F175A6.9080401@trifork.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