Return-Path: X-Original-To: apmail-db-derby-dev-archive@www.apache.org Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4DD6A1890D for ; Fri, 1 Jan 2016 18:52:40 +0000 (UTC) Received: (qmail 56996 invoked by uid 500); 1 Jan 2016 18:52:40 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 56919 invoked by uid 500); 1 Jan 2016 18:52:40 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 56909 invoked by uid 99); 1 Jan 2016 18:52:40 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Jan 2016 18:52:40 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id D3A2F2C14F9 for ; Fri, 1 Jan 2016 18:52:39 +0000 (UTC) Date: Fri, 1 Jan 2016 18:52:39 +0000 (UTC) From: "Bryan Pendleton (JIRA)" To: derby-dev@db.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (DERBY-6849) Statement.RETURN_GENERATED_KEYS returns "keys" even if there are no auto-generated fields MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DERBY-6849?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Bryan Pendleton updated DERBY-6849: ----------------------------------- Attachment: DERBY6849Repro.java I looked briefly at this job. The description is clear, but the code snippets are incomplete and aren't a working program by themselves. I didn't spend a lot of time on this, but I tried to take the code snippets from the distribution and turn them into a standalone test case, and failed. Attached is DERBY6849Repro.java, which, against both 10.9 and trunk, prints getGeneratedKeys returned null One thing I did that may be very significant is to use a simple VARCHAR type for the 'image' column, rather than using BLOB. John, perhaps you could have a look at my attached program and tell us whether: a) This program works differently for you than it did for me b) You can alter my trivial program to produce a standalone testcase that demonstrates the problem you're seeing with your application? thanks, bryan > Statement.RETURN_GENERATED_KEYS returns "keys" even if there are no auto-generated fields > ----------------------------------------------------------------------------------------- > > Key: DERBY-6849 > URL: https://issues.apache.org/jira/browse/DERBY-6849 > Project: Derby > Issue Type: Bug > Components: JDBC > Affects Versions: 10.9.1.0 > Reporter: John Hendrikx > Attachments: DERBY6849Repro.java > > > I have a very simple table: > {noformat} > CREATE TABLE images ( > url varchar(1000) NOT NULL, > image blob NOT NULL, > > CONSTRAINT images_url PRIMARY KEY (url) > ); > {noformat} > No auto-generated fields. However when I do an insert, JDBC tells me there are auto-generated keys (rs.next() does not return false and a LONG value is returned): > {noformat} > try(PreparedStatement statement = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) { > setParameters(parameterValues, statement); > statement.execute(); > try(ResultSet rs = statement.getGeneratedKeys()) { > if(rs.next()) { > return rs.getObject(1); > } > return null; > } > } > catch(SQLException e) { > throw new DatabaseException(this, sql + ": " + parameters, e); > } > {noformat} > This sounds like a bug to me. For comparison, PostgreSQL does not have the same behaviour. -- This message was sent by Atlassian JIRA (v6.3.4#6332)