Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 12941200AF5 for ; Thu, 2 Jun 2016 16:12:01 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 0DA9C160A51; Thu, 2 Jun 2016 14:12:01 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 568A816098A for ; Thu, 2 Jun 2016 16:12:00 +0200 (CEST) Received: (qmail 32982 invoked by uid 500); 2 Jun 2016 14:11:59 -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 32961 invoked by uid 99); 2 Jun 2016 14:11:59 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Jun 2016 14:11:59 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 3F77B2C1F61 for ; Thu, 2 Jun 2016 14:11:59 +0000 (UTC) Date: Thu, 2 Jun 2016 14:11:59 +0000 (UTC) From: "Bryan Pendleton (JIRA)" To: derby-dev@db.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (DERBY-6550) Bulk-insert causes identity columns to cycle when they shouldn't MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 02 Jun 2016 14:12:01 -0000 [ https://issues.apache.org/jira/browse/DERBY-6550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15312360#comment-15312360 ] Bryan Pendleton commented on DERBY-6550: ---------------------------------------- Another idea is to try the reproduction script against Derby 10.10, 10.11, and 10.12, to see if the bug reproduces in an older version. I think 10.10 was the active version at the time this job was logged. You can find the older release jars in the "lib" or "lib-debug" downloads from http://db.apache.org/derby/derby_downloads.html > Bulk-insert causes identity columns to cycle when they shouldn't > ---------------------------------------------------------------- > > Key: DERBY-6550 > URL: https://issues.apache.org/jira/browse/DERBY-6550 > Project: Derby > Issue Type: Bug > Components: SQL > Affects Versions: 10.11.1.1 > Reporter: Rick Hillegas > Attachments: screenshot-1.png > > > According to the SQL Standard, an identity column is conceptually backed by a sequence generator. If you don't specify a cycle option (and for Derby's identity column, you can't), then the identity column is supposed to NOT cycle. This is described by the following sections of the 2011 edition of the SQL Standard: > o Section 11.4 (column definition), syntax rule 16 > o Section 9.26 (Creation of a sequence generator), syntax rule 13 > If you aren't doing a bulk-insert, then Derby honors this contract. However, due to an optimization in InsertResultSet, this contract is not honored for bigint identity columns. Bulk-insert causes Derby to cycle past the biggest positive long value and to begin generating negative longs. > The following script shows this behavior: > {noformat} > connect 'jdbc:derby:memory:db;create=true'; > create table t > ( > a bigint generated always as identity ( start with 9223372036854775806 ), > b int > ); > create function integerList() returns table > ( > a int, > b int, > c int, > d int > ) > language java parameter style derby_jdbc_result_set no sql > external name 'org.apache.derbyTesting.functionTests.tests.lang.MergeStatementTest.integerList_023'; > -- this fails because bulk-insert isn't used and we go past the end of the identity column's range > insert into t( b ) values ( 1 ), ( 2 ), ( 3 ), ( 4 ), ( 5 ); > -- inserting into an empty table from a table function uses bulk-insert > -- > -- this should fail just like the previous statement, but it succeeds > insert into t( b ) select b from table( integerList() ) il; > select * from t; > {noformat} -- This message was sent by Atlassian JIRA (v6.3.4#6332)