db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r938959 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java
Date Wed, 28 Apr 2010 12:00:36 GMT
Author: kahatlen
Date: Wed Apr 28 12:00:35 2010
New Revision: 938959

URL: http://svn.apache.org/viewvc?rev=938959&view=rev
Log:
DERBY-4610: Error attempting delete with cascade and triggers

Added a regression test case for the bug. Not enabled yet.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java?rev=938959&r1=938958&r2=938959&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java
Wed Apr 28 12:00:35 2010
@@ -1418,6 +1418,44 @@ public class TriggerTest extends BaseJDB
         s.executeUpdate("DROP TABLE APP.LOG");
         s.executeUpdate("DROP TABLE APP.NAMES");
     }
-    
-    
+
+    /**
+     * Regression test case for DERBY-4610, where a DELETE statement failed
+     * because a trigger used the wrong meta-data and mixed up the data types.
+     *
+     * The test case is disabled for now. When the bug has been fixed, enable
+     * it by removing the leading 'x' in the method name.
+     */
+    public void xtestDerby4610WrongDataType() throws SQLException {
+        Statement s = createStatement();
+        s.execute("create table testtable " +
+                  "(id integer, name varchar(20), primary key(id))");
+        s.execute("create table testchild (" +
+                  "id integer constraint fk_id " +
+                  "references testtable on delete cascade, " +
+                  "ordernum int, primary key(id))");
+        s.execute("create procedure testproc (str varchar(20)) " +
+                  "PARAMETER STYLE JAVA LANGUAGE JAVA EXTERNAL NAME '" +
+                  getClass().getName() + ".derby4610proc'");
+        s.execute("create trigger testtabletrigger after delete on testtable " +
+                  "referencing old as old " +
+                  "for each row mode db2sql call testproc(char(old.id))");
+        s.execute("create trigger testchildtrigger after delete on testchild " +
+                  "referencing old as old " +
+                  "for each row mode db2sql call testproc(char(old.ordernum))");
+        s.execute("insert into testtable values (1, 'test1')");
+        s.execute("insert into testchild values (1, 10)");
+
+        // Used to fail with ERROR XCL12: An attempt was made to put a data
+        // value of type 'java.lang.String' into a data value of type 'INTEGER'.
+        assertUpdateCount(s, 1, "delete from testtable where id = 1");
+    }
+
+    /**
+     * Procedure that does nothing. Called as a stored procedure in the
+     * regression test case for DERBY-4610.
+     */
+    public static void derby4610proc(String str) {
+        // do nothing
+    }
 }



Mime
View raw message