db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r514416 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/sql/dictionary/ impl/sql/execute/
Date Sun, 04 Mar 2007 15:53:10 GMT
Author: djd
Date: Sun Mar  4 07:53:09 2007
New Revision: 514416

URL: http://svn.apache.org/viewvc?view=rev&rev=514416
Log:
DERBY-2397 (partial) Move the drop logic for TriggerDecsriptor and ViewDescriptor to be centralized
in each class as an instance method. The methods do not yet have a common signature,
more investigation is needed for the ViewDescriptor's relationship to its TableDescriptor.
Added some comments to CreateViewNode to describe the set of descriptors and dependencies
it creates.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TriggerDescriptor.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ViewDescriptor.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/CreateViewConstantAction.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropTableConstantAction.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropTriggerConstantAction.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropViewConstantAction.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericConstantActionFactory.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TriggerDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TriggerDescriptor.java?view=diff&rev=514416&r1=514415&r2=514416
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TriggerDescriptor.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TriggerDescriptor.java
Sun Mar  4 07:53:09 2007
@@ -30,12 +30,14 @@
 
 import org.apache.derby.iapi.reference.SQLState;
 import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.sql.Activation;
 import org.apache.derby.iapi.sql.StatementType;
 import org.apache.derby.catalog.DependableFinder;
 import org.apache.derby.catalog.Dependable;
 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.iapi.store.access.TransactionController;
 import org.apache.derby.iapi.services.context.ContextService;
 
 import org.apache.derby.impl.sql.execute.DropTriggerConstantAction;
@@ -702,10 +704,7 @@
 			// types SELECT, UPDATE, DELETE, INSERT, REFERENCES, TRIGGER), we  
 			// make the TriggerDescriptor drop itself. 
 			case DependencyManager.REVOKE_PRIVILEGE:
-				DropTriggerConstantAction.dropTriggerDescriptor(
-					lcc, getDataDictionary().getDependencyManager(),
-					getDataDictionary(), lcc.getTransactionExecute(), this,
-					null);
+                drop(lcc);
 				break;
 
 			default:
@@ -713,6 +712,38 @@
 		}
 		
 	}
+    
+    public void drop(LanguageConnectionContext   lcc) throws StandardException
+    {
+        DataDictionary dd = getDataDictionary();
+        DependencyManager dm = getDataDictionary().getDependencyManager();
+        TransactionController tc = lcc.getTransactionExecute();
+
+        dm.invalidateFor(this, DependencyManager.DROP_TRIGGER, lcc);
+
+        // Drop the trigger
+        dd.dropTriggerDescriptor(this, tc);
+
+        // Clear the dependencies for the trigger 
+        dm.clearDependencies(lcc, this);
+
+        // Drop the spses
+        SPSDescriptor spsd = dd.getSPSDescriptor(this.getActionId());
+
+        // there shouldn't be any dependencies, but in case
+        // there are, lets clear them
+        dm.invalidateFor(spsd, DependencyManager.DROP_TRIGGER, lcc);
+        dm.clearDependencies(lcc, spsd);
+        dd.dropSPSDescriptor(spsd, tc);
+        
+        if (getWhenClauseId() != null)
+        {   
+            spsd = dd.getSPSDescriptor(getWhenClauseId());
+            dm.invalidateFor(spsd, DependencyManager.DROP_TRIGGER, lcc);
+            dm.clearDependencies(lcc, spsd);
+            dd.dropSPSDescriptor(spsd, tc);
+        }
+    }
 
 
 	//////////////////////////////////////////////////////////////

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ViewDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ViewDescriptor.java?view=diff&rev=514416&r1=514415&r2=514416
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ViewDescriptor.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ViewDescriptor.java
Sun Mar  4 07:53:09 2007
@@ -337,11 +337,9 @@
 			//make the ViewDescriptor drop itself. 
 		    case DependencyManager.REVOKE_PRIVILEGE:
 		    case DependencyManager.DROP_COLUMN:
-				dropViewWork(getDataDictionary(), 
-						getDataDictionary().getDependencyManager(), lcc,
-						lcc.getTransactionExecute(), 
+				drop(lcc, 
 						getDataDictionary().getTableDescriptor(uuid).getSchemaDescriptor(),
-						getDataDictionary().getTableDescriptor(uuid), false);
+						getDataDictionary().getTableDescriptor(uuid));
 
                                 lcc.getLastActivation().addWarning(
                                     StandardException.newWarning(
@@ -386,11 +384,14 @@
 		}
 	}
 
