Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 93083 invoked from network); 29 Oct 2009 09:57:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 29 Oct 2009 09:57:23 -0000 Received: (qmail 72413 invoked by uid 500); 29 Oct 2009 09:57:23 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 72343 invoked by uid 500); 29 Oct 2009 09:57:23 -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 72333 invoked by uid 99); 29 Oct 2009 09:57:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Oct 2009 09:57:23 +0000 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; Thu, 29 Oct 2009 09:57:21 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 6577B234C045 for ; Thu, 29 Oct 2009 02:56:59 -0700 (PDT) Message-ID: <1821038823.1256810219396.JavaMail.jira@brutus> Date: Thu, 29 Oct 2009 09:56:59 +0000 (UTC) From: "Knut Anders Hatlen (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Updated: (DERBY-4421) Allow Visitors to process the nodes bottom-up In-Reply-To: <799935563.1256296799485.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/DERBY-4421?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Knut Anders Hatlen updated DERBY-4421: -------------------------------------- Attachment: d4421-2a.stat d4421-2a.diff Attaching patch 2a which removes the now redundant calls to stopTraversal() in acceptChildren(). The calls are redundant because QTN.accept() always checks stopTraversal() before calling visit(). I found a couple of instances where subclasses had forgotten to check stopTraversal(), so I believe the centralized check in QTN.accept() is more robust than relying on each subclass to check it. All the regression tests ran cleanly. > Allow Visitors to process the nodes bottom-up > --------------------------------------------- > > Key: DERBY-4421 > URL: https://issues.apache.org/jira/browse/DERBY-4421 > Project: Derby > Issue Type: Improvement > Components: SQL > Affects Versions: 10.6.0.0 > Reporter: Knut Anders Hatlen > Assignee: Knut Anders Hatlen > Priority: Minor > Attachments: d4421-1a.diff, d4421-1a.stat, d4421-2a.diff, d4421-2a.stat > > > Currently, QueryTreeNode.accept() walks the tree top-down, always calling > visit() on the parent before it calls visit() on the children. Although this > is fine in most cases, there are use cases where visiting the nodes > bottom-up would be better. One example is mentioned in DERBY-4416. The > visitor posted there looks for binary comparison operators and checks > whether both operands are constants. If they are, the operator is replaced > with a boolean constant. > Take this expression as an example: (1<2)=(2>1) > The query tree looks like this: > = > / \ > / \ > < > > / \ / \ > / \ / \ > 1 2 2 1 > If we walk the tree top-down with the said visitor, the = node doesn't have > constant operands when it's visited. The < and > operators do have constant > operands, and they're both replaced with constant TRUE. This means the > expression (1<2)=(2>1) is rewritten to TRUE=TRUE, and that's how far the > transformation goes. > If the tree had been processed bottom-up, we would start with the < and > > operators, and again replace them with TRUE. The query tree would therefore > have been transformed to this intermediate form when the = operator was > visited: > = > / \ > / \ > TRUE TRUE > This is the same as the end result when visiting top-down, but now the = > operator hasn't been visited yet. Since both the operands of the = operator > are constants, the visitor will perform yet another transformation so the > tree is simplified further and ends up as: > TRUE -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.