Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 33147 invoked from network); 2 Jun 2010 07:26:02 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 2 Jun 2010 07:26:02 -0000 Received: (qmail 15707 invoked by uid 500); 2 Jun 2010 07:26:02 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 15602 invoked by uid 500); 2 Jun 2010 07:26: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 15595 invoked by uid 99); 2 Jun 2010 07:26:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Jun 2010 07:26:01 +0000 X-ASF-Spam-Status: No, hits=-1488.5 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Jun 2010 07:26:01 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o527Pfpi000371 for ; Wed, 2 Jun 2010 07:25:41 GMT Message-ID: <29097794.125991275463541006.JavaMail.jira@thor> Date: Wed, 2 Jun 2010 03:25:41 -0400 (EDT) From: "Kristian Waagan (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Assigned: (DERBY-338) Move checks for referential constraints from DDL execution time to DML execution time In-Reply-To: <1132347856.1118012139925.JavaMail.jira@ajax.apache.org> 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-338?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Kristian Waagan reassigned DERBY-338: ------------------------------------- Assignee: (was: Kristian Waagan) Assigned and unassigned to clear in-progress state. > Move checks for referential constraints from DDL execution time to DML execution time > ------------------------------------------------------------------------------------- > > Key: DERBY-338 > URL: https://issues.apache.org/jira/browse/DERBY-338 > Project: Derby > Issue Type: Improvement > Components: SQL > Affects Versions: 10.0.2.0, 10.0.2.1, 10.0.2.2, 10.1.1.0 > Reporter: Andrew McIntyre > Attachments: refConstraint2005-06-07.diff, refConstraint2005-06-08.diff > > > Description for this bug from Jack Klebanoff: > The attached patch fixes a problem that Derby had with conflicting referential constraints. Consider the following DDL: > create table t2( ref1 int references t1(id) on delete cascade, > ref2 int references t1(id) on delete set null) > If both the ref1 and ref2 columns of the same t2 row refer to the same t1 row and that t1 row is deleted then the two referential constraint actions conflict. One says that the t2 row should be deleted, the other says that the ref2 column should be set to null. According to the SQL2003 spec an exception should be thrown when the t1 row is deleted. That is what Derby does after the attached patch is applied. > Without the patch Derby disallows the DDL statement that creates a constraint whose action may conflict with other constraint actions. This is a mistake. Derby cannot tell at DDL time whether there will actually be a conflict. Derby rejects the DDL statement in the example above. However if none of the t2 rows refer to the same t1 row then there is no conflict. Derby rejects some DDL that will work perfectly well. As, I said above this is contrary to the SQL standard which requires that the checks be made at DML execution time not at DDL execution time. > The patch changes iapi/sql/dictionary/DDUtils.java to remove the DDL time checks and changes impl/sql/execute/DeleteCascadeResultSet.java, DMLWriteResultSet.java, and UpdateResultSet.java to add the DML execution time checks. The execution time checks are implemented by building a hash table of all the rows that are changed as the result of referential constraint actions. An exception is thrown if any row is entered into the hash table twice with different actions. The hash table is implemented with BackingStoreHashtable in case it is too large to fit into memory. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.