You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2013/08/29 10:01:11 UTC

svn commit: r1518533 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: functionTests/tests/lang/StatementPlanCacheTest.java functionTests/tests/lang/XplainStatisticsTest.java junit/BaseJDBCTestCase.java

Author: kahatlen
Date: Thu Aug 29 08:01:10 2013
New Revision: 1518533

URL: http://svn.apache.org/r1518533
Log:
DERBY-6306: XplainStatisticsTest.testSimpleQuery: BEGIN_COMP_TIME unexpectedly NULL

Clear the statement cache between test cases so that statements from
earlier test cases don't affect the results.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/StatementPlanCacheTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XplainStatisticsTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/StatementPlanCacheTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/StatementPlanCacheTest.java?rev=1518533&r1=1518532&r2=1518533&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/StatementPlanCacheTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/StatementPlanCacheTest.java Thu Aug 29 08:01:10 2013
@@ -110,10 +110,7 @@ public class StatementPlanCacheTest exte
         cacheInPlanPS_TEXT = prepareStatement(
                 "SELECT COUNT(ID) FROM SYSCS_DIAG.STATEMENT_CACHE WHERE " +
                 "SCHEMANAME = ? AND SQL_TEXT = ?");
-        Statement s = createStatement();
-        s.execute("CALL SYSCS_UTIL.SYSCS_EMPTY_STATEMENT_CACHE()");
-        s.close();
-       
+        emptyStatementCache();
     }
     
     protected void tearDown() throws Exception {

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XplainStatisticsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XplainStatisticsTest.java?rev=1518533&r1=1518532&r2=1518533&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XplainStatisticsTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XplainStatisticsTest.java Thu Aug 29 08:01:10 2013
@@ -100,6 +100,18 @@ public class XplainStatisticsTest extend
 	}
         private static long timeSuiteStarted;
 
+    @Override
+    protected void setUp() throws SQLException {
+        // DERBY-6306: Some of the statistics, especially those that give
+        // information about compilation timing, are sensitive to whether
+        // preparing a statement in fact compiles the statement or if it
+        // just fetches it from the statement cache. Empty the statement
+        // cache between each test case, so that they don't need to worry
+        // about statements lying around from earlier test cases affecting
+        // the results.
+        emptyStatementCache();
+    }
+
 	/**
 	 * Creates a variety of tables used by the various tests.
          * The tests use the same basic schema as the 'toursdb' sample

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java?rev=1518533&r1=1518532&r2=1518533&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java Thu Aug 29 08:01:10 2013
@@ -1039,6 +1039,19 @@ public abstract class BaseJDBCTestCase
     }
 
     /**
+     * Clear the contents of the statement cache. Useful if a test case
+     * needs to make sure that a statement is actually compiled and not
+     * just fetched from the statement cache.
+     *
+     * @throws SQLException if a database error happens
+     */
+    protected final void emptyStatementCache() throws SQLException {
+        Statement s = createStatement();
+        s.execute("CALL SYSCS_UTIL.SYSCS_EMPTY_STATEMENT_CACHE()");
+        closeStatement(s);
+    }
+
+    /**
      * Execute a DROP TABLE command using the passed in tableName as-is
      * and the default connection.
      * If the DROP TABLE fails because the table does not exist then