db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r539071 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/sql/dictionary/ engine/org/apache/derby/impl/sql/catalog/ engine/org/apache/derby/impl/sql/execute/ storeless/org/apache/derby/impl/storeless/
Date Thu, 17 May 2007 18:31:34 GMT
Author: djd
Date: Thu May 17 11:31:32 2007
New Revision: 539071

URL: http://svn.apache.org/viewvc?view=rev&rev=539071
Log:
DERBY-2397 (partial) Move drop code for constraints and indexes into their descriptors
as drop() methods instead of static methods in constant actions.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/CheckConstraintDescriptor.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ConglomerateDescriptor.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ConstraintDescriptor.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DataDictionary.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.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/DropConstraintConstantAction.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropIndexConstantAction.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropTableConstantAction.java
    db/derby/code/trunk/java/storeless/org/apache/derby/impl/storeless/EmptyDictionary.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/CheckConstraintDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/CheckConstraintDescriptor.java?view=diff&rev=539071&r1=539070&r2=539071
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/CheckConstraintDescriptor.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/CheckConstraintDescriptor.java
Thu May 17 11:31:32 2007
@@ -22,8 +22,11 @@
 package org.apache.derby.iapi.sql.dictionary;
 import org.apache.derby.catalog.ReferencedColumns;
 import org.apache.derby.catalog.UUID;
+import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.services.sanity.SanityManager;
 import org.apache.derby.iapi.sql.StatementType;
+import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
+import org.apache.derby.iapi.store.access.TransactionController;
 
 /**
  * This class represents a check constraint descriptor.
@@ -31,8 +34,8 @@
  */
 public class CheckConstraintDescriptor extends ConstraintDescriptor
 {
-	ReferencedColumns	referencedColumns;
-	String						constraintText;
+	private ReferencedColumns	referencedColumns;
+	private String						constraintText;
 
 	CheckConstraintDescriptor(
 		    DataDictionary dataDictionary,
@@ -159,7 +162,7 @@
 	
 		// if update, only relevant if columns intersect
 		return doColumnsIntersect(modifiedCols, getReferencedColumns());
-	}
+	}   
 
 	/**
 	 * Convert the CheckConstraintDescriptor to a String.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ConglomerateDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ConglomerateDescriptor.java?view=diff&rev=539071&r1=539070&r2=539071
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ConglomerateDescriptor.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ConglomerateDescriptor.java
Thu May 17 11:31:32 2007
@@ -342,6 +342,16 @@
 	/** @see TupleDescriptor#getDescriptorName */
 	public String getDescriptorName() { return name; }
     
+    /**
+     * Drop this ConglomerateDescriptor when it represents
+     * an index. If this is the last desciptor for
+     * a physical index then the physical index (conglomerate)
+     * and its descriptor will be dropped.
+     * 
+     * @param lcc
+     * @param td
+     * @throws StandardException
+     */
 	public void drop(LanguageConnectionContext lcc,
 	        TableDescriptor td)
 	throws StandardException

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ConstraintDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ConstraintDescriptor.java?view=diff&rev=539071&r1=539070&r2=539071
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ConstraintDescriptor.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ConstraintDescriptor.java
Thu May 17 11:31:32 2007
@@ -35,8 +35,7 @@
 import org.apache.derby.iapi.services.io.StoredFormatIds;
 import org.apache.derby.iapi.sql.depend.DependencyManager;
 import	org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
