db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r545319 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/ testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Thu, 07 Jun 2007 21:26:24 GMT
Author: mamta
Date: Thu Jun  7 14:26:23 2007
New Revision: 545319

URL: http://svn.apache.org/viewvc?view=rev&rev=545319
Log:
DERBY-2777
Fixed the combination of IN operator 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/BinaryListOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.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/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=545319&r1=545318&r2=545319
==============================================================================
--- 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 Jun  7 14:26:23 2007
@@ -27,7 +27,6 @@
 
 import org.apache.derby.iapi.types.DataTypeDescriptor;
 import org.apache.derby.iapi.types.TypeId;
-import org.apache.derby.iapi.types.StringDataValue;
 import org.apache.derby.iapi.sql.compile.Visitor;
 import org.apache.derby.iapi.sql.compile.Visitable;
 
@@ -160,10 +159,6 @@
 
 			/* Set the left operand to the type of right parameter. */
 			leftOperand.setType(rightOperandList.getTypeServices());
-			//? parameter should pick up the collation type of the schema in
-			//which this statement is getting compiled.
-			leftOperand.setCollationUsingCompilationSchema(
-					StringDataValue.COLLATION_DERIVATION_IMPLICIT);
 		}
 
 		/* Is there a ? parameter on the right? */

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java?view=diff&rev=545319&r1=545318&r2=545319
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java
Thu Jun  7 14:26:23 2007
@@ -25,12 +25,8 @@
 
 import org.apache.derby.iapi.error.StandardException;
 
-import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
-
-import org.apache.derby.iapi.sql.dictionary.DataDictionary;
 import org.apache.derby.iapi.reference.ClassName;
 
-import org.apache.derby.iapi.types.StringDataValue;
 import org.apache.derby.iapi.types.TypeId;
 import org.apache.derby.iapi.types.DataTypeDescriptor;
 import org.apache.derby.iapi.types.DataValueDescriptor;
@@ -44,7 +40,6 @@
 
 import org.apache.derby.impl.sql.compile.ExpressionClassBuilder;
 
-import org.apache.derby.iapi.util.JBitSet;
 import org.apache.derby.iapi.services.classfile.VMOpcode;
 
 import java.lang.reflect.Modifier;
@@ -320,12 +315,6 @@
 					getContextManager());
 
 			DataTypeDescriptor pType = srcVal.getTypeServices();
