Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 8404 invoked from network); 5 Oct 2005 16:33:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 5 Oct 2005 16:33:01 -0000 Received: (qmail 69098 invoked by uid 500); 5 Oct 2005 16:07:42 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 69014 invoked by uid 500); 5 Oct 2005 16:07:41 -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: "Derby Development" Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 69003 invoked by uid 99); 5 Oct 2005 16:07:41 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Oct 2005 09:07:41 -0700 X-ASF-Spam-Status: No, hits=0.4 required=10.0 tests=SPF_HELO_FAIL X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [32.97.110.157] (HELO bldfb.esmtp.ibm.com) (32.97.110.157) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Oct 2005 09:07:44 -0700 Received: from e36.co.us.ibm.com ([9.17.249.46]) by bldfb.esmtp.ibm.com (8.12.11/8.12.11) with ESMTP id j95G6sgl009041 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 5 Oct 2005 12:06:54 -0400 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e36.co.us.ibm.com (8.12.11/8.12.11) with ESMTP id j95G5WtN024578 for ; Wed, 5 Oct 2005 12:05:32 -0400 Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d03relay04.boulder.ibm.com (8.12.10/NCO/VERS6.7) with ESMTP id j95G7Tx4550024 for ; Wed, 5 Oct 2005 10:07:37 -0600 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.12.11/8.13.3) with ESMTP id j95G6kQO029154 for ; Wed, 5 Oct 2005 10:06:46 -0600 Received: from [127.0.0.1] (DMCSDJDT41P.usca.ibm.com [9.72.133.55]) by d03av04.boulder.ibm.com (8.12.11/8.12.11) with ESMTP id j95G6kAD028894 for ; Wed, 5 Oct 2005 10:06:46 -0600 Message-ID: <4343FA11.90406@debrunners.com> Date: Wed, 05 Oct 2005 09:06:41 -0700 From: Daniel John Debrunner User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.3) Gecko/20040910 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Derby Development Subject: Re: [PATCH]Derby-582 Dynamic parameter should be allowed to be the operand of unary operator "-". References: <4343DEC0.5070805@debrunners.com> In-Reply-To: X-Enigmail-Version: 0.90.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Mamta Satoor wrote: > Let me go back to the example sql > select * from t1 where c1 = -? > BinaryOperatorNode.bindExpression checks if right operand is a parameter > node and if yes, it CASTS the right operand to ParameterNode and calls > setDescriptor method on it. > /* Is there a ? parameter on the right? */ > if (rightOperand.isParameterNode()) > { > /* Set the right operand to the type of the left parameter. */ > (*(ParameterNode)* rightOperand).setDescriptor( > leftOperand.getTypeServices()); > } > This casting of a parameter operand to ParameterNode and setting the > descriptor on it is spread all over Derby engine code and rather than > having to change them all, I decided to make UnaryOperatorNode extend > ParameterNode so the rest of the type setting code can work without any > change. > > It's possible that I have been thinking single track, so if anyone have > any suggestions, do let me know. Unfortunately I think you have been driven down that track due to the current code. :-( One of my credo's is that it doesn't matter how much code needs to be changed to make a fix, if it makes the code better then it's a good thing to change all that code. On this it seems that there is some current confusion in the code, ValueNode has two methods to set the type, setType and setDescriptor. So why does ParameterNode need a special set type method setDescriptor, and the associated required casting? A possible direction for the fix is: - Have an isParameterNode method in UnaryOperatorNode that returns its operand's isParameterNode return value. - Have a single type setting method setType in ValueNode - Have ParameterNode override setType with any logic it needs. The the code above becomes: if (rightOperand.isParameterNode()) rightOperand.setType(leftOperand.getTypeServices()) Maybe I'm missing something in the above that will come out in the details, but it may be better to address that, rather than the somewhat unnatural forcing of a UnaryOperatorNode to be a ParameterNode, when logically it is not a ParameterNode. I'm willing to help out on any issues you discover on this new path. Dan.