db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1542220 - in /db/derby/code/branches/10.10: ./ java/engine/org/apache/derby/impl/sql/execute/GenericTriggerExecutor.java java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java
Date Fri, 15 Nov 2013 10:43:19 GMT
Author: kahatlen
Date: Fri Nov 15 10:43:19 2013
New Revision: 1542220

URL: http://svn.apache.org/r1542220
Log:
DERBY-6348: NPE or assert failure in recursive trigger

Merged revision 1537393 from trunk.

Modified:
    db/derby/code/branches/10.10/   (props changed)
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/GenericTriggerExecutor.java
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java

Propchange: db/derby/code/branches/10.10/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1537393

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/GenericTriggerExecutor.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/GenericTriggerExecutor.java?rev=1542220&r1=1542219&r2=1542220&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/GenericTriggerExecutor.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/GenericTriggerExecutor.java
Fri Nov 15 10:43:19 2013
@@ -134,6 +134,12 @@ public abstract class GenericTriggerExec
 			*/
 			if (ps == null || recompile)
 			{
+                // The SPS activation will set its parent activation from
+                // the statement context. Reset it to the original parent
+                // activation first so that it doesn't use the activation of
+                // the previously executed SPS as parent. DERBY-6348.
+                lcc.getStatementContext().setActivation(activation);
+
 				/*
 				** We need to clone the prepared statement so we don't
 				** wind up marking that ps that is tied to sps as finished

Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java?rev=1542220&r1=1542219&r2=1542220&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java
(original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java
Fri Nov 15 10:43:19 2013
@@ -2017,4 +2017,34 @@ public class TriggerTest extends BaseJDB
                 + "(select count(*) from sysibm.sysdummy1)");
 
     }
+
+    public void testDerby6348() throws SQLException {
+        setAutoCommit(false);
+        Statement s = createStatement();
+        s.execute("create table d6348(x int)");
+        s.execute("insert into d6348 values 1");
+        s.execute("create trigger d6348_tr1 after update on d6348 values 1");
+        s.execute("create trigger d6348_tr2 after update on d6348 "
+                + "for each row update d6348 set x = x + 1 where x < 3");
+
+        // Used to fail with assert failure or NullPointerException before
+        // DERBY-6348.
+        s.execute("update d6348 set x = x + 1");
+
+        JDBC.assertSingleValueResultSet(
+                s.executeQuery("select * from d6348"),
+                "3");
+
+        rollback();
+
+        s.execute("create table d6348(x int)");
+        s.execute("create trigger d6348_tr1 after insert on d6348 "
+                + "values current_user");
+        s.execute("create trigger d6348_tr2 after insert on d6348 "
+                + "values current_user");
+
+        // Used to fail with assert failure or NullPointerException before
+        // DERBY-6348.
+        s.execute("insert into d6348 values 1");
+    }
 }



Mime
View raw message