-
-import org.apache.derby.impl.sql.execute.DropConstraintConstantAction;
+import org.apache.derby.iapi.store.access.TransactionController;
 
 /**
  * This class is used to get information from a ConstraintDescriptor.
@@ -607,13 +606,7 @@
 			//depend on a privilege. None of the other constraint types 
 			//can be dependent on a privilege becuse those constraint types
 			//can not reference a table/routine.
-			DropConstraintConstantAction.dropConstraintAndIndex(
-					getDataDictionary().getDependencyManager(),
-					table,
-					getDataDictionary(),
-					this,
-					lcc.getTransactionExecute(),
-					lcc, true);
+			drop(lcc, true);
 			return;
 		}
 
@@ -642,6 +635,69 @@
 			}
 		}
 	}
+    
+    /**
+     * Drop the constraint.  Clears dependencies, drops 
+     * the backing index and removes the constraint
+     * from the list on the table descriptor.  Does NOT
+     * do an dm.invalidateFor()
+     */
+    public void drop(LanguageConnectionContext lcc,
+            boolean clearDependencies)
+        throws StandardException
+    {       
+        DataDictionary dd = getDataDictionary();
+        DependencyManager dm = dd.getDependencyManager();
+        TransactionController tc = lcc.getTransactionExecute();
+
+        if (clearDependencies)
+        {
+            dm.clearDependencies(lcc, this);
+        }
+
+        /* Drop the constraint.
+         * NOTE: This must occur before dropping any backing index, since
+         * a user is not allowed to drop a backing index without dropping
+         * the constraint.
+         */
+        dd.dropConstraintDescriptor(this, tc);
+
+        /* Drop the index, if there's one for this constraint.
+         * NOTE: There will always be an indexAction. We don't
+         * force the constraint to exist at bind time, so we always
+         * generate one.
+         */
+        if (hasBackingIndex())
+        {
+
+            // it may have duplicates, and we drop a backing index
+            // Bug 4307
+            // We need to get the conglomerate descriptors from the 
+            // dd in case we dropped other constraints in a cascade operation. 
+             ConglomerateDescriptor[]conglomDescs =
+                 dd.getConglomerateDescriptors(getConglomerateId());
+
+            if (conglomDescs.length != 0)
+            {
+                // Typically there is only one ConglomerateDescriptor
+                // for a given UUID, but due to an old bug
+                // there may be more than one. If there is more
+                // than one then which one is remvoed does not
+                // matter since they will all have the same critical
+                // information since they point to the same physical index.
+                for (int i = 0; i < conglomDescs.length; i++)
+                {
+                    if (conglomDescs[i].isConstraint())
+                    {
+                        conglomDescs[i].drop(lcc, table);
+                        break;
+                    }
+                }
+            }
+        }
+
+        table.removeConstraintDescriptor(this);
+    }
 	
 	/** @see TupleDescriptor#getDescriptorName */
 	public String getDescriptorName() { return constraintName; }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DataDictionary.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DataDictionary.java?view=diff&rev=539071&r1=539070&r2=539071
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DataDictionary.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DataDictionary.java
Thu May 17 11:31:32 2007
@@ -808,8 +808,7 @@
 						throws StandardException;
 
 	/**
-	 * Drops the given ConstraintDescriptor that is associated
-	 * with the given table and constraint type from the data dictionary.
+	 * Drops the given ConstraintDescriptor from the data dictionary.
 	 *
 	 * NOTE: Caller is responsible for dropping any backing index
 	 *
@@ -820,7 +819,7 @@
 	 *
 	 * @exception StandardException		Thrown on failure
 	 */
-	public void	dropConstraintDescriptor(TableDescriptor table,
+	public void	dropConstraintDescriptor(
 			ConstraintDescriptor descriptor,
 			TransactionController tc)
 						throws StandardException;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java?view=diff&rev=539071&r1=539070&r2=539071
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
Thu May 17 11:31:32 2007
@@ -4944,17 +4944,14 @@
 	}
 
 	/**
-	 * Drops the given ConstraintDescriptor that is associated
-	 * with the given table and constraint type from the data dictionary.
+	 * Drops the given ConstraintDescriptor from the data dictionary.
 	 *
-	 * @param table	The table from which to drop the
-	 *			constraint descriptor
 	 * @param descriptor	The descriptor to drop
 	 * @param tc			The TransactionController
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public void	dropConstraintDescriptor(TableDescriptor table,
+	public void	dropConstraintDescriptor(
 			ConstraintDescriptor descriptor,
 			TransactionController tc)
 		throws StandardException
@@ -5015,7 +5012,7 @@
 		for (Iterator iterator = cdl.iterator(); iterator.hasNext(); )
 		{
 			ConstraintDescriptor cd = (ConstraintDescriptor) iterator.next();
-			dropConstraintDescriptor(table, cd, tc);
+			dropConstraintDescriptor(cd, tc);
 		}
 
 		/*
@@ -8223,7 +8220,7 @@
 				//record the new timestamp
 				if (timeNow > timeForLastSystemSQLName) {
 					systemSQLNameNumber = 0;
-					calendarForLastSystemSQLName.setTime(new Date(timeNow));
+					calendarForLastSystemSQLName.setTimeInMillis(timeNow);
 					timeForLastSystemSQLName = timeNow;
 				} else { 
 					//the request has come at the same time as the last generated name request
@@ -8237,7 +8234,7 @@
 						systemSQLNameNumber = 0;
 						timeForLastSystemSQLName = timeForLastSystemSQLName + 10L;
 						//increment the timestamp for system generated names by 10ms
-            calendarForLastSystemSQLName.setTime(new Date(timeForLastSystemSQLName));
+                        calendarForLastSystemSQLName.setTimeInMillis(timeForLastSystemSQLName);
 					}
 				}
 

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?view=diff&rev=539071&r1=539070&r2=539071
==============================================================================
--- 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
Thu May 17 11:31:32 2007
@@ -836,7 +836,7 @@
 			{
 				if ((cd instanceof CheckConstraintDescriptor) && changed)
 				{
-					dd.dropConstraintDescriptor(td, cd, tc);
+					dd.dropConstraintDescriptor(cd, tc);
 					for (j = 0; j < numRefCols; j++)
 					{
 						if (referencedColumns[j] > droppedColumnPosition)
@@ -870,8 +870,7 @@
 			// drop now in all other cases
 			dm.invalidateFor(cd, DependencyManager.DROP_CONSTRAINT,
 									lcc);
-			DropConstraintConstantAction.dropConstraintAndIndex(dm, td, dd,
-							 cd, tc, lcc, true);
+            cd.drop(lcc, true);
 
 			activation.addWarning(
                 StandardException.newWarning(SQLState.LANG_CONSTRAINT_DROPPED,
@@ -881,8 +880,7 @@
 		for (int i = tbr_size - 1; i >= 0; i--)
 		{
 			ConstraintDescriptor cd = toBeRemoved[i];
-			DropConstraintConstantAction.dropConstraintAndIndex(
-                dm, td, dd, cd, tc, lcc, false);
+			cd.drop(lcc, false);
 
 			activation.addWarning(
                 StandardException.newWarning(SQLState.LANG_CONSTRAINT_DROPPED,
@@ -900,8 +898,7 @@
 									DependencyManager.DROP_CONSTRAINT,
 									lcc);
 
-					DropConstraintConstantAction.dropConstraintAndIndex(
-						dm, fkcd.getTableDescriptor(), dd, fkcd, tc, lcc, true);
+                    fkcd.drop(lcc, true);
 
 					activation.addWarning(
                         StandardException.newWarning(

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropConstraintConstantAction.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropConstraintConstantAction.java?view=diff&rev=539071&r1=539070&r2=539071
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropConstraintConstantAction.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropConstraintConstantAction.java
Thu May 17 11:31:32 2007
@@ -227,7 +227,7 @@
 		** be repeatedly changing the reference count of the referenced
 		** key and generating unnecessary I/O.
 		*/
