You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by dj...@apache.org on 2006/08/10 00:38:46 UTC
svn commit: r430170 - in /db/derby/code/trunk/java/engine/org/apache/derby:
iapi/sql/depend/ iapi/sql/dictionary/ impl/sql/depend/ impl/sql/execute/
Author: djd
Date: Wed Aug 9 15:38:46 2006
New Revision: 430170
URL: http://svn.apache.org/viewvc?rev=430170&view=rev
Log:
DERBY-1643 Rename the Dependency manager invalidation constant to represent its use of revoke restrict.
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/depend/DependencyManager.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/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/depend/BasicDependencyManager.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/RoutinePrivilegeInfo.java
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/depend/DependencyManager.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/depend/DependencyManager.java?rev=430170&r1=430169&r2=430170&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/depend/DependencyManager.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/depend/DependencyManager.java Wed Aug 9 15:38:46 2006
@@ -309,11 +309,20 @@
// UPDATE and DELETE privileges. For all these privilege types,
// a revoke statement causes the dependents to drop
public static final int REVOKE_PRIVILEGE = 44;
- //A special action for revoke execute...restrict privilege. This is
- // because when revoke execute ... restrict is issued, the dependents
- // need to throw an exception. As long as there are dependent objects
- // on the execute privilege, the execute privilege can't be revoked.
- public static final int REVOKE_EXECUTE_PRIVILEGE = 45;
+
+ //This special revoke action is for when revoke should fail if
+ // there are dependents on the privilege being revoked. When
+ // such an action type is received by any dependents, they
+ // should throw an exception. Such a form of revoke will succeed
+ // only if there are no dependents on the privilege being revoked.
+ //
+ //Currently, this is supported only for execute privilege on a
+ // routine. In Derby, at this point, execute privilege on a
+ // routine can be revoked only if there are no dependents on
+ // that privilege. So, when a revoke execute..,restrict is
+ // issued, this invalidation action will be sent to all
+ // it's dependents.
+ public static final int REVOKE_PRIVILEGE_RESTRICT = 45;
/**
* Extensions to this interface may use action codes > MAX_ACTION_CODE without fear of
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?rev=430170&r1=430169&r2=430170&view=diff
==============================================================================
--- 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 Wed Aug 9 15:38:46 2006
@@ -554,17 +554,10 @@
case DependencyManager.SET_CONSTRAINTS_DISABLE:
case DependencyManager.SET_TRIGGERS_ENABLE:
case DependencyManager.SET_TRIGGERS_DISABLE:
- //Notice that REVOKE_EXECUTE_PRIVILEGE is not included here.
- //In Derby, at this point, a constraint can't depend on a
- //routine and hence a REVOKE_EXECUTE_PRIVILEGE invalidation
- //action should never be received by a ConstraintDescriptor.
- //Don't know how, but if it ever happened for some mysterious
- //reason, it will be caught in the default: case.
- //
- //For all the other types of revoke privileges, for instance,
- //SELECT, UPDATE, DELETE, INSERT, REFERENCES, TRIGGER, we don't
- //do anything here and later in makeInvalid, we make the
- //ConstraintDescriptor drop itself.
+ //When REVOKE_PRIVILEGE gets sent (this happens for privilege
+ //types SELECT, UPDATE, DELETE, INSERT, REFERENCES, TRIGGER), we
+ //don't do anything here. Later in makeInvalid method, we make
+ //the ConstraintDescriptor drop itself.
case DependencyManager.REVOKE_PRIVILEGE:
break;
@@ -572,6 +565,18 @@
** Currently, the only thing we are depenedent
** on is another constraint or an alias..
*/
+ //Notice that REVOKE_PRIVILEGE_RESTRICT is not caught earlier.
+ //It gets handled in this default: action where an exception
+ //will be thrown. This is because, if such an invalidation
+ //action type is ever received by a dependent, the dependent
+ //should throw an exception.
+ //In Derby, at this point, REVOKE_PRIVILEGE_RESTRICT gets sent
+ //when execute privilege on a routine is getting revoked.
+ //Currently, in Derby, a constraint can't depend on a routine
+ //and hence a REVOKE_PRIVILEGE_RESTRICT invalidation action
+ //should never be received by a ConstraintDescriptor. But this
+ //may change in future and when it does, the code to do the right
+ //thing is already here.
default:
throw StandardException.newException(SQLState.LANG_PROVIDER_HAS_DEPENDENT_OBJECT,
dm.getActionString(action),
@@ -591,16 +596,15 @@
public void makeInvalid(int action, LanguageConnectionContext lcc)
throws StandardException
{
- //Notice that REVOKE_EXECUTE_PRIVILEGE is not included here.
- //This is because, in Derby, at this point, a constraint can't
- //depend on a routine and hence a REVOKE_EXECUTE_PRIVILEGE
- //invalidation action should never be received by a
- //ConstraintDescriptor. Don't know how, but if it ever happened
- //for some mysterious reason, it will be caught in prepareToInvalidate
- //method
+ /*
+ ** For ConstraintDescriptor, SET_CONSTRAINTS/TRIGGERS and
+ * REVOKE_PRIVILEGE are the only valid actions
+ */
+
+ //Let's handle REVOKE_PRIVILEGE first
if (action == DependencyManager.REVOKE_PRIVILEGE)
{
- //At this point (Derby 10.2), only a foreign key constraint can
+ //At this point (Derby 10.2), only a FOREIGN KEY key constraint can
//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.
@@ -615,7 +619,7 @@
}
/*
- ** SET_CONSTRAINTS/TRIGGERS is the only valid action
+ ** Now, handle SET_CONSTRAINTS/TRIGGERS
*/
if ((action != DependencyManager.SET_CONSTRAINTS_DISABLE) &&
(action != DependencyManager.SET_CONSTRAINTS_ENABLE) &&
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?rev=430170&r1=430169&r2=430170&view=diff
==============================================================================
--- 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 Wed Aug 9 15:38:46 2006
@@ -635,23 +635,26 @@
switch (action)
{
/*
- ** We are only dependent on the underlying
- ** table, and our spses. (we should be
- ** dropped before our table is dropped).
+ ** We are only dependent on the underlying table, and our spses and
+ ** privileges on various objects. (we should be dropped before our
+ ** table is dropped. Also, we should be dropped before revoke
+ ** RESTRICT privilege is issued otherwise revoke RESTRICT will
+ ** throw an exception).
+ ** Currently, in Derby, an execute routine privilege can be revoked
+ ** only if there are no dependents on that privilege. When revoke
+ ** execute RESTRICT is exectued, all the dependents will receive
+ ** REVOKE_PRIVILEGE_RESTRICT and they should throw exception.
+ ** We handle this for TriggerDescriptor by throwning an exception
+ ** below. For all the other types of revoke privileges, for
+ ** instance, SELECT, UPDATE, DELETE, INSERT, REFERENCES,
+ ** TRIGGER, we don't do anything here and later in makeInvalid, we
+ ** make the TriggerDescriptor drop itself.
*/
case DependencyManager.DROP_TABLE:
case DependencyManager.DROP_SYNONYM:
case DependencyManager.DROP_SPS:
case DependencyManager.RENAME:
- //Derby supports only RESTRICT form of revoke execute and that
- //means that if there are any dependent objects on execute
- //permission on routine, revoke execute on that routine should
- //fail
- //For all the other types of revoke privileges, for instance,
- //SELECT, UPDATE, DELETE, INSERT, REFERENCES, TRIGGER, we don't
- //do anything here and later in makeInvalid, we make the
- //TriggerDescriptor drop itself.
- case DependencyManager.REVOKE_EXECUTE_PRIVILEGE:
+ case DependencyManager.REVOKE_PRIVILEGE_RESTRICT:
DependencyManager dm = getDataDictionary().getDependencyManager();
throw StandardException.newException(SQLState.LANG_PROVIDER_HAS_DEPENDENT_OBJECT,
dm.getActionString(action),
@@ -686,13 +689,9 @@
// the trigger table, so there is a very large number of actions
// that we would have to check against. This is hard to maintain,
// so don't bother.
-
- //Notice that REVOKE_EXECUTE_PRIVILEGE is not included here.
- //This is because Derby supports only RESTRICT form of revoke
- //execute and that means that if there are any dependent
- //objects on execute permission on routine, revoke execute on
- //that routine should fail. This behvaior for revoke execute
- //gets implemented in prepareToInvalidate method
+ // When REVOKE_PRIVILEGE gets sent (this happens for privilege
+ // types SELECT, UPDATE, DELETE, INSERT, REFERENCES, TRIGGER), we
+ // make the TriggerDescriptor drop itself.
if (action == DependencyManager.REVOKE_PRIVILEGE)
{
DropTriggerConstantAction.dropTriggerDescriptor(
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?rev=430170&r1=430169&r2=430170&view=diff
==============================================================================
--- 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 Wed Aug 9 15:38:46 2006
@@ -268,19 +268,20 @@
*/
case DependencyManager.SET_CONSTRAINTS_ENABLE:
case DependencyManager.SET_TRIGGERS_ENABLE:
- //Notice that REVOKE_EXECUTE_PRIVILEGE is not included here.
- //This is because Derby supports only RESTRICT form of revoke
- //execute and that means that if there are any dependent objects
- //on execute permission on routine, revoke execute on that
- //routine should fail
- //
- //For all the other types of revoke privileges, for instance,
- //SELECT, UPDATE, DELETE, INSERT, REFERENCES, TRIGGER, we don't
- //do anything here and later in makeInvalid, we make the
- //ViewDescriptor drop itself.
+ //When REVOKE_PRIVILEGE gets sent (this happens for privilege
+ //types SELECT, UPDATE, DELETE, INSERT, REFERENCES, TRIGGER), we
+ //don't do anything here. Later in makeInvalid method, we make
+ //the ViewDescriptor drop itself.
case DependencyManager.REVOKE_PRIVILEGE:
break;
+ //Notice that REVOKE_PRIVILEGE_RESTRICT is not caught earlier.
+ //It gets handled in this default: action where an exception
+ //will be thrown. This is because, if such an invalidation
+ //action type is ever received by a dependent, the dependent
+ //show throw an exception.
+ //In Derby, at this point, REVOKE_PRIVILEGE_RESTRICT gets sent
+ //when execute privilege on a routine is getting revoked.
default:
DependencyManager dm;
@@ -306,9 +307,7 @@
{
switch ( action )
{
- /* creating or dropping another publication won't affect
- * this view. so we allow these actions.
- * We don't care about creating or dropping indexes or
+ /* We don't care about creating or dropping indexes or
* alter table on an underlying table.
*/
case DependencyManager.CREATE_INDEX:
@@ -327,12 +326,9 @@
case DependencyManager.TRUNCATE_TABLE:
break;
- //Notice that REVOKE_EXECUTE_PRIVILEGE is not included here.
- //This is because Derby supports only RESTRICT form of revoke
- //execute and that means that if there are any dependent
- //objects on execute permission on routine, revoke execute on
- //that routine should fail. This behvaior for revoke execute
- //gets implemented in prepareToInvalidate method
+ //When REVOKE_PRIVILEGE gets sent (this happens for privilege
+ //types SELECT, UPDATE, DELETE, INSERT, REFERENCES, TRIGGER), we
+ //make the ViewDescriptor drop itself.
case DependencyManager.REVOKE_PRIVILEGE:
dropViewWork(getDataDictionary(),
getDataDictionary().getDependencyManager(), lcc,
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependencyManager.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependencyManager.java?rev=430170&r1=430169&r2=430170&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependencyManager.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependencyManager.java Wed Aug 9 15:38:46 2006
@@ -839,8 +839,8 @@
case REVOKE_PRIVILEGE:
return "REVOKE PRIVILEGE";
- case REVOKE_EXECUTE_PRIVILEGE:
- return "REVOKE EXECUTE PRIVILEGE";
+ case REVOKE_PRIVILEGE_RESTRICT:
+ return "REVOKE PRIVILEGE RESTRICT";
default:
if (SanityManager.DEBUG)
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/RoutinePrivilegeInfo.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/RoutinePrivilegeInfo.java?rev=430170&r1=430169&r2=430170&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/RoutinePrivilegeInfo.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/RoutinePrivilegeInfo.java Wed Aug 9 15:38:46 2006
@@ -79,8 +79,11 @@
for( Iterator itr = grantees.iterator(); itr.hasNext();)
{
String grantee = (String) itr.next();
- if (dd.addRemovePermissionsDescriptor( grant, routinePermsDesc, grantee, tc))
- dd.getDependencyManager().invalidateFor(routinePermsDesc, DependencyManager.REVOKE_EXECUTE_PRIVILEGE, lcc);
+ if (dd.addRemovePermissionsDescriptor( grant, routinePermsDesc, grantee, tc))
+ //Derby currently supports only restrict form of revoke execute
+ //privilege and that is why, we are sending invalidation action
+ //as REVOKE_PRIVILEGE_RESTRICT rather than REVOKE_PRIVILEGE
+ dd.getDependencyManager().invalidateFor(routinePermsDesc, DependencyManager.REVOKE_PRIVILEGE_RESTRICT, lcc);
}
} // end of executeConstantAction