Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 95333 invoked from network); 27 Jun 2007 04:20:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 27 Jun 2007 04:20:25 -0000 Received: (qmail 34550 invoked by uid 500); 27 Jun 2007 04:20:28 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 34521 invoked by uid 500); 27 Jun 2007 04:20:28 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 34510 invoked by uid 99); 27 Jun 2007 04:20:28 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Jun 2007 21:20:28 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Jun 2007 21:20:24 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id D90941A981A; Tue, 26 Jun 2007 21:20:03 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r551033 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/CastNode.java engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java Date: Wed, 27 Jun 2007 04:20:03 -0000 To: derby-commits@db.apache.org From: mamta@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070627042003.D90941A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mamta Date: Tue Jun 26 21:20:01 2007 New Revision: 551033 URL: http://svn.apache.org/viewvc?view=rev&rev=551033 Log: DERBY-2776 Internally generated CAST nodes should not pick up the collation of the current schema. In order to implement this, the CAST nodes generated directly by the user sql (parser) will set a flag on the cast node to indicate that they are externally generated CAST nodes. During the bind phase of a CAST node, we will check if the node is externally generated. If yes, then we will have it pick up the collation of the compilation schema otherwise we will leave the collation unchanged. Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java?view=diff&rev=551033&r1=551032&r2=551033 ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java Tue Jun 26 21:20:01 2007 @@ -31,7 +31,6 @@ import org.apache.derby.iapi.sql.compile.C_NodeTypes; import org.apache.derby.iapi.types.DataTypeUtilities; -import org.apache.derby.iapi.types.StringDataValue; import org.apache.derby.iapi.types.TypeId; import org.apache.derby.iapi.reference.Limits; @@ -76,6 +75,17 @@ TypeId destCTI = null; TypeId sourceCTI = null; boolean forDataTypeFunction = false; + /** This variable gets set by the parser to indiciate that this CAST node + * has been generated by the parser. This means that we should use the + * collation info of the current compilation schmea for this node's + * collation setting. If this variable does not get set to true, then it + * means that this CAST node has been an internally generated node and we + * should not touch the collation info set for this CAST node because it + * has been already set correctly by the class that generated this CAST + * node. Collation info is part of the DataTypeDescriptor that's defined + * on the ValueNode (the super class of this CastNode class) + */ + boolean externallyGeneratedCastNode = false; /* ** Static array of valid casts. Dimentions @@ -363,7 +373,7 @@ //If the result type of cast is string data type, then that data type //should get it's collation type from the current schema. - if (destCTI.isStringTypeId()) { + if (externallyGeneratedCastNode && destCTI.isStringTypeId()) { //set the collation type to be same as the current schema's //collation type. Collation derivation is already initialized //to correct value by default which is "IMPLICIT" @@ -1002,6 +1012,21 @@ } return returnNode; + } + + /** This method gets called by the parser to indiciate that this CAST node + * has been generated by the parser. This means that we should use the + * collation info of the current compilation schmea for this node's + * collation setting. If this method does not get called, then it means + * that this CAST node has been an internally generated node and we should + * not touch the collation of this CAST node because it has been already + * set correctly by the class that generated this CAST node. + * + * @param b true to use function conversion rules + */ + public void setForExternallyGeneratedCASTnode() + { + externallyGeneratedCastNode = true; } /** set this to be a dataTypeScalarFunction Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj?view=diff&rev=551033&r1=551032&r2=551033 ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj Tue Jun 26 21:20:01 2007 @@ -6666,6 +6666,7 @@ dts, getContextManager()); ((CastNode) value).setForDataTypeFunction(true); + ((CastNode) value).setForExternallyGeneratedCASTnode(); return value; } @@ -6681,6 +6682,7 @@ getContextManager()); ((CastNode) value).setForDataTypeFunction(true); + ((CastNode) value).setForExternallyGeneratedCASTnode(); return value; } } @@ -7229,11 +7231,13 @@ */