-		dropConstraintAndIndex(dm, td, dd, conDesc, tc, lcc, !cascadeOnRefKey);
+        conDesc.drop(lcc, !cascadeOnRefKey);
 
 		if (cascadeOnRefKey) 
 		{
@@ -243,8 +243,7 @@
 			{
 				fkcd = (ForeignKeyConstraintDescriptor) cdl.elementAt(index);
 				dm.invalidateFor(fkcd, DependencyManager.DROP_CONSTRAINT, lcc);
-				dropConstraintAndIndex(dm, fkcd.getTableDescriptor(), dd, fkcd,
-								tc, lcc, true);
+				fkcd.drop(lcc, true);
 			}
 	
 			/*
@@ -255,72 +254,5 @@
 			dm.invalidateFor(conDesc, DependencyManager.DROP_CONSTRAINT, lcc);
 			dm.clearDependencies(lcc, conDesc);
 		}
-	}
-
-	/*
-	 * Drop the constraint.  Clears dependencies, drops 
-	 * the backing index and removes the constraint
-	 * from the list on the table descriptor.  Does NOT
-	 * do an dm.invalidateFor()
-	 */
-	public static void dropConstraintAndIndex(DependencyManager	dm,
-								TableDescriptor 		td,
-								DataDictionary 			dd,
-								ConstraintDescriptor 	conDesc,
-								TransactionController 	tc,
-								LanguageConnectionContext lcc,
-								boolean					clearDependencies)
-		throws StandardException
-	{
-		if (SanityManager.DEBUG)
-		{
-			SanityManager.ASSERT(tc != null, "tc is null");
-			SanityManager.ASSERT(td != null, "td is null");
-		}
-
-		if (clearDependencies)
-		{
-			dm.clearDependencies(lcc, conDesc);
-		}
-
-		/* Drop the constraint.
-		 * NOTE: This must occur before dropping any backing index, since
-		 * a user is not allowed to drop a backing index without dropping
-		 * the constraint.
-		 */
-		dd.dropConstraintDescriptor(td, conDesc, tc);
-
-		/* Drop the index, if there's one for this constraint.
-		 * NOTE: There will always be an indexAction. We don't
-		 * force the constraint to exist at bind time, so we always
-		 * generate one.
-		 */
-		if (conDesc.hasBackingIndex())
-		{
-			ConglomerateDescriptor[] conglomDescs;
-
-			// it may have duplicates, and we drop a backing index
-			// Bug 4307
-			// We need to get the conglomerate descriptors from the 
-			// dd in case we dropped other constraints in a cascade operation. 
-			conglomDescs = dd.getConglomerateDescriptors(
-							conDesc.getConglomerateId());
-
-			if (conglomDescs.length != 0)
-			{
-				for (int i = 0; i < conglomDescs.length; i++)
-				{
-					if (conglomDescs[i].isConstraint())
-					{
-						DropIndexConstantAction.dropIndex(dm, dd, tc,
-													conglomDescs[i], td, 
-													lcc);
-						break;
-					}
-				}
-			}
-		}
-
-		td.removeConstraintDescriptor(conDesc);
 	}
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropIndexConstantAction.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropIndexConstantAction.java?view=diff&rev=539071&r1=539070&r2=539071
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropIndexConstantAction.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropIndexConstantAction.java
Thu May 17 11:31:32 2007
@@ -173,45 +173,4 @@
 
 		cd.drop(lcc, td);
 	}
