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 5F3CA11EF1 for ; Fri, 18 Jul 2014 20:04:06 +0000 (UTC) Received: (qmail 11968 invoked by uid 500); 18 Jul 2014 20:04:06 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 11941 invoked by uid 500); 18 Jul 2014 20:04:06 -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 11916 invoked by uid 99); 18 Jul 2014 20:04:06 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Jul 2014 20:04:06 +0000 Date: Fri, 18 Jul 2014 20:04:05 +0000 (UTC) From: "Rick Hillegas (JIRA)" To: derby-dev@db.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (DERBY-6670) Rollback to savepoint allows violation of deferrable constraints 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-6670?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14066805#comment-14066805 ] Rick Hillegas commented on DERBY-6670: -------------------------------------- Some relief may be provided by the fix for DERBY-6665. That should eliminate some of the code paths which clear the memory of deferred violations. Right now, the memory is cleared when conglomerate ids change, but by using the logical constraint ids, there should be no need to clear the memory. > Rollback to savepoint allows violation of deferrable constraints > ---------------------------------------------------------------- > > Key: DERBY-6670 > URL: https://issues.apache.org/jira/browse/DERBY-6670 > Project: Derby > Issue Type: Bug > Components: SQL > Affects Versions: 10.11.0.0 > Reporter: Knut Anders Hatlen > Attachments: derby-6670-01-aa-forbidSavepointsWithDeferredConstraints.diff > > > The bug is illustrated by the following code snippet: > {code} > Connection c = DriverManager.getConnection("jdbc:derby:memory:db;create=true"); > c.setAutoCommit(false); > Statement s = c.createStatement(); > s.execute("create table t1(x int primary key initially deferred)"); > s.execute("insert into t1 values 1,1,1,1"); > Savepoint sp = c.setSavepoint(); > s.execute("drop table t1"); > c.rollback(sp); > // Since there are four identical rows in T1, this call should have > // failed because the primary key was violated. > c.commit(); > // Instead, it succeeds, and all four rows are committed, as can > // be seen here: > ResultSet rs = s.executeQuery("select * from t1"); > while (rs.next()) { > System.out.println(rs.getInt(1)); > } > // Insert yet another row, so that we have five identical rows ... > s.execute("insert into t1 values 1"); > // ... and now commit complains ... > c.commit(); > {code} > With auto-commit off, add duplicates into a deferred primary key. Then set a savepoint, drop the table, and roll back to the savepoint. > Apparently, when you drop the table, information about any constraint violations seen on that table is lost, and that information is not restored when the drop table operation is undone by the rollback to savepoint. > So when you commit the transaction after having rolled back the drop operation, no deferred checking of constraints happens, and the duplicates you have inserted are committed. -- This message was sent by Atlassian JIRA (v6.2#6252)