-			//collation of ? operand should be same as the current schema
-			pType.setCollationDerivation(
-					StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-			pType.setCollationType(
-					getLanguageConnectionContext().getDefaultSchema()
-							.getCollationType());
 			pNode.setDescriptors(new DataTypeDescriptor [] { pType });
 			pNode.setType(pType);
 

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=545319&r1=545318&r2=545319
==============================================================================
--- 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
Jun  7 14:26:23 2007
@@ -21,8 +21,6 @@
 
 package	org.apache.derby.impl.sql.compile;
 
-import org.apache.derby.iapi.services.context.ContextManager;
-
 import org.apache.derby.iapi.error.StandardException;
 
 import org.apache.derby.iapi.sql.compile.CompilerContext;
@@ -36,23 +34,10 @@
 import org.apache.derby.iapi.reference.ClassName;
 
 import org.apache.derby.iapi.types.DataTypeDescriptor;
-import org.apache.derby.iapi.types.StringDataValue;
-
-import org.apache.derby.iapi.sql.execute.ExecRow;
-
-import org.apache.derby.iapi.sql.Activation;
-import org.apache.derby.iapi.types.DataValueDescriptor;
-import org.apache.derby.iapi.sql.Row;
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-import org.apache.derby.iapi.sql.ResultSet;
-import org.apache.derby.iapi.types.TypeId;
-
-import org.apache.derby.iapi.services.loader.GeneratedMethod;
 
 import org.apache.derby.iapi.services.compiler.MethodBuilder;
 import org.apache.derby.iapi.services.compiler.LocalField;
 
-
 import org.apache.derby.iapi.services.sanity.SanityManager;
 
 import org.apache.derby.iapi.store.access.Qualifier;
@@ -64,10 +49,8 @@
 import org.apache.derby.impl.sql.execute.OnceResultSet;
 
 import org.apache.derby.iapi.util.JBitSet;
-import org.apache.derby.iapi.util.ReuseFactory;
 import org.apache.derby.iapi.services.classfile.VMOpcode;
 
-import java.util.Properties;
 import java.util.Vector;
 
 /**
@@ -532,9 +515,6 @@
 		{
 			leftOperand.setType(
 				((ResultColumn) resultColumns.elementAt(0)).getTypeServices());
-			//collation of ? operand should be same as the compilation schema
-			leftOperand.setCollationUsingCompilationSchema(
-					StringDataValue.COLLATION_DERIVATION_IMPLICIT);
 		}
 
 		// Set the DataTypeServices

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=545319&r1=545318&r2=545319
==============================================================================
--- 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
Thu Jun  7 14:26:23 2007
@@ -733,29 +733,37 @@
     JDBC.assertFullResultSet(rs,new String[][] {{"SYSCOLUMNS"}});
 
     //Do parameter testing with IN and subquery
-    //Won't work in territory based database because in 
-    //? IN (SELECT TABLENAME FROM SYS.SYSTABLES)
-    //? will get the collation of the current schema which is a user
-    //schema and hence the collation type of ? will be territory based. 
-    //But the rhs will have collation of system schema which UCS_BASIC. So the 
-    //comparison between left hand side with terriotry based and right hand 
-    //side with UCS_BASIC will fail.
-    checkPreparedStatementError(conn, "SELECT COUNT(*) FROM CUSTOMER WHERE " +
-    		" ? IN (SELECT TABLENAME FROM SYS.SYSTABLES)", "42818");
-    //To fix the problem above, we need to CAST TABLENAME so that the result 
-    //of CAST will pick up the collation of the current schema and this will
-    //cause both the operands of ? IN (SELECT TABLENAME FROM SYS.SYSTABLES) 
-    //to have same collation
-    ps = conn.prepareStatement("SELECT COUNT(*) FROM CUSTOMER WHERE " + 
-		" ? IN (SELECT CAST(TABLENAME AS CHAR(10)) FROM SYS.SYSTABLES)");
+    //Following will work just fine because ? will take it's collation from the
+    //context which in this case will be collation of TABLENAME which has 
+    //collation type of UCS_BASIC. 
+    ps = conn.prepareStatement("SELECT COUNT(*) FROM CUSTOMER WHERE ? IN " +
+    		" (SELECT TABLENAME FROM SYS.SYSTABLES)");
     ps.setString(1, "SYSCOLUMNS");
     rs = ps.executeQuery();
     JDBC.assertFullResultSet(rs,new String[][] {{"7"}});
 
-    //Similar testing for NOT IN
+    //Testing for NOT IN. Following won't work becuase ? is taking the 
+    //collation type from context which will be from the character string
+    //literal 'SYSCOLUMNS'. That literal will have the collation type of the
+    //current schema which is the user schema and hence it's collation type
+    //will be territory based. But that collation does not match the left hand
+    //side on IN clause and hence it results in compliation error.
     checkPreparedStatementError(conn, "SELECT TABLENAME FROM SYS.SYSTABLES " +
     		" WHERE TABLENAME NOT IN (?, ' SYSCOLUMNS ') AND " +
 			" CAST(TABLENAME AS CHAR(10)) = 'SYSCOLUMNS' ", "42818");
+    //We can make the query work in 2 ways
+    //1)Be in the SYS schema and then ? will take the collation of UCS_BASIC
+    //because that is what the character string literal ' SYSCOLUMNS ' has.
+    s.executeUpdate("set schema SYS");
+    ps = conn.prepareStatement("SELECT TABLENAME FROM SYS.SYSTABLES " +
+    		" WHERE TABLENAME NOT IN (?, ' SYSCOLUMNS ') AND " +
+			" CAST(TABLENAME AS CHAR(10)) = 'SYSCOLUMNS' ");
+    ps.setString(1, "aSYSCOLUMNS");
+    rs = ps.executeQuery();
+    JDBC.assertFullResultSet(rs,new String[][] {{"SYSCOLUMNS"}});
+    //2)The other way to fix the query would be to do a CAST on TABLENAME so
+    //it will have the collation of current schema which is APP 
+    s.executeUpdate("set schema APP");
     ps = conn.prepareStatement("SELECT TABLENAME FROM SYS.SYSTABLES WHERE " + 
 	" CAST(TABLENAME AS CHAR(10)) NOT IN (?, ' SYSCOLUMNS ') AND " +
 	" CAST(TABLENAME AS CHAR(10)) = 'SYSCOLUMNS' ");



Mime
View raw message