db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r545593 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/IsNullNode.java testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
Date Fri, 08 Jun 2007 18:55:45 GMT
Author: mamta
Date: Fri Jun  8 11:55:42 2007
New Revision: 545593

URL: http://svn.apache.org/viewvc?view=rev&rev=545593
Log:
DERBY-2777
Fixed the combination of IS NULL and parameters so that the parameters take their collation
from the context and not from the current
compilation schema. Also, the earlier checkin for test case of CONCATENATION was incorrect.
This commit fixes that too.


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IsNullNode.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/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=545593&r1=545592&r2=545593
==============================================================================
--- 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 Fri
Jun  8 11:55:42 2007
@@ -143,12 +143,12 @@
 		** If IS [NOT] NULL has a ? operand, we assume
 		** its type is varchar with the implementation-defined maximum length
 		** for a varchar.
+		** Also, for IS [NOT] NULL, it doesn't matter what is VARCHAR's 
+		** collation (since for NULL check, no collation sensitive processing
+		** is required) and hence we will not worry about the collation setting
 		*/
 
 		operand.setType(new DataTypeDescriptor(TypeId.getBuiltInTypeId(Types.VARCHAR), true));
-		//collation of ? operand should be same as the compilation schema
-		operand.setCollationUsingCompilationSchema(
-				StringDataValue.COLLATION_DERIVATION_IMPLICIT);
 	}
 
 	/* RelationalOperator interface */

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=545593&r1=545592&r2=545593
==============================================================================
--- 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 11:55:42 2007
@@ -26,6 +26,7 @@
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.sql.Types;
 
 import javax.sql.DataSource;
 
@@ -725,17 +726,32 @@
     //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");   
+    		" WHERE TABLENAME || ? LIKE 'SYSCOLUMNS '", "42ZA2");   
     //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 '");   
+    		" CAST((TABLENAME || ?) AS CHAR(20)) LIKE '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");   
+    ps = conn.prepareStatement("SELECT TABLENAME FROM SYS.SYSTABLES " +
+    		" WHERE TABLENAME || ? LIKE 'SYSCOLUMNS'");   
     s.executeUpdate("set schema APP");
+
+    //Do parameter testing for IS NULL
+    //Following query will pass because it doesn't matter what the collation of
+    //? is when doing a NULL check
+    ps = conn.prepareStatement("SELECT TABLENAME FROM SYS.SYSTABLES WHERE " +
+    		" ? IS NULL");   
+    ps.setString(1, " ");
+    rs = ps.executeQuery();
+	JDBC.assertEmpty(rs);
+	//Now do the testing for IS NOT NULL
+    ps = conn.prepareStatement("SELECT TABLENAME FROM SYS.SYSTABLES WHERE " +
+    		" ? IS NOT NULL");
+    ps.setNull(1, java.sql.Types.VARCHAR);
+    rs = ps.executeQuery();
+    JDBC.assertEmpty(rs);
 
     
     //Do parameter testing with COALESCE



Mime
View raw message