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 ADBA610D54 for ; Wed, 16 Jul 2014 20:41:05 +0000 (UTC) Received: (qmail 28786 invoked by uid 500); 16 Jul 2014 20:41:05 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 28758 invoked by uid 500); 16 Jul 2014 20:41:05 -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 28741 invoked by uid 99); 16 Jul 2014 20:41:05 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Jul 2014 20:41:05 +0000 Date: Wed, 16 Jul 2014 20:41:05 +0000 (UTC) From: "Rick Hillegas (JIRA)" To: derby-dev@db.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (DERBY-6668) Truncating a table may silently violate a deferred foreign key. 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-6668?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14064052#comment-14064052 ] Rick Hillegas commented on DERBY-6668: -------------------------------------- I would support the meat-ax approach of forbidding TRUNCATE on referenced tables, per the Standard. We would need a release note to flag the backward incompatibility. > Truncating a table may silently violate a deferred foreign key. > --------------------------------------------------------------- > > Key: DERBY-6668 > URL: https://issues.apache.org/jira/browse/DERBY-6668 > Project: Derby > Issue Type: Bug > Components: SQL > Affects Versions: 10.11.0.0 > Reporter: Rick Hillegas > > If you truncate a table which is referenced by a deferred foreign key, orphaned tuples are left in the foreign table. That is, the foreign key is violated but no exception is raised. > Since table truncation involves changing conglomerate ids, this may be another case of derby-6665. Or this may be a new bug. > The following script shows this behavior: > {noformat} > connect 'jdbc:derby:memory:db;create=true'; > create table tunique > ( > a int not null unique > ); > create table tref > ( > a int references tunique( a ) initially deferred > ); > insert into tunique values ( 1 ); > insert into tref values ( 1 ); > truncate table tunique; > -- the unique table is empty > select * from tunique; > -- but the table which references it has a row > select * from tref; > {noformat} -- This message was sent by Atlassian JIRA (v6.2#6252)