-
-	public static void dropIndex(DependencyManager 	dm,
-							DataDictionary			dd,
-							TransactionController	tc,
-							ConglomerateDescriptor	cd,
-							TableDescriptor			td,
-							LanguageConnectionContext lcc)
-		throws StandardException
-	{	
-		if (SanityManager.DEBUG)
-		{
-			SanityManager.ASSERT(tc != null, "tc is null");
-			SanityManager.ASSERT(cd != null, "cd is null");
-		}
-
-		// only drop the conglomerate if no similar index but with different
-		// name. Get from dd in case we drop other dup indexes with a cascade operation
-
-		if (dd.getConglomerateDescriptors(cd.getConglomerateNumber()).length == 1)
-		{
-			/* Drop statistics */
-			dd.dropStatisticsDescriptors(td.getUUID(), cd.getUUID(), tc);
-
-			/* Drop the conglomerate */
-			tc.dropConglomerate(cd.getConglomerateNumber());
-		}
-
-		// invalidate any prepared statements that
-		// depended on the index (including this one)
-		dm.invalidateFor(cd, DependencyManager.DROP_INDEX, lcc);
-
-		/* Drop the conglomerate descriptor */
-		dd.dropConglomerateDescriptor(cd, tc);
-
-		/* 
-		** Remove the conglomerate descriptor from the list hanging off of the
-		** table descriptor
-		*/
-		td.removeConglomerateDescriptor(cd);
-	}
-
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropTableConstantAction.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropTableConstantAction.java?view=diff&rev=539071&r1=539070&r2=539071
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropTableConstantAction.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropTableConstantAction.java
Thu May 17 11:31:32 2007
@@ -312,8 +312,7 @@
 			}
 
 			dm.invalidateFor(cd, DependencyManager.DROP_CONSTRAINT, lcc);
-			DropConstraintConstantAction.dropConstraintAndIndex(dm, td, dd, cd, 
-						tc, lcc, true);
+			cd.drop(lcc, true);
 		}
 
 		/*
@@ -344,8 +343,7 @@
 			** Pass in false to dropConstraintsAndIndex so it
 			** doesn't clear dependencies, we'll do that ourselves.
 			*/
-			DropConstraintConstantAction.dropConstraintAndIndex(dm, td, dd, cd, 
-						tc, lcc, false);
+			cd.drop(lcc, false);
 
 			/*
 			** If we are going to cascade, get all the
@@ -368,9 +366,7 @@
 				{
 					fkcd = (ConstraintDescriptor) fkcdl.elementAt(inner);
 					dm.invalidateFor(fkcd, DependencyManager.DROP_CONSTRAINT, lcc);
-					DropConstraintConstantAction.dropConstraintAndIndex(
-							dm, fkcd.getTableDescriptor(), dd, fkcd,
-							tc, lcc, true);
+					fkcd.drop(lcc, true);
 					activation.addWarning(
 						StandardException.newWarning(SQLState.LANG_CONSTRAINT_DROPPED,
  							fkcd.getConstraintName(),

Modified: db/derby/code/trunk/java/storeless/org/apache/derby/impl/storeless/EmptyDictionary.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/storeless/org/apache/derby/impl/storeless/EmptyDictionary.java?view=diff&rev=539071&r1=539070&r2=539071
==============================================================================
--- db/derby/code/trunk/java/storeless/org/apache/derby/impl/storeless/EmptyDictionary.java
(original)
+++ db/derby/code/trunk/java/storeless/org/apache/derby/impl/storeless/EmptyDictionary.java
Thu May 17 11:31:32 2007
@@ -320,8 +320,8 @@
 
 	}
 
-	public void dropConstraintDescriptor(TableDescriptor table,
-			ConstraintDescriptor descriptor, TransactionController tc)
+	public void dropConstraintDescriptor(
+            ConstraintDescriptor descriptor, TransactionController tc)
 			throws StandardException {
 		// TODO Auto-generated method stub
 



Mime
View raw message