Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id C6E3C634B29 for ; Fri, 24 Apr 2009 05:24:17 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 01479-07-2 for ; Fri, 24 Apr 2009 05:24:08 -0300 (ADT) X-Greylist: delayed 00:05:31.774313 by SQLgrey-1.7.6 Received: from MAIL91.interprise.dk (mail.interprise.dk [77.66.16.98]) by mail.postgresql.org (Postfix) with ESMTP id 05247635199 for ; Fri, 24 Apr 2009 05:23:59 -0300 (ADT) Received: from itcmail01.interprise.dk (172.22.110.33) by MAIL91.interprise.dk (172.22.200.10) with Microsoft SMTP Server (TLS) id 8.1.358.0; Fri, 24 Apr 2009 10:16:53 +0200 Received: from [172.30.121.236] (195.184.117.154) by SMTP.Trifork.com (172.22.110.33) with Microsoft SMTP Server (TLS) id 8.1.336.0; Fri, 24 Apr 2009 10:17:53 +0200 Message-ID: <49F175A6.9080401@trifork.com> Date: Fri, 24 Apr 2009 10:17:42 +0200 From: Jeppe Sommer User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 To: Subject: Here's a fix to AbstractJdbc3Statement.getGeneratedKeys Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200904/82 X-Sequence-Number: 19529 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