db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r634896 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/ engine/org/apache/derby/impl/sql/execute/ testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/
Date Sat, 08 Mar 2008 03:52:20 GMT
Author: mikem
Date: Fri Mar  7 19:52:19 2008
New Revision: 634896

URL: http://svn.apache.org/viewvc?rev=634896&view=rev
Log:
DERBY-3456

Clean up comments and adjust newly added code to match style of
surrounding code.


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ModifyColumnNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DDLSingleTableConstantAction.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ModifyColumnNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ModifyColumnNode.java?rev=634896&r1=634895&r2=634896&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ModifyColumnNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ModifyColumnNode.java
Fri Mar  7 19:52:19 2008
@@ -131,9 +131,11 @@
 	}
 	
 	/**
-	 * If the type of a column is being changed (for mulan, the length of the
-	 * column is being increased then make sure that this does not violate
-	 * any key constraints; 
+     * Check if the the column can be modified, and throw error if not.
+     *
+	 * If the type of a column is being changed (for instance if the length 
+     * of the column is being increased) then make sure that this does not 
+     * violate any key constraints; 
 	 * the column being altered is 
 	 *   1. part of foreign key constraint 
 	 *         ==> ERROR. This references a Primary Key constraint and the
@@ -155,15 +157,16 @@
 			(getNodeType() != C_NodeTypes.MODIFY_COLUMN_CONSTRAINT_NOT_NULL_NODE))
 			return;
 
-		DataDictionary dd = getDataDictionary();
-		ConstraintDescriptorList cdl = dd.getConstraintDescriptors(td);
-		int intArray[] = new int[1];
-		intArray[0] = columnPosition;
+		DataDictionary           dd          = getDataDictionary();
+		ConstraintDescriptorList cdl         = dd.getConstraintDescriptors(td);
+		int                      intArray[]  = new int[1];
+		intArray[0]                          = columnPosition;
 
 		for (int index = 0; index < cdl.size(); index++)
 		{
 			ConstraintDescriptor existingConstraint =
 				                                cdl.elementAt(index);
+
 			if (!(existingConstraint instanceof KeyConstraintDescriptor))
 				continue;
 
@@ -180,21 +183,25 @@
 				(getNodeType() == C_NodeTypes.MODIFY_COLUMN_TYPE_NODE))
 			{
 				throw StandardException.newException(
-					 SQLState.LANG_MODIFY_COLUMN_FKEY_CONSTRAINT, name, existingConstraint.getConstraintName());
+					 SQLState.LANG_MODIFY_COLUMN_FKEY_CONSTRAINT, 
+                     name, existingConstraint.getConstraintName());
 			}	
-			
 			else
 			{
 				//if a column is part of unique constraint it can't be
-				//made nullable in soft upgrade mode
+				//made nullable in soft upgrade mode from a pre-10.4 db.
 				if ((existingConstraint.getConstraintType() == 
-								DataDictionary.UNIQUE_CONSTRAINT)) {
+								DataDictionary.UNIQUE_CONSTRAINT)) 
+                {
 					if (!dd.checkVersion(
 							DataDictionary.DD_VERSION_DERBY_10_4, null))
+                    {
 						throw StandardException.newException(
 								SQLState.LANG_MODIFY_COLUMN_EXISTING_CONSTRAINT,
 								name);
+                    }
 				}
+
 				// a column that is part of a primary key
                 // is being made nullable; can't be done.
 				if ((getNodeType() == 
@@ -202,8 +209,8 @@
 					((existingConstraint.getConstraintType() == 
 					 DataDictionary.PRIMARYKEY_CONSTRAINT)))
 				{
-				throw StandardException.newException(
-					 SQLState.LANG_MODIFY_COLUMN_EXISTING_CONSTRAINT, name);
+                    throw StandardException.newException(
+                         SQLState.LANG_MODIFY_COLUMN_EXISTING_CONSTRAINT, name);
 				}
 				// unique key or primary key.
 				ConstraintDescriptorList 
@@ -212,7 +219,8 @@
 				if (refcdl.size() > 0)
 				{
 					throw StandardException.newException(
-						 SQLState.LANG_MODIFY_COLUMN_REFERENCED, name, refcdl.elementAt(0).getConstraintName());
+						 SQLState.LANG_MODIFY_COLUMN_REFERENCED, 
+                         name, refcdl.elementAt(0).getConstraintName());
 				}
 				
 				// Make the statement dependent on the primary key constraint.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java?rev=634896&r1=634895&r2=634896&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
Fri Mar  7 19:52:19 2008
@@ -26,7 +26,6 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
-import org.apache.derby.catalog.Dependable;
 
 import org.apache.derby.catalog.DependableFinder;
 import org.apache.derby.catalog.IndexDescriptor;
@@ -1052,7 +1051,9 @@
 										boolean nullability)
 		throws StandardException								
 	{
-		LanguageConnectionContext lcc = activation.getLanguageConnectionContext();
+		LanguageConnectionContext lcc = 
+            activation.getLanguageConnectionContext();
+
 		DataDictionary dd = lcc.getDataDictionary();
 		TransactionController tc = lcc.getTransactionExecute();
 
@@ -1064,31 +1065,36 @@
 		DataTypeDescriptor dataType =
             columnDescriptor.getType().getNullabilityType(nullability);
 
-        //check if there any unique constraint to update
+        //check if there are any unique constraints to update
         ConstraintDescriptorList cdl = dd.getConstraintDescriptors(td);
         int columnPostion = columnDescriptor.getPosition();
-        for (int i = 0; i < cdl.size(); i++) {
+        for (int i = 0; i < cdl.size(); i++) 
+        {
             ConstraintDescriptor cd = cdl.elementAt(i);
-            if (cd.getConstraintType() == DataDictionary.UNIQUE_CONSTRAINT) {
+            if (cd.getConstraintType() == DataDictionary.UNIQUE_CONSTRAINT) 
+            {
                 ColumnDescriptorList columns = cd.getColumnDescriptors();
-                for (int count = 0; count < columns.size(); count++) {
-                    if (columns.elementAt(count).getPosition()
-                                                            != columnPostion)
+                for (int count = 0; count < columns.size(); count++) 
+                {
+                    if (columns.elementAt(count).getPosition() != columnPostion)
                         break;
+
                     //get backing index
-                    ConglomerateDescriptor desc 
-                            = td.getConglomerateDescriptor(
-                                    cd.getConglomerateId());
+                    ConglomerateDescriptor desc = 
+                        td.getConglomerateDescriptor(cd.getConglomerateId());
+
                     //check if the backing index was created when the column
                     //not null ie is backed by unique index
                     if (!desc.getIndexDescriptor().isUnique())
                         break;
-                    //need to replace the index
-                    recreateUniqueConstraintBackingIndex (desc, td,
-                            activation, lcc);
+
+                    // replace backing index with a unique when not null index.
+                    recreateUniqueConstraintBackingIndexAsUniqueWhenNotNull(
+                        desc, td, activation, lcc);
                 }
             }
         }
+
 		newColumnDescriptor = 
 			 new ColumnDescriptor(colName,
 									columnDescriptor.getPosition(),
@@ -1099,9 +1105,6 @@
 									columnDescriptor.getDefaultUUID(),
 									columnDescriptor.getAutoincStart(),
 									columnDescriptor.getAutoincInc());
-		
-
-
         
 		// Update the ColumnDescriptor with new default info
 		dd.dropColumnDescriptor(td.getUUID(), colName, tc);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DDLSingleTableConstantAction.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DDLSingleTableConstantAction.java?rev=634896&r1=634895&r2=634896&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DDLSingleTableConstantAction.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DDLSingleTableConstantAction.java
Fri Mar  7 19:52:19 2008
@@ -257,44 +257,61 @@
     
     /**
      * Recreate backing index of unique constraint.
+     *
      * It first drops the existing index and creates it again with 
      * uniqueness set to false and uniqueWhenNotNull set to true. It reuses
      * the uuid so there is no need to update ConstraintDescriptor.
-     * @param cd ConglomerateDescritor to recreate
-     * @param td TableDescriptor for the table on which congDesc exists
-     * @param activation Activation used when creating a new backing
-     *  index (if a new backing index is needed)
-     * @param lcc LanguageConnectionContext used for dropping
+     *
+     * @param cd            ConglomerateDescritor to recreate
+     * @param td            TableDescriptor for table on which congDesc exists
+     * @param activation    Activation used when creating a new backing index 
+     *                      (if a new backing index is needed)
+     * @param lcc           LanguageConnectionContext used for dropping
+     *
      * @throws StandardException
      */
