db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r543266 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/
Date Thu, 31 May 2007 21:30:04 GMT
Author: mamta
Date: Thu May 31 14:30:02 2007
New Revision: 543266

URL: http://svn.apache.org/viewvc?view=rev&rev=543266
Log:
DERBY-2599
There are few character string types that should take their collation type from compilation
schema. I had earlier checked in code for them
to use current schema rather than compilation schema (For reference http://www.nabble.com/more-on-system-schema-vs.-user-schema-and-character-constants.-p10885286.html)
With this commit, I am adding an utility method in ValueNode called setCollationUsingCompilationSchema(int)
which will use the compilation
schema's collation type for it's DTD. And it will use the passed int value to set its DTD's
collation derivation. This utility method will
be used by the subclasses of ValueNode to set their DTD's collation type to compilation schema's
type wherever required. Note that all the
character string types always take their collation from the compilation schema. For instance,
persistent character string type column from a
table will take the collation type from the schema their table belongs to rather than the
compilation schema.

I have run the 2 collation related tests, CollationTest and CollationTest2 and they run with
no problems. 


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryListOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharConstantNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IsNullNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LengthOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SimpleStringOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TernaryOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryArithmeticOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryListOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryListOperatorNode.java?view=diff&rev=543266&r1=543265&r2=543266
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryListOperatorNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryListOperatorNode.java
Thu May 31 14:30:02 2007
@@ -162,10 +162,8 @@
 			leftOperand.setType(rightOperandList.getTypeServices());
 			//? parameter should pick up the collation type of the schema in
 			//which this statement is getting compiled.
-			leftOperand.getTypeServices().setCollationDerivation(
+			leftOperand.setCollationUsingCompilationSchema(
 					StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-			leftOperand.getTypeServices().setCollationType(
-					getLanguageConnectionContext().getDefaultSchema().getCollationType());
 		}
 
 		/* Is there a ? parameter on the right? */

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java?view=diff&rev=543266&r1=543265&r2=543266
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java
Thu May 31 14:30:02 2007
@@ -316,11 +316,9 @@
 
 			/* Set the left operand to the type of right parameter. */
 			leftOperand.setType(rightOperand.getTypeServices());
-			//collation of ? operand should be same as the current schema
-			leftOperand.getTypeServices().setCollationDerivation(
+			//collation of ? operand should be same as the compilation schema
+			leftOperand.setCollationUsingCompilationSchema(
 					StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-			leftOperand.getTypeServices().setCollationType(
-					getLanguageConnectionContext().getDefaultSchema().getCollationType());
 		}
 
 		/* Is there a ? parameter on the right? */
@@ -328,12 +326,9 @@
 		{
 			/* Set the right operand to the type of the left parameter. */
 			rightOperand.setType(leftOperand.getTypeServices());
-			//collation of ? operand should be same as the current schema
-			rightOperand.getTypeServices().setCollationDerivation(
+			//collation of ? operand should be same as the compilation schema
+			rightOperand.setCollationUsingCompilationSchema(
 					StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-			rightOperand.getTypeServices().setCollationType(
-					getLanguageConnectionContext().getDefaultSchema()
-							.getCollationType());
 		}
 
 		return genSQLJavaSQLTree();

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharConstantNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharConstantNode.java?view=diff&rev=543266&r1=543265&r2=543266
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharConstantNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharConstantNode.java
Thu May 31 14:30:02 2007
@@ -155,8 +155,8 @@
 	{
 		//The DTD for this character constant should get its collation type
 		//from the schema it is getting compiled in.
-		getTypeServices().setCollationType(
-				getLanguageConnectionContext().getDefaultSchema().getCollationType());
+		setCollationUsingCompilationSchema(
+				StringDataValue.COLLATION_DERIVATION_IMPLICIT);
 	    //Once we have the collation type, we should check if the value
 	    //associated with this node should change from 
 	    //SQLChar/SQLVarchar/SQLLongvarchar/SQLClob

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java?view=diff&rev=543266&r1=543265&r2=543266
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java
Thu May 31 14:30:02 2007
@@ -176,14 +176,9 @@
 			if (((ValueNode) argumentsList.elementAt(index)).requiresTypeFromContext())
 			{
 				((ValueNode)argumentsList.elementAt(index)).setType(getTypeServices());
-				//collation of ? operand should be same as the current schema
-				((ValueNode)argumentsList.elementAt(index)).getTypeServices()
-				.setCollationDerivation(
+				//collation of ? operand should be same as the compilation schema
+				((ValueNode)argumentsList.elementAt(index)).setCollationUsingCompilationSchema(
 						StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-				((ValueNode)argumentsList.elementAt(index)).getTypeServices()
-				.setCollationType(
-						getLanguageConnectionContext().getDefaultSchema()
-								.getCollationType());
 				break;
 			}
 		}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java?view=diff&rev=543266&r1=543265&r2=543266
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java
Thu May 31 14:30:02 2007
@@ -125,12 +125,9 @@
 
 			leftOperand.setType(new DataTypeDescriptor(leftType, true));
 			if (rightOperand.getTypeId().isStringTypeId()) {
-				//collation of ? operand should be same as the current schema
-				leftOperand.getTypeServices().setCollationDerivation(
+				//collation of ? operand should be same as the compilation schema
+				leftOperand.setCollationUsingCompilationSchema(
 						StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-				leftOperand.getTypeServices().setCollationType(
-						getLanguageConnectionContext().getDefaultSchema()
-								.getCollationType());
 			}
 		}
 
@@ -169,12 +166,9 @@
 			}
 			rightOperand.setType(new DataTypeDescriptor(rightType, true));
 			if (leftOperand.getTypeId().isStringTypeId()) {
-				//collation of ? operand should be same as the current schema
-				rightOperand.getTypeServices().setCollationDerivation(
+				//collation of ? operand should be same as the compilation schema
+				rightOperand.setCollationUsingCompilationSchema(
 						StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-				rightOperand.getTypeServices().setCollationType(
-						getLanguageConnectionContext().getDefaultSchema()
-								.getCollationType());
 			}
 		}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IsNullNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IsNullNode.java?view=diff&rev=543266&r1=543265&r2=543266
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IsNullNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IsNullNode.java Thu
May 31 14:30:02 2007
@@ -146,12 +146,9 @@
 		*/
 
 		operand.setType(new DataTypeDescriptor(TypeId.getBuiltInTypeId(Types.VARCHAR), true));
-		//collation of ? operand should be same as the current schema
-		operand.getTypeServices().setCollationDerivation(
+		//collation of ? operand should be same as the compilation schema
+		operand.setCollationUsingCompilationSchema(
 				StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-		operand.getTypeServices().setCollationType(
-				getLanguageConnectionContext().getDefaultSchema()
-						.getCollationType());
 	}
 
 	/* RelationalOperator interface */

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LengthOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LengthOperatorNode.java?view=diff&rev=543266&r1=543265&r2=543266
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LengthOperatorNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LengthOperatorNode.java
Thu May 31 14:30:02 2007
@@ -148,12 +148,9 @@
 
 		operand.setType(DataTypeDescriptor.getBuiltInDataTypeDescriptor(parameterType, true, 
 												parameterWidth));
-		//collation of ? operand should be same as the current schema
-		operand.getTypeServices().setCollationDerivation(
+		//collation of ? operand should be same as the compilation schema
+		operand.setCollationUsingCompilationSchema(
 				StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-		operand.getTypeServices().setCollationType(
-				getLanguageConnectionContext().getDefaultSchema()
-						.getCollationType());
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java?view=diff&rev=543266&r1=543265&r2=543266
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
Thu May 31 14:30:02 2007
@@ -189,12 +189,9 @@
             receiver.setType(
                 new DataTypeDescriptor(
                     TypeId.getBuiltInTypeId(Types.VARCHAR), true));
-			//collation of ? operand should be same as the current schema
-			receiver.getTypeServices().setCollationDerivation(
+			//collation of ? operand should be same as the compilation schema
+			receiver.setCollationUsingCompilationSchema(
 					StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-			receiver.getTypeServices().setCollationType(
-					getLanguageConnectionContext().getDefaultSchema()
-							.getCollationType());
         }
 
         /* 
@@ -220,12 +217,9 @@
                     new DataTypeDescriptor(
                         TypeId.getBuiltInTypeId(Types.VARCHAR), true));
             }
-			//collation of ? operand should be same as the current schema
-			leftOperand.getTypeServices().setCollationDerivation(
+			//collation of ? operand should be same as the compilation schema
+			leftOperand.setCollationUsingCompilationSchema(
 					StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-			leftOperand.getTypeServices().setCollationType(
-					getLanguageConnectionContext().getDefaultSchema()
-							.getCollationType());
         }
 
         /* 
@@ -250,12 +244,9 @@
                     new DataTypeDescriptor(
                         TypeId.getBuiltInTypeId(Types.VARCHAR), true));
             }
-			//collation of ? operand should be same as the current schema
-			rightOperand.getTypeServices().setCollationDerivation(
+			//collation of ? operand should be same as the compilation schema
+			rightOperand.setCollationUsingCompilationSchema(
 					StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-			rightOperand.getTypeServices().setCollationType(
-					getLanguageConnectionContext().getDefaultSchema()
-							.getCollationType());
         }
 
         bindToBuiltIn();

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java?view=diff&rev=543266&r1=543265&r2=543266
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java Thu
May 31 14:30:02 2007
@@ -574,12 +574,9 @@
 			if (getTypeServices() != null)
 			{
 				expression.setType(getTypeServices());
-				//collation of ? operand should be same as the current schema
-				expression.getTypeServices().setCollationDerivation(
+				//collation of ? operand should be same as the compilation schema
+				expression.setCollationUsingCompilationSchema(
 						StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-				expression.getTypeServices().setCollationType(
-						getLanguageConnectionContext().getDefaultSchema()
-								.getCollationType());
 			}
 		}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java?view=diff&rev=543266&r1=543265&r2=543266
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java Thu
May 31 14:30:02 2007
@@ -336,12 +336,9 @@
 				** corresponding column of the target table.
 				*/
 				re.setType(typeCol.getTypeServices());
-				//collation of ? operand should be same as the current schema
-				re.getTypeServices().setCollationDerivation(
+				//collation of ? operand should be same as the compilation schema
+				re.setCollationUsingCompilationSchema(
 						StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-				re.getTypeServices().setCollationType(
-						getLanguageConnectionContext().getDefaultSchema()
-								.getCollationType());
 			}
 			else if (re instanceof CharConstantNode)
 			{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java?view=diff&rev=543266&r1=543265&r2=543266
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java
Thu May 31 14:30:02 2007
@@ -728,12 +728,9 @@
 				** type array.
 				*/
 				rc.getExpression().setType(types[index]);
-				//collation of ? operand should be same as the current schema
-				rc.getExpression().getTypeServices().setCollationDerivation(
+				//collation of ? operand should be same as the compilation schema
+				rc.getExpression().setCollationUsingCompilationSchema(
 						StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-				rc.getExpression().getTypeServices().setCollationType(
-						getLanguageConnectionContext().getDefaultSchema()
-								.getCollationType());
 			}
 		}
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SimpleStringOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SimpleStringOperatorNode.java?view=diff&rev=543266&r1=543265&r2=543266
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SimpleStringOperatorNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SimpleStringOperatorNode.java
Thu May 31 14:30:02 2007
@@ -151,12 +151,9 @@
 		*/
 
 		operand.setType(DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.VARCHAR));
-		//collation of ? operand should be same as the current schema
-		operand.getTypeServices().setCollationDerivation(
+		//collation of ? operand should be same as the compilation schema
+		operand.setCollationUsingCompilationSchema(
 				StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-		operand.getTypeServices().setCollationType(
-				getLanguageConnectionContext().getDefaultSchema()
-						.getCollationType());
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java?view=diff&rev=543266&r1=543265&r2=543266
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java Thu
May 31 14:30:02 2007
@@ -532,12 +532,9 @@
 		{
 			leftOperand.setType(
 				((ResultColumn) resultColumns.elementAt(0)).getTypeServices());
-			//collation of ? operand should be same as the current schema
-			leftOperand.getTypeServices().setCollationDerivation(
+			//collation of ? operand should be same as the compilation schema
+			leftOperand.setCollationUsingCompilationSchema(
 					StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-			leftOperand.getTypeServices().setCollationType(
-					getLanguageConnectionContext().getDefaultSchema()
-							.getCollationType());
 		}
 
 		// Set the DataTypeServices

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TernaryOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TernaryOperatorNode.java?view=diff&rev=543266&r1=543265&r2=543266
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TernaryOperatorNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TernaryOperatorNode.java
Thu May 31 14:30:02 2007
@@ -524,12 +524,9 @@
 			*/
 	
 			receiver.setType(getVarcharDescriptor());
-			//collation of ? operand should be same as the current schema
-			receiver.getTypeServices().setCollationDerivation(
+			//collation of ? operand should be same as the compilation schema
+			receiver.setCollationUsingCompilationSchema(
 					StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-			receiver.getTypeServices().setCollationType(
-					getLanguageConnectionContext().getDefaultSchema()
-							.getCollationType());
 		}
 
 		/* Is there a ? parameter on the left? */
@@ -537,12 +534,9 @@
 		{
 			/* Set the left operand type to varchar. */
 			leftOperand.setType(getVarcharDescriptor());
-			//collation of ? operand should be same as the current schema
-			leftOperand.getTypeServices().setCollationDerivation(
+			//collation of ? operand should be same as the compilation schema
+			leftOperand.setCollationUsingCompilationSchema(
 					StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-			leftOperand.getTypeServices().setCollationType(
-					getLanguageConnectionContext().getDefaultSchema()
-							.getCollationType());
 		}
 
 		bindToBuiltIn();
@@ -635,12 +629,9 @@
 							         leftOperand.getTypeServices());
 				}
 			}
-			//collation of ? operand should be same as the current schema
-			receiver.getTypeServices().setCollationDerivation(
+			//collation of ? operand should be same as the compilation schema
+			receiver.setCollationUsingCompilationSchema(
 					StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-			receiver.getTypeServices().setCollationType(
-					getLanguageConnectionContext().getDefaultSchema()
-							.getCollationType());
 		}
 							                            
 		/*
@@ -661,12 +652,9 @@
 							         receiver.getTypeServices());
 				}
 			}
-			//collation of ? operand should be same as the current schema
-			leftOperand.getTypeServices().setCollationDerivation(
+			//collation of ? operand should be same as the compilation schema
+			leftOperand.setCollationUsingCompilationSchema(
 					StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-			leftOperand.getTypeServices().setCollationType(
-					getLanguageConnectionContext().getDefaultSchema()
-							.getCollationType());
 		}
 
 		/*
@@ -676,12 +664,9 @@
 		{
 			rightOperand.setType(
 				new DataTypeDescriptor(TypeId.INTEGER_ID, true)); 
-			//collation of ? operand should be same as the current schema
-			rightOperand.getTypeServices().setCollationDerivation(
+			//collation of ? operand should be same as the compilation schema
+			rightOperand.setCollationUsingCompilationSchema(
 					StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-			rightOperand.getTypeServices().setCollationType(
-					getLanguageConnectionContext().getDefaultSchema()
-							.getCollationType());
 		}
 
 		bindToBuiltIn();
@@ -757,12 +742,9 @@
 			*/
 	
 			receiver.setType(getVarcharDescriptor());
-			//collation of ? operand should be same as the current schema
-			receiver.getTypeServices().setCollationDerivation(
+			//collation of ? operand should be same as the compilation schema
+			receiver.setCollationUsingCompilationSchema(
 					StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-			receiver.getTypeServices().setCollationType(
-					getLanguageConnectionContext().getDefaultSchema()
-							.getCollationType());
 		}
 
 		/* Is there a ? parameter on the left? */
@@ -893,12 +875,9 @@
         if( arg.requiresTypeFromContext() && arg.getTypeId() == null)
         {
             arg.setType( new DataTypeDescriptor(TypeId.getBuiltInTypeId( jdbcType), true));
-			//collation of ? operand should be same as the current schema
-			arg.getTypeServices().setCollationDerivation(
+			//collation of ? operand should be same as the compilation schema
+			arg.setCollationUsingCompilationSchema(
 					StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-			arg.getTypeServices().setCollationType(
-					getLanguageConnectionContext().getDefaultSchema()
-							.getCollationType());
             return true;
         }
         return false;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampOperatorNode.java?view=diff&rev=543266&r1=543265&r2=543266
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampOperatorNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampOperatorNode.java
Thu May 31 14:30:02 2007
@@ -90,22 +90,16 @@
 		//Set the type if there is a parameter involved here 
 		if (leftOperand.requiresTypeFromContext()) {
 			leftOperand.setType(DataTypeDescriptor.getBuiltInDataTypeDescriptor( Types.DATE));
-			//collation of ? operand should be same as the current schema
-			leftOperand.getTypeServices().setCollationDerivation(
+			//collation of ? operand should be same as the compilation schema
+			leftOperand.setCollationUsingCompilationSchema(
 					StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-			leftOperand.getTypeServices().setCollationType(
-					getLanguageConnectionContext().getDefaultSchema()
-							.getCollationType());
 		}
 		//Set the type if there is a parameter involved here 
 		if (rightOperand.requiresTypeFromContext()) {
 			rightOperand.setType(DataTypeDescriptor.getBuiltInDataTypeDescriptor( Types.TIME));
-			//collation of ? operand should be same as the current schema
-			rightOperand.getTypeServices().setCollationDerivation(
+			//collation of ? operand should be same as the compilation schema
+			rightOperand.setCollationUsingCompilationSchema(
 					StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-			rightOperand.getTypeServices().setCollationType(
-					getLanguageConnectionContext().getDefaultSchema()
-							.getCollationType());
 		}
 
 		TypeId leftTypeId = leftOperand.getTypeId();

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryArithmeticOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryArithmeticOperatorNode.java?view=diff&rev=543266&r1=543265&r2=543266
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryArithmeticOperatorNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryArithmeticOperatorNode.java
Thu May 31 14:30:02 2007
@@ -253,12 +253,9 @@
 	public void setType(DataTypeDescriptor descriptor) throws StandardException
 	{
 		operand.setType(descriptor);
-		//collation of ? operand should be same as the current schema
-		operand.getTypeServices().setCollationDerivation(
+		//collation of ? operand should be same as the compilation schema
+		operand.setCollationUsingCompilationSchema(
 				StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-		operand.getTypeServices().setCollationType(
-				getLanguageConnectionContext().getDefaultSchema()
-						.getCollationType());
 		super.setType(descriptor);
 		//Derby-582 add support for dynamic parameters for unary plus and minus
 		//Now that we know the type of this parameter node, we can do the

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java?view=diff&rev=543266&r1=543265&r2=543266
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java
Thu May 31 14:30:02 2007
@@ -446,10 +446,7 @@
         setType(targetType);
 		//Set the collation type to be same as the current schema's 
 		//collation type. 
-		getTypeServices().setCollationType(
-				getLanguageConnectionContext().getDefaultSchema().getCollationType());
-		//Set the collation derivation to be "IMPLICIT".
-		getTypeServices().setCollationDerivation(
+        setCollationUsingCompilationSchema(
 				StringDataValue.COLLATION_DERIVATION_IMPLICIT);
     }
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java?view=diff&rev=543266&r1=543265&r2=543266
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java Thu May
31 14:30:02 2007
@@ -238,6 +238,28 @@
 		// Clear the typeCompiler, just in case type has changed
 		typeCompiler = null;
 	}
+	
+	/**
+	 * There are many subclasses of ValueNode where we want the 
+	 * DataTypeDescriptor of the node to have the same collation type as the 
+	 * compilation schema's collation type. For that purpose, this method in 
+	 * the baseclass here can be utilized by the subclasses. In addition, the
+	 * subclasses can pass the collationDerivation that they expect the
+	 * DataTypeDescriptor to have.
+	 * 
+	 * @param collationDerivation This can be 
+	 * StringDataValue#COLLATION_DERIVATION_IMPLICIT
+	 * StringDataValue#COLLATION_DERIVATION_NONE
+	 * StringDataValue#COLLATION_DERIVATION_EXPLICIT
+	 * 
+	 * @throws StandardException
+	 */
+	protected void setCollationUsingCompilationSchema(int collationDerivation)
+	throws StandardException {
+		dataTypeServices.setCollationType(
+	    	     getSchemaDescriptor(null).getCollationType());
+		dataTypeServices.setCollationDerivation(collationDerivation);
+	}
 
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java?view=diff&rev=543266&r1=543265&r2=543266
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java Thu
May 31 14:30:02 2007
@@ -551,10 +551,8 @@
 				valueNode.setType(descriptor);
 				//? parameter should pick up the collation type of the schema in
 				//which this statement is getting compiled.
-				valueNode.getTypeServices().setCollationDerivation(
+				valueNode.setCollationUsingCompilationSchema(
 						StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-				valueNode.getTypeServices().setCollationType(
-						getLanguageConnectionContext().getDefaultSchema().getCollationType());
 			}
 		}
 	}



Mime
View raw message