db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1501365 - in /db/derby/code/branches/10.9: ./ java/engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java java/testing/org/apache/derbyTesting/functionTests/tests/lang/XplainStatisticsTest.java
Date Tue, 09 Jul 2013 16:19:47 GMT
Author: mamta
Date: Tue Jul  9 16:19:47 2013
New Revision: 1501365

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


Backporting revision 1495943 from trunk to 10.9.


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

Propchange: db/derby/code/branches/10.9/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1495943

Modified: db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java?rev=1501365&r1=1501364&r2=1501365&view=diff
==============================================================================
--- db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java
(original)
+++ db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java
Tue Jul  9 16:19:47 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/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XplainStatisticsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XplainStatisticsTest.java?rev=1501365&r1=1501364&r2=1501365&view=diff
==============================================================================
--- db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XplainStatisticsTest.java
(original)
+++ db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XplainStatisticsTest.java
Tue Jul  9 16:19:47 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()



Mime
View raw message