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 2E4CE10A1C for ; Mon, 2 Jun 2014 22:45:03 +0000 (UTC) Received: (qmail 91115 invoked by uid 500); 2 Jun 2014 22:45:03 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 91081 invoked by uid 500); 2 Jun 2014 22:45:02 -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 91073 invoked by uid 99); 2 Jun 2014 22:45:02 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Jun 2014 22:45:02 +0000 Date: Mon, 2 Jun 2014 22:45:02 +0000 (UTC) From: "Dag H. Wanvik (JIRA)" To: derby-dev@db.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (DERBY-6559) A immediate Fk constraint blows up iff its referenced PK is deferred and we delete a duplicate 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-6559?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14015992#comment-14015992 ] Dag H. Wanvik edited comment on DERBY-6559 at 6/2/14 10:43 PM: --------------------------------------------------------------- But see [limitation on FK with deferrable pK here|https://issues.apache.org/jira/browse/DERBY-6576?focusedCommentId=14015985&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14015985] was (Author: dagw): But see [limitation on FK with deferrable pK here|https://issues.apache.org/jira/secure/EditComment!default.jspa?id=12713983&commentId=14015985] > A immediate Fk constraint blows up iff its referenced PK is deferred and we delete a duplicate > ---------------------------------------------------------------------------------------------- > > Key: DERBY-6559 > URL: https://issues.apache.org/jira/browse/DERBY-6559 > Project: Derby > Issue Type: Bug > Components: SQL > Reporter: Dag H. Wanvik > Assignee: Dag H. Wanvik > Fix For: 10.11.0.0 > > Attachments: derby-6559.diff, derby-6559.status > > > Cf the following test case: > {code:title=testFKPlusUnique|borderStyle=solid} > /** > * The referenced constraint (in the referenced table) is also a deferred > * (unique/ok) constraint. > * > * @throws SQLException > */ > public void testFKPlusUnique() throws SQLException { > Statement s = createStatement( > ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE); > > try { > s.executeUpdate( > "create table ref_t(i int, " + > " constraint ct primary key(i) deferrable initially deferred)"); > s.executeUpdate( > "create table t(i int unique not null, " + > " constraint c foreign key (i) references ref_t(i) " + > " deferrable initially immediate)"); > > s.executeUpdate("insert into ref_t values 1,1"); > s.executeUpdate("insert into t values 1"); > > // Now, the child (referencing table) is referencing one of the the > // rows whose value is 1, so the reference is potentially suspect. > > // What happens when we delete the one copy before commit? > ResultSet rs = s.executeQuery("select * from ref_t"); > rs.next(); > > // Will this delete blow up? Hopefully not, here is another row > // that would satisfy the constraint. > rs.deleteRow(); > > // Now there should be only one left, so the referenced table is > // OK. > commit(); > : > {code} > Now, the constraint C throws when we do the "rs.deleteRow" above. But since there is (still) a row satisfying the FK, albeit a duplicate, I believe it should not. -- This message was sent by Atlassian JIRA (v6.2#6252)