db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1395854 - in /db/derby/code/branches/10.7: ./ java/engine/org/apache/derby/iapi/sql/dictionary/ViewDescriptor.java
Date Tue, 09 Oct 2012 03:49:08 GMT
Author: mamta
Date: Tue Oct  9 03:49:07 2012
New Revision: 1395854

URL: http://svn.apache.org/viewvc?rev=1395854&view=rev
Log:
DERBY-5567 (AlterTableTest#testDropColumn fails: drop view cannot be performed due to dependency)

backporting to 10.7


Modified:
    db/derby/code/branches/10.7/   (props changed)
    db/derby/code/branches/10.7/java/engine/org/apache/derby/iapi/sql/dictionary/ViewDescriptor.java

Propchange: db/derby/code/branches/10.7/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1239898
  Merged /db/derby/code/branches/10.8:r1240258

Modified: db/derby/code/branches/10.7/java/engine/org/apache/derby/iapi/sql/dictionary/ViewDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.7/java/engine/org/apache/derby/iapi/sql/dictionary/ViewDescriptor.java?rev=1395854&r1=1395853&r2=1395854&view=diff
==============================================================================
--- db/derby/code/branches/10.7/java/engine/org/apache/derby/iapi/sql/dictionary/ViewDescriptor.java
(original)
+++ db/derby/code/branches/10.7/java/engine/org/apache/derby/iapi/sql/dictionary/ViewDescriptor.java
Tue Oct  9 03:49:07 2012
@@ -39,7 +39,6 @@ import org.apache.derby.iapi.sql.Stateme
 import org.apache.derby.catalog.DependableFinder;
 import org.apache.derby.catalog.Dependable;
 import org.apache.derby.iapi.services.io.StoredFormatIds;
-import org.apache.derby.impl.sql.execute.DropTriggerConstantAction;
 
 /**
  * This is the implementation of ViewDescriptor. Users of View descriptors
@@ -364,20 +363,28 @@ public final class ViewDescriptor extend
 				// types SELECT, UPDATE, DELETE, INSERT, REFERENCES, TRIGGER),
 				// we make the ViewDescriptor drop itself. REVOKE_ROLE also
 				// drops the dependent view.
+            case DependencyManager.DROP_COLUMN:
 		    case DependencyManager.REVOKE_PRIVILEGE:
-		    case DependencyManager.DROP_COLUMN:
 			case DependencyManager.REVOKE_ROLE:
-				drop(lcc, 
-						getDataDictionary().getTableDescriptor(uuid).getSchemaDescriptor(),
-						getDataDictionary().getTableDescriptor(uuid));
-
-                                lcc.getLastActivation().addWarning(
-                                    StandardException.newWarning(
-                                        SQLState.LANG_VIEW_DROPPED,
-                                        this.getObjectName() ));
-                                return;
+                
+                TableDescriptor td = 
+                        getDataDictionary().getTableDescriptor(uuid);
+                
+                if (td == null) { 
+                    // DERBY-5567 already dropped via another dependency 
+                    break;
+                }
+                
+                // DERBY-5567 keep original action
+                drop(lcc, td.getSchemaDescriptor(), td, action);
+
+                lcc.getLastActivation().addWarning(
+                        StandardException.newWarning(
+                        SQLState.LANG_VIEW_DROPPED,
+                        this.getObjectName() ));
+                break;
 
-		    default:
+            default:
 
 				/* We should never get here, since we can't have dangling references */
 				if (SanityManager.DEBUG)
@@ -414,14 +421,43 @@ public final class ViewDescriptor extend
 		}
 	}
 
-	public void drop(LanguageConnectionContext lcc,
-							  SchemaDescriptor sd, TableDescriptor td)
-		throws StandardException
-	{
+    /**
+     * Drop this descriptor, if not already done.
+     * 
+     * @param lcc current language connection context
+     * @param sd schema descriptor
+     * @param td table descriptor for this view
+     * @throws StandardException standard error policy
+     */
+    public void drop(
+            LanguageConnectionContext lcc,
+            SchemaDescriptor sd,
+            TableDescriptor td) throws StandardException
+    {
+        drop(lcc, sd, td, DependencyManager.DROP_VIEW);
+    }
+
+    /**
+     * Drop this descriptor, if not already done, due to action.
+     * If action is not {@code DependencyManager.DROP_VIEW}, the descriptor is 
+     * dropped due to dropping some other object, e.g. a table column.
+     * 
+     * @param lcc current language connection context
+     * @param sd schema descriptor
+     * @param td table descriptor for this view
+     * @param action action
+     * @throws StandardException standard error policy
+     */
+    private void drop(
+            LanguageConnectionContext lcc,
+            SchemaDescriptor sd,
+            TableDescriptor td,
+            int action) throws StandardException
+    {
         DataDictionary dd = getDataDictionary();
         DependencyManager dm = dd.getDependencyManager();
         TransactionController tc = lcc.getTransactionExecute();
-        
+
 		/* Drop the columns */
 		dd.dropAllColumnDescriptors(td.getUUID(), tc);
 
@@ -430,7 +466,7 @@ public final class ViewDescriptor extend
 		 * cursor referencing a table/view that the user is attempting to
 		 * drop.) If no one objects, then invalidate any dependent objects.
 		 */
-		dm.invalidateFor(td, DependencyManager.DROP_VIEW, lcc);
+        dm.invalidateFor(td, action, lcc);
 
 		/* Clear the dependencies for the view */
 		dm.clearDependencies(lcc, this);
@@ -445,5 +481,8 @@ public final class ViewDescriptor extend
 		dd.dropTableDescriptor(td, sd, tc);
 	}
 
+    public String getName() {
+        return viewName;
+    }
 
 }



Mime
View raw message