db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1378788 - in /db/derby/code/branches/10.8: ./ java/engine/org/apache/derby/impl/store/access/btree/OpenBTree.java java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
Date Thu, 30 Aug 2012 02:09:29 GMT
Author: mamta
Date: Thu Aug 30 02:09:28 2012
New Revision: 1378788

URL: http://svn.apache.org/viewvc?rev=1378788&view=rev
Log:
DERBY-5531 Assert failure when inserting NULL into indexed column with territory-based collation

Backport to 10.8


Modified:
    db/derby/code/branches/10.8/   (props changed)
    db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/store/access/btree/OpenBTree.java
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java

Propchange: db/derby/code/branches/10.8/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1378206

Modified: db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/store/access/btree/OpenBTree.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/store/access/btree/OpenBTree.java?rev=1378788&r1=1378787&r2=1378788&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/store/access/btree/OpenBTree.java
(original)
+++ db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/store/access/btree/OpenBTree.java
Thu Aug 30 02:09:28 2012
@@ -508,6 +508,10 @@ public class OpenBTree 
 
             for (int i = 0; i < row.length; i++)
             {
+            	//DERBY-5531 If the row column's value is null, then 
+            	// don't worry about the data type match.
+            	if (row[i].isNull())
+            		continue;
                 // Compare class's rather than format id's to pick up 
                 // different problems with wrong collation implementation.
 				if (!row[i].getClass().equals(template[i].getClass()))

Modified: db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java?rev=1378788&r1=1378787&r2=1378788&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
(original)
+++ db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
Thu Aug 30 02:09:28 2012
@@ -478,6 +478,40 @@ public void testNorwayCollation() throws
       }
   
 
+/**
+ * DERBY-5531 Assert failure when inserting NULL into indexed column with 
+ *  territory-based collation
+ * Make sure that when the row being inserted has all nulls, we do not run
+ *  into assert failure 
+ * @throws SQLException
+ */
+public void testNullColumnInInsert() throws SQLException {
+    Statement s = createStatement();
+    String collation; 
+
+    ResultSet rs = null;
+    s.executeUpdate("CREATE TABLE derby5531_t1(x varchar(10) unique, y varchar(10))");
+    s.executeUpdate("INSERT INTO derby5531_t1 VALUES(NULL, 'a')");
+    s.executeUpdate("INSERT INTO derby5531_t1 VALUES('1', 'a')");
+    s.executeUpdate("INSERT INTO derby5531_t1 VALUES('2', NULL)");
+    s.executeUpdate("INSERT INTO derby5531_t1 VALUES(NULL, NULL)");
+    s.executeUpdate("INSERT INTO derby5531_t1(x) VALUES(NULL)");
+    s.executeUpdate("INSERT INTO derby5531_t1 VALUES('3', 'b')");
+    rs = s.executeQuery("select * from derby5531_t1 order by x");
+    JDBC.assertFullResultSet(rs,
+      		new String[][] {{"1","a"}, {"2",null}, {"3","b"}, {null,null}, {null,null}, {null,"a"}});
+    s.executeUpdate("DROP TABLE derby5531_t1");
+
+    s.executeUpdate("CREATE TABLE derby5531_t2(x varchar(10) unique)");
+    s.executeUpdate("INSERT INTO derby5531_t2 VALUES(NULL)");
+    s.executeUpdate("INSERT INTO derby5531_t2(x) VALUES(NULL)");
+    s.executeUpdate("INSERT INTO derby5531_t2 VALUES('a')");
+    rs = s.executeQuery("select * from derby5531_t2 order by x");
+    JDBC.assertFullResultSet(rs,
+      		new String[][] {{"a"}, {null}, {null}});
+    s.executeUpdate("DROP TABLE derby5531_t2");
+}
+
   /**
    * Test order by with English collation
    *
@@ -1363,6 +1397,8 @@ public void testMissingCollatorSupport()
         suite.addTest(new CleanDatabaseTestSetup(
                 new CollationTest("testDefaultCollation")));
         suite.addTest(collatedSuite("en", false, "testEnglishCollation"));
+        suite.addTest(collatedSuite("en", true, "testNullColumnInInsert"));
+        suite.addTest(collatedSuite("en", false, "testNullColumnInInsert"));
          
         // Only add tests for other locales if they are in fact supported 
         // by the jvm.



Mime
View raw message