Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 39065 invoked from network); 16 Apr 2008 01:27:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Apr 2008 01:27:35 -0000 Received: (qmail 75067 invoked by uid 500); 16 Apr 2008 01:27:36 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 75036 invoked by uid 500); 16 Apr 2008 01:27:36 -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 75027 invoked by uid 99); 16 Apr 2008 01:27:35 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Apr 2008 18:27:35 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Apr 2008 01:26:51 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 7F37E234C0D3 for ; Tue, 15 Apr 2008 18:24:28 -0700 (PDT) Message-ID: <1367618730.1208309068519.JavaMail.jira@brutus> Date: Tue, 15 Apr 2008 18:24:28 -0700 (PDT) From: "Bryan Pendleton (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Updated: (DERBY-3603) 'IN' clause ignores valid results, incorrect qualifier handling suspected In-Reply-To: <1214723879.1207620925545.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/DERBY-3603?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Bryan Pendleton updated DERBY-3603: ----------------------------------- Attachment: updateSubqueryMaster.diff Thanks Army for the clear and detailed description of the subquery processing. To confirm it, I introduced some crude print statements into the MultiProbe code and: - without the patch I can see it ping-ponging back and forth between -2 and 1 - with the patch I can see that it simply uses the -2 row over and over, as you suggest. Based on that evidence, and on a close read of Army's description, I'm comfortable updating the subqueryFlattening.out file. Attached is updateSubquerymaster.diff, which I believe is ready for review. I intend to commit this patch to the trunk tonight or tomorrow morning, and I'm also intending to merge it to 10.4, assuming no additional concerns are raised via review or testing. > 'IN' clause ignores valid results, incorrect qualifier handling suspected > ------------------------------------------------------------------------- > > Key: DERBY-3603 > URL: https://issues.apache.org/jira/browse/DERBY-3603 > Project: Derby > Issue Type: Bug > Components: SQL > Affects Versions: 10.3.2.1, 10.4.1.1 > Reporter: David Butterworth > Assignee: Bryan Pendleton > Attachments: d3603_v1.patch, d3603_with_test.diff, derbydb.jar, derbydb.tar.bz2, subqueryFlattening.diff, updateSubqueryMaster.diff > > > Derbys' 'IN' clause is returning different results depending on which side of a joined table > I am doing my 'IN' comparison against. This only occurs when the number of items within the 'IN' clause is greater then 1. > This behaviour was also confirmed by Bryan Pendleton in this thread: > http://mail-archives.apache.org/mod_mbox/db-derby-user/200804.mbox/%3c47FA5974.2060705@amberpoint.com%3e > Using the test database attatched the following 2 queries produce the issue: > ij> select count(*) FROM spike.accounts account, spike.admin_units admin_unit, > spike.bookings booking > WHERE booking.child_id = 2 AND > admin_unit.admin_unit_id IN (1,21) AND > booking.booking_date_time_out >= 20080331000000 AND > booking.booking_date_time_in <= 20080406235900 AND > account.account_id = booking.account_id AND > admin_unit.admin_unit_id = account.admin_unit_id; > 1 > ----------- > 2 > 1 row selected > ij> select count(*) FROM spike.accounts account, spike.admin_units admin_unit, > spike.bookings booking > WHERE booking.child_id = 2 AND > account.admin_unit_id IN (1,21) AND > booking.booking_date_time_out >= 20080331000000 AND > booking.booking_date_time_in <= 20080406235900 AND > account.account_id = booking.account_id AND > admin_unit.admin_unit_id = account.admin_unit_id; > 1 > ----------- > 3 > 1 row selected > ij> > The only difference between the 2 statements is which side of a join the 'IN' clause is matched against. > Bryan performed some initial testing and stated the following: > --------------------- SNIP ------------------------ > Interestingly, although the actual results do NOT contain any values > for admin_unit_id = 21, if I change the query to: > admin_unit.admin_unit_id IN (1) > or > account.admin_unit_id IN (1) > then the problem disappears -- I get 3 rows for both queries. > I also ran query plans for both the queries (in the IN (1,21) case) > and have pasted the (simplified) query plans at the end of this message. > I notice that in the case where the query gives 2 rows, which is > when we specify admin_unit.admin_unit_id in (1,21), the admin_unit_id > index scan output in the query plan contains: > qualifiers: > Column[0][0] Id: 0 > Operator: = > Ordered nulls: false > Unknown return value: false > Negate comparison result: false > However, in the case where the query gives 3 rows, which is > when we specify account.admin_unit_id in (1,21), the admin_unit_id > index scan output in the query plan contains: > qualifiers: > None > I think it is the presence/absence of this qualifier on the query > scan which is causing the different results in the query, as in > the first case we see: > Number of rows qualified=2 > Number of rows visited=3 > but in the second case we see: > Number of rows qualified=3 > Number of rows visited=3 > I definitely don't have any explanation for why you are getting > this odd behavior; it certainly seems like a bug to me. > -------------END SNIP ----------------------- -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.