db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r763900 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/execute/ testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Fri, 10 Apr 2009 09:59:39 GMT
Author: kahatlen
Date: Fri Apr 10 09:59:39 2009
New Revision: 763900

URL: http://svn.apache.org/viewvc?rev=763900&view=rev
Log:
DERBY-2353: intermittent NPEs during DELETE ops in a reasonably large transaction

When derby.language.logQueryPlan is true, don't try to print the query
plan if the activation has been closed.

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ReferentialActionsTest.java
  (with props)
Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java?rev=763900&r1=763899&r2=763900&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java
Fri Apr 10 09:59:39 2009
@@ -351,9 +351,16 @@
 			** is on, then the run time statistics from the autocommit is the
 			** only one that the user would ever see.  So, we don't overwrite
 			** the run time statistics object for a commit.
+            ** DERBY-2353: Also make an exception when the activation is
+            ** closed. If the activation is closed, the run time statistics
+            ** object is null and there's nothing to print. This may happen
+            ** if a top-level result set closes the activation and close() is
+            ** subsequently called on the child result sets. The information
+            ** about the children is also printed by the parent, so it's safe
+            ** to skip printing it.
 			*/
 			if (lcc.getRunTimeStatisticsMode() &&
-				! doesCommit())
+				!doesCommit() && !activation.isClosed())
 			{
 				endExecutionTime = getCurrentTimeMillis();
 

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ReferentialActionsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ReferentialActionsTest.java?rev=763900&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ReferentialActionsTest.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ReferentialActionsTest.java
Fri Apr 10 09:59:39 2009
@@ -0,0 +1,66 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.functionTests.tests.lang.ReferentialActionsTest
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to you under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derbyTesting.functionTests.tests.lang;
+
+import java.sql.SQLException;
+import java.sql.Statement;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.DatabasePropertyTestSetup;
+
+/**
+ * This class tests SQL referential actions.
+ */
+public class ReferentialActionsTest extends BaseJDBCTestCase {
+
+    public ReferentialActionsTest(String name) {
+        super(name);
+    }
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite("ReferentialActionsTest");
+
+        // DERBY-2353: Need to set derby.language.logQueryPlan to expose the
+        // bug (got a NullPointerException when writing the plan to derby.log)
+        suite.addTest(DatabasePropertyTestSetup.singleProperty(
+                new ReferentialActionsTest("onDeleteCascadeWithLogQueryPlan"),
+                "derby.language.logQueryPlan", "true", true));
+
+        return suite;
+    }
+
+    /**
+     * Test that cascading delete works when derby.language.logQueryPlan is
+     * set to true - DERBY-2353.
+     */
+    public void onDeleteCascadeWithLogQueryPlan() throws SQLException {
+        setAutoCommit(false);
+        Statement s = createStatement();
+        s.execute("create table a (a1 int primary key)");
+        s.execute("insert into a values 1");
+        s.execute("create table b (b1 int references a on delete cascade)");
+        s.execute("insert into b values 1");
+        // The next line used to cause a NullPointerException
+        s.execute("delete from a");
+    }
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ReferentialActionsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java?rev=763900&r1=763899&r2=763900&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
Fri Apr 10 09:59:39 2009
@@ -70,6 +70,7 @@
 		suite.addTest(LangScripts.suite());
         suite.addTest(MathTrigFunctionsTest.suite());
         suite.addTest(PrepareExecuteDDL.suite());
+        suite.addTest(ReferentialActionsTest.suite());
         suite.addTest(RolesTest.suite());
         suite.addTest(RolesConferredPrivilegesTest.suite());
         suite.addTest(SQLSessionContextTest.suite());



Mime
View raw message