-	public void dropViewWork(DataDictionary dd, DependencyManager dm,
-							  LanguageConnectionContext lcc, TransactionController tc,
-							  SchemaDescriptor sd, TableDescriptor td, boolean cascade)
+	public void drop(LanguageConnectionContext lcc,
+							  SchemaDescriptor sd, TableDescriptor td)
 		throws StandardException
 	{
+        DataDictionary dd = getDataDictionary();
+        DependencyManager dm = dd.getDependencyManager();
+        TransactionController tc = lcc.getTransactionExecute();
+        
 		/* Drop the columns */
 		dd.dropAllColumnDescriptors(td.getUUID(), tc);
 

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=514416&r1=514415&r2=514416
==============================================================================
--- 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
Sun Mar  4 07:53:09 2007
@@ -766,7 +766,7 @@
 				{
 					if (cascade)
 					{
-						DropTriggerConstantAction.dropTriggerDescriptor(lcc, dm, dd, tc, trd, activation);
+                        trd.drop(lcc);
 						activation.addWarning(
 							StandardException.newWarning(SQLState.LANG_TRIGGER_DROPPED,
 								trd.getName(), td.getName()));

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CreateViewConstantAction.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CreateViewConstantAction.java?view=diff&rev=514416&r1=514415&r2=514416
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CreateViewConstantAction.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CreateViewConstantAction.java
Sun Mar  4 07:53:09 2007
@@ -51,6 +51,20 @@
 /**
  *	This class  describes actions that are ALWAYS performed for a
  *	CREATE VIEW Statement at Execution time.
+ *  A view is represented as:
+ *  <UL>
+ *  <LI> TableDescriptor with the name of the view and type VIEW_TYPE
+ *  <LI> Set of ColumnDescriptor's for the column names and types
+ *  <LI> ViewDescriptor describing the SQL query that makes up the view.
+ *  </UL>
+ *  Dependencies are created as:
+ *  <UL>
+ *  <LI> ViewDescriptor depends on the Providers that its compiled
+ *  query depends on.
+ *  <LI> ViewDescriptor depends on the privileges required to execute the view.
+ *  </UL>
+ *  Note there are no dependencies created between the ViewDescriptor, TableDecriptor
+ *  and the ColumnDescriptor's.
  *
  *	@author Jerry Brenner.
  */
@@ -72,14 +86,13 @@
 	 *	Make the ConstantAction for a CREATE VIEW statement.
 	 *
 	 *  @param schemaName			name for the schema that view lives in.
-	 *  @param tableName	Name of table.
-	 *  @param tableType	Type of table (e.g., BASE).
+	 *  @param tableName	Name of view.
+	 *  @param tableType	Type of table (ie. TableDescriptor.VIEW_TYPE).
 	 *	@param viewText		Text of query expression for view definition
 	 *  @param checkOption	Check option type
 	 *  @param columnInfo	Information on all the columns in the table.
 	 *  @param providerInfo Information on all the Providers
 	 *  @param compSchemaId 	Compilation Schema Id
-	 *		 (REMIND tableDescriptor ignored)
 	 */
 	CreateViewConstantAction(
 								String			schemaName,
@@ -117,7 +130,7 @@
 
 
 	/**
-	 *	This is the guts of the Execution-time logic for CREATE TABLE.
+	 *	This is the guts of the Execution-time logic for CREATE VIEW.
 	 *
 	 *	@see ConstantAction#executeConstantAction
 	 *
@@ -128,7 +141,6 @@
 	{
 		TableDescriptor 			td;
 		UUID 						toid;
-		SchemaDescriptor			schemaDescriptor;
 		ColumnDescriptor			columnDescriptor;
 		ViewDescriptor				vd;
 

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=514416&r1=514415&r2=514416
==============================================================================
--- 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
Sun Mar  4 07:53:09 2007
@@ -193,7 +193,7 @@
 		while (descs.hasMoreElements())
 		{
 			TriggerDescriptor trd = (TriggerDescriptor) descs.nextElement();
-			DropTriggerConstantAction.dropTriggerDescriptor(lcc, dm, dd, tc, trd, activation);	
+            trd.drop(lcc);
 		}
 
 		/* Drop all defaults */

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropTriggerConstantAction.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropTriggerConstantAction.java?view=diff&rev=514416&r1=514415&r2=514416
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropTriggerConstantAction.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropTriggerConstantAction.java
Sun Mar  4 07:53:09 2007
@@ -89,8 +89,6 @@
 
 		LanguageConnectionContext lcc = activation.getLanguageConnectionContext();
 		DataDictionary dd = lcc.getDataDictionary();
-		DependencyManager dm = dd.getDependencyManager();
-
 
 		/*
 		** Inform the data dictionary that we are about to write to it.
@@ -139,48 +137,7 @@
 		** cursor referencing a table/trigger that the user is attempting to
 		** drop.) If no one objects, then invalidate any dependent objects.
 		*/
-		dropTriggerDescriptor(lcc, dm, dd, tc, triggerd, activation);
-	}
-
-	public static void dropTriggerDescriptor
-	(
-		LanguageConnectionContext	lcc,
-		DependencyManager 			dm,
-		DataDictionary				dd,
-		TransactionController		tc,
-		TriggerDescriptor			triggerd,
-		Activation					activation
-	) throws StandardException
-	{
-		if (SanityManager.DEBUG)
-		{
-			SanityManager.ASSERT(triggerd!=null, "trigger descriptor is null");
-		}
-
-		dm.invalidateFor(triggerd, DependencyManager.DROP_TRIGGER, lcc);
-
-		// Drop the trigger
-		dd.dropTriggerDescriptor(triggerd, tc);
-
-		// Clear the dependencies for the trigger 
-		dm.clearDependencies(lcc, triggerd);
-
-		// Drop the spses
-		SPSDescriptor spsd = dd.getSPSDescriptor(triggerd.getActionId());
-
-		// there shouldn't be any dependencies, but in case
-		// there are, lets clear them
-		dm.invalidateFor(spsd, DependencyManager.DROP_TRIGGER, lcc);
-		dm.clearDependencies(lcc, spsd);
-		dd.dropSPSDescriptor(spsd, tc);
-		
-		if (triggerd.getWhenClauseId() != null)
-		{	
-			spsd = dd.getSPSDescriptor(triggerd.getWhenClauseId());
-			dm.invalidateFor(spsd, DependencyManager.DROP_TRIGGER, lcc);
-			dm.clearDependencies(lcc, spsd);
-			dd.dropSPSDescriptor(spsd, tc);
-		}
+        triggerd.drop(lcc);
 	}
 
 	public String toString()

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropViewConstantAction.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropViewConstantAction.java?view=diff&rev=514416&r1=514415&r2=514416
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropViewConstantAction.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropViewConstantAction.java
Sun Mar  4 07:53:09 2007
@@ -101,8 +101,6 @@
 
 		LanguageConnectionContext lcc = activation.getLanguageConnectionContext();
 		DataDictionary dd = lcc.getDataDictionary();
-		DependencyManager dm = dd.getDependencyManager();
-		TransactionController tc = lcc.getTransactionExecute();
 
 		/*
 		** Inform the data dictionary that we are about to write to it.
@@ -133,6 +131,6 @@
 
 		vd = dd.getViewDescriptor(td);
 
-		vd.dropViewWork(dd, dm, lcc, tc, sd, td, false);
+		vd.drop(lcc, sd, td);
 	}
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericConstantActionFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericConstantActionFactory.java?view=diff&rev=514416&r1=514415&r2=514416
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericConstantActionFactory.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericConstantActionFactory.java
Sun Mar  4 07:53:09 2007
@@ -314,7 +314,7 @@
 	 *
 	 *  @param schemaName	Name of the schema that table lives in.
 	 *  @param tableName	Name of table.
-	 *  @param tableType	Type of table (e.g., BASE).
+	 *  @param tableType	Type of table (in this case TableDescriptor.VIEW_TYPE).
 	 *	@param viewText		Text of query expression for view definition
 	 *  @param checkOption	Check option type
 	 *  @param columnInfo	Information on all the columns in the table.



Mime
View raw message