db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r1292682 - in /db/derby/code/branches/10.7: ./ java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java
Date Thu, 23 Feb 2012 07:21:50 GMT
Author: kristwaa
Date: Thu Feb 23 07:21:49 2012
New Revision: 1292682

URL: http://svn.apache.org/viewvc?rev=1292682&view=rev
Log:
DERBY-5530: SQLChar.getCollationKey NPE in index-stat-thread

Merged fix from trunk (revision 1243878).

Modified:
    db/derby/code/branches/10.7/   (props changed)
    db/derby/code/branches/10.7/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
    db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java

Propchange: db/derby/code/branches/10.7/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 23 07:21:49 2012
@@ -1,2 +1,2 @@
 /db/derby/code/branches/10.8:1209227-1209228,1209284
-/db/derby/code/trunk:1035603,1036769,1038514,1038813,1039084,1039268,1040658,1041338,1043227,1043389,1044096,1051026,1053724,1055169,1059888,1060480,1062096,1063809,1065061,1066290,1067250,1067357,1069661,1071463,1071886,1076335,1076387,1078461,1078608,1078693,1081072,1081455,1081568,1085078,1091000,1097247,1103681,1103718,1128243,1129136,1130632,1130895,1131272,1132664,1136363,1138341,1138444,1139449,1141924,1164370,1203050,1207729,1208775,1209228
+/db/derby/code/trunk:1035603,1036769,1038514,1038813,1039084,1039268,1040658,1041338,1043227,1043389,1044096,1051026,1053724,1055169,1059888,1060480,1062096,1063809,1065061,1066290,1067250,1067357,1069661,1071463,1071886,1076335,1076387,1078461,1078608,1078693,1081072,1081455,1081568,1085078,1091000,1097247,1103681,1103718,1128243,1129136,1130632,1130895,1131272,1132664,1136363,1138341,1138444,1139449,1141924,1164370,1203050,1207729,1208775,1209228,1243878

Modified: db/derby/code/branches/10.7/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.7/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java?rev=1292682&r1=1292681&r2=1292682&view=diff
==============================================================================
--- db/derby/code/branches/10.7/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
(original)
+++ db/derby/code/branches/10.7/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
Thu Feb 23 07:21:49 2012
@@ -2507,9 +2507,10 @@ class AlterTableConstantAction extends D
 
 			for (int index = 0; index < numIndexes; index++)
 			{
+                IndexRowGenerator curIndex = compressIRGs[index];
 				// create a single index row template for each index
-				indexRows[index] = compressIRGs[index].getIndexRowTemplate();
-				compressIRGs[index].getIndexRow(emptyHeapRow, 
+                indexRows[index] = curIndex.getIndexRowTemplate();
+                curIndex.getIndexRow(emptyHeapRow, 
 											  rl, 
 											  indexRows[index],
 											  (FormatableBitSet) null);
@@ -2518,15 +2519,15 @@ class AlterTableConstantAction extends D
 				 * No need to try to enforce uniqueness here as
 				 * index should be valid.
 				 */
-				int[] baseColumnPositions = 
-                    compressIRGs[index].baseColumnPositions();
+                int[] baseColumnPositions = curIndex.baseColumnPositions();
 
-				boolean[] isAscending = compressIRGs[index].isAscending();
+                boolean[] isAscending = curIndex.isAscending();
 
 				int numColumnOrderings;
 				numColumnOrderings = baseColumnPositions.length + 1;
 				ordering[index]    = new ColumnOrdering[numColumnOrderings];
-                collation[index]   = new int[baseColumnPositions.length + 1];
+                collation[index]   = curIndex.getColumnCollationIds(
+                                                td.getColumnDescriptorList());
 
 				for (int ii =0; ii < numColumnOrderings - 1; ii++) 
 				{

Modified: db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java?rev=1292682&r1=1292681&r2=1292682&view=diff
==============================================================================
--- db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java
(original)
+++ db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java
Thu Feb 23 07:21:49 2012
@@ -1783,6 +1783,39 @@ public class CollationTest2 extends Base
     }
 
     /**
+     * Tests that truncating a table with indexes leaves us with a valid set
+     * of conglomerates.
+     */
+    private void runDerby5530TruncateIndex()
+            throws SQLException {
+        setAutoCommit(false);
+        Statement s = createStatement();
+        s.executeUpdate("create table d5530i (val varchar(10))");
+        s.executeUpdate("create index idx on d5530i(val)");
+        s.executeUpdate("truncate table d5530i");
+        s.executeUpdate("insert into d5530i values 'one', 'two'");
+        ResultSet rs = s.executeQuery("select * from d5530i");
+        JDBC.assertUnorderedResultSet(rs, new String[][] {{"one"}, {"two"}});
+        rollback();
+    }
+
+    /**
+     * Tests that truncating a table without indexes leaves us with a valid
+     * conglomerate.
+     */
+    private void runDerby5530TruncateNoIndex()
+            throws SQLException {
+        setAutoCommit(false);
+        Statement s = createStatement();
+        s.executeUpdate("create table d5530 (val varchar(10))");
+        s.executeUpdate("truncate table d5530");
+        s.executeUpdate("insert into d5530 values 'one', 'two'");
+        ResultSet rs = s.executeQuery("select * from d5530");
+        JDBC.assertUnorderedResultSet(rs, new String[][] {{"one"}, {"two"}});
+        rollback();
+    }
+
+    /**
      * Shared code to run all test cases against a single collation.
      * <p>
      * Pass in the index of which TEST_DATABASE database to test.  So
@@ -1849,6 +1882,8 @@ public class CollationTest2 extends Base
 
         runLikeTests(db_index);
 
+        runDerby5530TruncateNoIndex();
+        runDerby5530TruncateIndex();
 
         /*
         TODO -MIKEM, this test does not work yet.



Mime
View raw message