db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1518111 - in /db/derby/code/trunk/java: testing/org/apache/derbyTesting/functionTests/tests/lang/XplainStatisticsTest.java tools/org/apache/derby/impl/tools/planexporter/AccessDatabase.java
Date Wed, 28 Aug 2013 08:57:40 GMT
Author: kahatlen
Date: Wed Aug 28 08:57:40 2013
New Revision: 1518111

URL: http://svn.apache.org/r1518111
Log:
DERBY-6297: Intermittent failures in XplainStatisticsTest.testSimpleXplainOnly

Make AccessDatabase.schemaExists() close the ResultSet.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XplainStatisticsTest.java
    db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/AccessDatabase.java

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=1518111&r1=1518110&r2=1518111&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
Wed Aug 28 08:57:40 2013
@@ -1092,7 +1092,6 @@ public class XplainStatisticsTest extend
     public void testSimpleXplainOnly() throws Exception
     {
         Statement s = createStatement();
-        ResultSet rs;
 
         enableXplainStyle(s);
         enableXplainOnlyMode(s);
@@ -1220,7 +1219,6 @@ public class XplainStatisticsTest extend
     public void testXplainOnlyExecutePrepared() throws Exception
     {
         Statement s = createStatement();
-        ResultSet rs;
 
         String selectStatement = 
             "select region, count(country) from app.countries group by region";
@@ -1294,12 +1292,16 @@ public class XplainStatisticsTest extend
         JDBC.assertEmpty(ps.executeQuery());
         clearXplainOnlyMode(s);
         disableXplainStyle(s);
+
+        // Verify that statistics were collected.
+        JDBC.assertDrainResults(
+                s.executeQuery("select * from xpltest.sysxplain_statements"),
+                1);
     }
     
     public void testXplainOnlyPrepared() throws Exception
     {
         Statement s = createStatement();
-        ResultSet rs;
 
         String selectStatement = 
             "select region, count(country) from app.countries group by region";

Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/AccessDatabase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/AccessDatabase.java?rev=1518111&r1=1518110&r2=1518111&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/AccessDatabase.java
(original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/AccessDatabase.java
Wed Aug 28 08:57:40 2013
@@ -146,15 +146,20 @@ public class AccessDatabase {
      * name that was passed in to this instance.
      */
     private boolean schemaExists() throws SQLException {
-    	boolean found=false;
     	ResultSet result = conn.getMetaData().getSchemas();
-    	while(result.next()){
-    		if(result.getString(1).equals(schema)){
-    			found=true;
-    			break;
-    		}
-    	}	
-    	return found;
+        try {
+            while (result.next()) {
+                if (result.getString(1).equals(schema)) {
+                    // Found it!
+                    return true;
+                }
+            }
+        } finally {
+            result.close();
+        }
+
+        // Didn't find the schema.
+        return false;
     }
 
     public boolean verifySchemaExistance() {



Mime
View raw message