Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 15544 invoked from network); 12 Jun 2007 02:57:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Jun 2007 02:57:21 -0000 Received: (qmail 52909 invoked by uid 500); 12 Jun 2007 02:57:25 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 52878 invoked by uid 500); 12 Jun 2007 02:57:24 -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 52869 invoked by uid 99); 12 Jun 2007 02:57:24 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Jun 2007 19:57:24 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: local policy) Received: from [69.147.64.96] (HELO smtp123.sbc.mail.sp1.yahoo.com) (69.147.64.96) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 11 Jun 2007 19:57:20 -0700 Received: (qmail 5088 invoked from network); 12 Jun 2007 02:57:00 -0000 Received: from unknown (HELO ?192.168.254.49?) (ddebrunner@sbcglobal.net@75.26.0.86 with plain) by smtp123.sbc.mail.sp1.yahoo.com with SMTP; 12 Jun 2007 02:56:59 -0000 X-YMail-OSG: Ykfi9AkVM1nUIzw8Fwi4FCmRIPcese.AlcswXTRaaaJaFNTeSzTz0jjw6Z3rJb1rSfhrJlb9.A-- Message-ID: <466E0B37.2070209@apache.org> Date: Mon, 11 Jun 2007 19:55:51 -0700 From: Daniel John Debrunner User-Agent: Thunderbird 1.5.0.12 (Windows/20070509) MIME-Version: 1.0 To: derby-dev@db.apache.org Subject: Re: Setting correct collation on return type of a user defined function References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Mamta Satoor wrote: > The schema information is available at CreateAliasNode.bindStatement > time. I was thinking of modifying the collation type of return type > (returnType variable in) of RoutineAliasInfo inside > CreateAliadNode.bindStatement but there is not a way to do that > currently because RoutineAliasInfo does not have a method to change the > TypeDescriptor of it's return type. I can fix that easily by adding a > new method to RoutineAliasInfo like following > > public void setReturnType(TypeDescriptor typeWithCorrectCollation) { > returnType = typeWithCorrectCollation; > } RoutineAliasInfo doesn't have any set methods as it is intended to be an immutable (at least logically). This allows instances of it to be passed around without worrying about other users changing its definition. Immutable objects can benefit code quality by not leading to bugs where state changes in one part of the code cause unexpected changes elsewhere. > But the other problem is that there is no way to change a TypeDescriptor > object. All I want to do is something like following in > CreateAliasNode.bindStatement > > if (aliasType == AliasInfo.ALIAS_TYPE_FUNCTION_AS_CHAR) { > RoutineAliasInfo rai = (RoutineAliasInfo)aliasInfo; > TypeDescriptor returnType = rai.getReturnType(); > //pseudo code. Get the schema descriptor sd for function's schema > returnType.setCollationType(sd.getCollationType()); > rai.setReturnType(returnType); > } > > But since there is no way to change the collation type on the > TypeDescriptor interface, do I just somehow CAST returnType to > TypeDescriptorImpl and change the collation type on it. This (CASTing) > doesn't seem right to me but before I spend too much time on the > problem, I wanted to see if anyone had any ideas/feedback. TypeDescriptor is also logically immutable for similar reasons, one doesn't want the type of a column in a catalog to be changed by some code re-using the descriptor and changing its nullability (or collation). I'm cleaning up the TypeDescriptor under DERBY-2775. Dan.