Return-Path: X-Original-To: apmail-db-derby-dev-archive@www.apache.org Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E5210DCDE for ; Wed, 12 Sep 2012 17:14:07 +0000 (UTC) Received: (qmail 15508 invoked by uid 500); 12 Sep 2012 17:14:07 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 15455 invoked by uid 500); 12 Sep 2012 17:14:07 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 15447 invoked by uid 99); 12 Sep 2012 17:14:07 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Sep 2012 17:14:07 +0000 Date: Thu, 13 Sep 2012 04:14:07 +1100 (NCT) From: "Dag H. Wanvik (JIRA)" To: derby-dev@db.apache.org Message-ID: <1337962831.70083.1347470047765.JavaMail.jiratomcat@arcas> In-Reply-To: <1346960935.5633.1346152748045.JavaMail.jiratomcat@arcas> Subject: [jira] [Commented] (DERBY-5911) WHERE condition getting pushed into sub-query with FETCH MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DERBY-5911?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13454134#comment-13454134 ] Dag H. Wanvik commented on DERBY-5911: -------------------------------------- Backported to 10.9 as svn 1384041. > WHERE condition getting pushed into sub-query with FETCH > -------------------------------------------------------- > > Key: DERBY-5911 > URL: https://issues.apache.org/jira/browse/DERBY-5911 > Project: Derby > Issue Type: Bug > Components: SQL > Affects Versions: 10.9.1.0 > Environment: Tested with Derby 10.9.1.0 on Windows 7 x64, Java 1.6.0_27-b07 server > Reporter: Stefan Zeiger > Assignee: Dag H. Wanvik > Fix For: 10.9.1.1, 10.10.0.0 > > Attachments: derby5911a.diff, derby5911a.stat, derby5911b.diff, derby5911b.stat > > > Derby pushes query conditions down into subqueries with FETCH limits, thus creating wrong results. Take the following snippet: > CREATE TABLE COFFEES (COF_NAME VARCHAR(254),PRICE INTEGER); > > INSERT INTO COFFEES (COF_NAME,PRICE) VALUES ('Colombian', 5); > INSERT INTO COFFEES (COF_NAME,PRICE) VALUES ('French_Roast', 5); > INSERT INTO COFFEES (COF_NAME,PRICE) VALUES ('Colombian_Decaf', 20); > > select COF_NAME, PRICE from COFFEES order by COF_NAME fetch next 2 rows only; > > select * from ( > select COF_NAME, PRICE from COFFEES order by COF_NAME fetch next 2 rows only > ) t where t.PRICE < 10; > The first query correctly returns the rows (Colombian,5), (Colombian_Decaf,20). > The second query (which filters the result of the first one) returns (Colombian,5), (French_Roast,5). The row (French_Roast,5) should not be there since it is not a result of the first query. It shows up because (supposedly) the filter condition has been evaluated before the fetch limit. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira