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/06/24 10:07:56 UTC

svn commit: r1495943 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java testing/org/apache/derbyTesting/functionTests/tests/lang/XplainStatisticsTest.java

Author: kahatlen
Date: Mon Jun 24 08:07:56 2013
New Revision: 1495943

URL: http://svn.apache.org/r1495943
Log:
DERBY-6268: Run-time statistics not collected if query contains always false predicate

Make ProjectRestrictResultSet.close() call super.close() so that the
logic for dumping run-time statistics gets executed.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XplainStatisticsTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java?rev=1495943&r1=1495942&r2=1495943&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java Mon Jun 24 08:07:56 2013
@@ -356,9 +356,9 @@ class ProjectRestrictResultSet extends N
 		/* Nothing to do if open was short circuited by false constant expression */
 		if (shortCircuitOpen)
 		{
-			isOpen = false;
 			shortCircuitOpen = false;
 			source.close();
+            super.close();
 			return;
 		}
 

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=1495943&r1=1495942&r2=1495943&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 Mon Jun 24 08:07:56 2013
@@ -2498,6 +2498,27 @@ public class XplainStatisticsTest extend
     }
 
     /**
+     * Test that run-time statistics are recorded even if the query has a
+     * predicate that always evaluates to false. Before DERBY-6268, the logic
+     * that saved the statistics would be short-circuited in such queries.
+     */
+    public void testAlwaysEmptyResultSet() throws Exception {
+        // Execute a query with a predicate that is known at compile time to
+        // evaluate to false. The predicate FALSE should do.
+        String sql = "select * from sysibm.sysdummy1 where false -- DERBY-6268";
+        Statement s = createStatement();
+        enableXplainStyle(s);
+        JDBC.assertEmpty(s.executeQuery(sql));
+        disableXplainStyle(s);
+
+        // Now, see if we find the query among the recorded statements.
+        PreparedStatement ps = prepareStatement(
+            "select * from xpltest.sysxplain_statements where stmt_text = ?");
+        ps.setString(1, sql);
+        JDBC.assertDrainResults(ps.executeQuery(), 1);
+    }
+
+    /**
       * A simple test of table with the wrong 'shape'.
       */
     public void testTableNotValid()