Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 82912 invoked from network); 9 Apr 2010 08:02:31 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 9 Apr 2010 08:02:31 -0000 Received: (qmail 48477 invoked by uid 500); 9 Apr 2010 08:02:31 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 48414 invoked by uid 500); 9 Apr 2010 08:02:29 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 48407 invoked by uid 99); 9 Apr 2010 08:02:29 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Apr 2010 08:02:29 +0000 X-ASF-Spam-Status: No, hits=-2.3 required=10.0 tests=RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [192.18.6.24] (HELO gmp-eb-inf-2.sun.com) (192.18.6.24) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Apr 2010 08:02:19 +0000 Received: from fe-emea-13.sun.com (gmp-eb-lb-1-fe1.eu.sun.com [192.18.6.7] (may be forged)) by gmp-eb-inf-2.sun.com (8.13.7+Sun/8.12.9) with ESMTP id o3981xwc014506 for ; Fri, 9 Apr 2010 08:01:59 GMT MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII Received: from conversion-daemon.fe-emea-13.sun.com by fe-emea-13.sun.com (Sun Java(tm) System Messaging Server 7u2-7.04 64bit (built Jul 2 2009)) id <0L0L00300NM02000@fe-emea-13.sun.com> for derby-user@db.apache.org; Fri, 09 Apr 2010 09:01:38 +0100 (BST) Received: from [192.168.1.232] ([unknown] [89.11.158.128]) by fe-emea-13.sun.com (Sun Java(tm) System Messaging Server 7u2-7.04 64bit (built Jul 2 2009)) with ESMTPSA id <0L0L002V7NMPV340@fe-emea-13.sun.com> for derby-user@db.apache.org; Fri, 09 Apr 2010 09:01:38 +0100 (BST) Date: Fri, 09 Apr 2010 10:02:34 +0200 From: Knut Anders Hatlen Subject: Re: Possible bug with cascade delete and triggers In-reply-to: <1efc5fe73cc3627898fea58058f65180.squirrel@alstongrove.com> Sender: Knut.Hatlen@Sun.COM To: derby-user@db.apache.org Message-id: <4BBEDF1A.9050303@sun.com> References: <1270731606.61985.ezmlm@db.apache.org> <1efc5fe73cc3627898fea58058f65180.squirrel@alstongrove.com> User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.1.9) Gecko/20100318 Lightning/1.0b1 Thunderbird/3.0.4 X-Virus-Checked: Checked by ClamAV on apache.org On 04/ 8/10 03:32 PM, Eric Long wrote: > I think I've encountered a bug, and I'm looking to confirm it is a bug and find any possible > workarounds for it. I am using Apache Derby 10.5.3.0 and Sun JDK 1.6.0_07. The scenario is a > parent and child table with a cascade delete and triggers on both tables. Here are the steps to > reproduce. > > First, compile TestFunctions.java and put it on the classpath: > > public class TestFunctions > { > public static void test(String str) > { > } > } > > Next, enter commands into interactive SQL: > > create table testtable (id integer, name varchar(20), primary key(id)); > > create table testchild ( > id integer > constraint fk_id references testtable on delete cascade, > ordernum int, > primary key(id)); > > create procedure testproc (str varchar(20)) > PARAMETER STYLE JAVA LANGUAGE JAVA EXTERNAL NAME 'TestFunctions.test'; > > create trigger testtabletrigger after delete on testtable referencing old as old > for each row mode db2sql call testproc(char(old.id)); > > create trigger testchildtrigger after delete on testchild referencing old as old > for each row mode db2sql call testproc(char(old.ordernum)); > > insert into testtable values (1, 'test1'); > > insert into testchild values (1, 10); > > delete from testtable where id = 1; > > The expected result is that deleting a row from "testtable" will cascade the delete to > "testchild", and the triggers will be called for each delete. The actual result is that the > delete is rolled back with the following error: > > Error: An attempt was made to put a data value of type 'java.lang.String' into a data value of > type 'INTEGER'. > SQLState: XCL12 > ErrorCode: 30000 > > There are no additional entries in the derby.log after the error. If only one trigger is used, or > if the cascade is removed, then the delete will succeed. Hi Eric, I see this error too when I follow the steps you posted. I agree that it looks like a bug. It would be great if you could file a bug report at https://issues.apache.org/jira/browse/DERBY so that we don't lose track of the issue. Thanks. -- Knut Anders