Return-Path: X-Original-To: apmail-db-derby-commits-archive@www.apache.org Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B7C9010385 for ; Tue, 9 Jul 2013 16:20:14 +0000 (UTC) Received: (qmail 98518 invoked by uid 500); 9 Jul 2013 16:20:14 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 98459 invoked by uid 500); 9 Jul 2013 16:20:12 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 98450 invoked by uid 99); 9 Jul 2013 16:20:11 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Jul 2013 16:20:11 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Jul 2013 16:20:08 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 859C623888E2; Tue, 9 Jul 2013 16:19:47 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: derby-commits@db.apache.org From: mamta@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130709161947.859C623888E2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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()