db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r545443 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
Date Fri, 08 Jun 2007 07:07:52 GMT
Author: mamta
Date: Fri Jun  8 00:07:51 2007
New Revision: 545443

URL: http://svn.apache.org/viewvc?view=rev&rev=545443
Log:
DERBY-2777
Fixed the combination of CONCATENATION and parameters so that the parameters take their collation
from the context and not from the current
compilation schema



Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java
    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/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=545443&r1=545442&r2=545443
==============================================================================
--- 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
Fri Jun  8 00:07:51 2007
@@ -125,9 +125,11 @@
 
 			leftOperand.setType(new DataTypeDescriptor(leftType, true));
 			if (rightOperand.getTypeId().isStringTypeId()) {
-				//collation of ? operand should be same as the compilation schema
-				leftOperand.setCollationUsingCompilationSchema(
-						StringDataValue.COLLATION_DERIVATION_IMPLICIT);
+				//collation of ? operand should be picked from the context
+				leftOperand.getTypeServices().setCollationDerivation(
+						rightOperand.getTypeServices().getCollationDerivation());
+				leftOperand.getTypeServices().setCollationType(
+						rightOperand.getTypeServices().getCollationType());
 			}
 		}
 
@@ -166,9 +168,11 @@
 			}
 			rightOperand.setType(new DataTypeDescriptor(rightType, true));
 			if (leftOperand.getTypeId().isStringTypeId()) {
-				//collation of ? operand should be same as the compilation schema
-				rightOperand.setCollationUsingCompilationSchema(
-						StringDataValue.COLLATION_DERIVATION_IMPLICIT);
+				//collation of ? operand should be picked from the context
+				rightOperand.getTypeServices().setCollationDerivation(
+						leftOperand.getTypeServices().getCollationDerivation());
+				rightOperand.getTypeServices().setCollationType(
+						leftOperand.getTypeServices().getCollationType());
 			}
 		}
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java?view=diff&rev=545443&r1=545442&r2=545443
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
Fri Jun  8 00:07:51 2007
@@ -716,6 +716,28 @@
     rs = ps.executeQuery();
     JDBC.assertFullResultSet(rs,new String[][] {{"SYSCOLUMNS"}});      
 
+    //Do parameter testing with CONCATENATION operator
+    //Following will fail because the result of concatenation will have 
+    //collation type of UCS_BASIC whereas the right hand side of = operator
+    //will have collation type current schema which is territory based.
+    //The reason CONCAT will have collation type of UCS_BASIC is because ? will
+    //take collation from context which here will be TABLENAME and hence the
+    //result of concatenation will have collation type of it's 2 operands,
+    //namely UCS_BASIC
+    checkPreparedStatementError(conn, "SELECT TABLENAME FROM SYS.SYSTABLES " +
+    		" WHERE TABLENAME || ? = 'SYSCOLUMNS '", "42818");   
+    //The query above can be made to work if we are in SYS schema or if we use
+    //CAST while we are trying to run the query is user schema
+    //Let's try CAST first
+    ps = conn.prepareStatement("SELECT TABLENAME FROM SYS.SYSTABLES WHERE " +
+    		" CAST(TABLENAME || ? AS CHAR(10)) = 'SYSCOLUMNS '");   
+    //try switching to SYS schema and then run the original query without CAST
+    s.executeUpdate("set schema SYS");
+    checkPreparedStatementError(conn, "SELECT TABLENAME FROM SYS.SYSTABLES " +
+    		" WHERE TABLENAME || ? = 'SYSCOLUMNS '", "42818");   
+    s.executeUpdate("set schema APP");
+
+    
     //Do parameter testing with COALESCE
     //following will pass because the ? inside the COALESCE will take the 
     //collation type of the other operand which is TABLENAME. The result of



Mime
View raw message