-    void recreateUniqueConstraintBackingIndex (
-            ConglomerateDescriptor  cd,
-            TableDescriptor td,
-            Activation activation, 
-            LanguageConnectionContext lcc) throws StandardException {
-        Properties prop = new Properties ();
+    void recreateUniqueConstraintBackingIndexAsUniqueWhenNotNull(
+    ConglomerateDescriptor      cd,
+    TableDescriptor             td,
+    Activation                  activation, 
+    LanguageConnectionContext   lcc) 
+        throws StandardException 
+    {
         //get index property
+        Properties prop = new Properties ();
         loadIndexProperties(lcc, cd, prop);
         ArrayList list = new ArrayList();
+
+        // drop the existing index.
         dropConglomerate(cd, td, false, list, activation, lcc);
+
+
         String [] cols = cd.getColumnNames();
-        if (cols == null) {
-            //column list wasn't stored in conglomerateDescritor
+        if (cols == null) 
+        {
+            //column list wasn't stored in conglomerateDescriptor
             //fetch is from table descriptor
             int [] pos = cd.getIndexDescriptor().baseColumnPositions();
-            cols = new String [pos.length];
-            for (int i = 0; i < cols.length; i++) {
-                cols [i] = td.getColumnDescriptor(pos [i]).getColumnName();
+            cols       = new String [pos.length];
+
+            for (int i = 0; i < cols.length; i++) 
+            {
+                cols[i] = td.getColumnDescriptor(pos[i]).getColumnName();
             }
         }
         
         //create new index action
         CreateIndexConstantAction action =
-                new CreateIndexConstantAction (false, false, true, 
-                cd.getIndexDescriptor().indexType(), td.getSchemaName(), 
-                cd.getConglomerateName(), td.getName(), td.getUUID(),
-                cols, cd.getIndexDescriptor().isAscending(),
-                true, cd.getUUID(), prop);
+                new CreateIndexConstantAction(
+                        false,          // not part of create table 
+                        false,          // not unique
+                        true,           // create as unique when not null index
+                        cd.getIndexDescriptor().indexType(), 
+                        td.getSchemaName(), 
+                        cd.getConglomerateName(), td.getName(), td.getUUID(),
+                        cols, cd.getIndexDescriptor().isAscending(),
+                        true, cd.getUUID(), prop);
+
         //create index
         action.executeConstantAction(activation);
     }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java?rev=634896&r1=634895&r2=634896&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
Fri Mar  7 19:52:19 2008
@@ -219,7 +219,7 @@
                    //junit tests after checking for the phase of the current
                    //run. 
                    suite.addTest(Changes10_3.suite(phase));
-                 }
+                }
                 if (oldMinor < 4)
                 	suite.addTest(Changes10_4.suite(phase));
             }



Mime
View raw message