org.apache.derby.impl.sql.execute
Class DDLConstantAction

java.lang.Object
  extended by org.apache.derby.impl.sql.execute.DDLConstantAction
All Implemented Interfaces:
ConstantAction
Direct Known Subclasses:
CreateAliasConstantAction, CreateRoleConstantAction, CreateSchemaConstantAction, CreateSequenceConstantAction, CreateTableConstantAction, CreateViewConstantAction, DDLSingleTableConstantAction, DropAliasConstantAction, DropRoleConstantAction, DropSchemaConstantAction, DropSequenceConstantAction, DropStatisticsConstantAction, DropViewConstantAction, GrantRoleConstantAction, RevokeRoleConstantAction, SavepointConstantAction, SetConstraintsConstantAction

abstract class DDLConstantAction
extends java.lang.Object
implements ConstantAction

Abstract class that has actions that are across all DDL actions.


Nested Class Summary
private  class DDLConstantAction.SettableBoolean
          Mutable Boolean wrapper, initially false
 
Constructor Summary
DDLConstantAction()
           
 
Method Summary
protected  void addColumnDependencies(LanguageConnectionContext lcc, DataDictionary dd, TableDescriptor td, ColumnInfo ci)
          Add dependencies of a column on providers.
protected  void adjustUDTDependencies(LanguageConnectionContext lcc, DataDictionary dd, AliasDescriptor ad, boolean adding)
          Add and drop dependencies of a routine on UDTs.
private  void adjustUDTDependencies(LanguageConnectionContext lcc, DataDictionary dd, Dependent dependent, java.util.HashMap addUdtMap, java.util.HashMap dropUdtMap)
          Add and drop dependencies of an object on UDTs.
protected  void adjustUDTDependencies(LanguageConnectionContext lcc, DataDictionary dd, TableDescriptor td, ColumnInfo[] columnInfos, boolean dropWholeTable)
          Adjust dependencies of a table on ANSI UDTs.
protected  java.lang.String constructToString(java.lang.String statementType, java.lang.String objectName)
           
private static void executeCAPreferSubTrans(CreateSchemaConstantAction csca, TransactionController tc, Activation activation)
           
private static PermissionsDescriptor findRoleUsage(Activation activation, StatementPermission statPerm)
          We have determined that the statement permission described by statPerm is not granted to the current user nor to PUBLIC, so it must be granted to the current role or one of the roles inherited by the current role.
(package private) static SchemaDescriptor getAndCheckSchemaDescriptor(DataDictionary dd, UUID schemaId, java.lang.String statementType)
          Get the schema descriptor for the schemaid.
(package private) static SchemaDescriptor getSchemaDescriptorForCreate(DataDictionary dd, Activation activation, java.lang.String schemaName)
          Get the schema descriptor in the creation of an object in the passed in schema.
private  boolean inProviderSet(ProviderInfo[] providers, UUID routineId)
           
(package private)  void lockTableForDDL(TransactionController tc, long heapConglomerateNumber, boolean exclusiveMode)
          Lock the table in exclusive or share mode to prevent deadlocks.
protected  void storeConstraintDependenciesOnPrivileges(Activation activation, Dependent dependent, UUID refTableUUID, ProviderInfo[] providers)
          This method saves dependencies of constraints on privileges in the dependency system.
protected  void storeViewTriggerDependenciesOnPrivileges(Activation activation, Dependent dependent)
          This method saves dependencies of views and triggers on privileges in the dependency system.
private static void trackRoleDependency(Activation activation, Dependent dependent, DDLConstantAction.SettableBoolean roleDepAdded)
          The statement permission needed for dependent has been found to rely on the current role.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.derby.iapi.sql.execute.ConstantAction
executeConstantAction
 

Constructor Detail

DDLConstantAction

DDLConstantAction()
Method Detail

getAndCheckSchemaDescriptor

static SchemaDescriptor getAndCheckSchemaDescriptor(DataDictionary dd,
                                                    UUID schemaId,
                                                    java.lang.String statementType)
                                             throws StandardException
Get the schema descriptor for the schemaid.

Parameters:
dd - the data dictionary
schemaId - the schema id
statementType - string describing type of statement for error reporting. e.g. "ALTER STATEMENT"
Returns:
the schema descriptor
Throws:
StandardException - if schema is system schema

getSchemaDescriptorForCreate

static SchemaDescriptor getSchemaDescriptorForCreate(DataDictionary dd,
                                                     Activation activation,
                                                     java.lang.String schemaName)
                                              throws StandardException
Get the schema descriptor in the creation of an object in the passed in schema.

Parameters:
dd - the data dictionary
activation - activation
schemaName - name of the schema
Returns:
the schema descriptor
Throws:
StandardException - if the schema does not exist

executeCAPreferSubTrans

private static void executeCAPreferSubTrans(CreateSchemaConstantAction csca,
                                            TransactionController tc,
                                            Activation activation)
                                     throws StandardException
Throws:
StandardException

lockTableForDDL

final void lockTableForDDL(TransactionController tc,
                           long heapConglomerateNumber,
                           boolean exclusiveMode)
                    throws StandardException
Lock the table in exclusive or share mode to prevent deadlocks.

Parameters:
tc - The TransactionController
heapConglomerateNumber - The conglomerate number for the heap.
exclusiveMode - Whether or not to lock the table in exclusive mode.
Throws:
StandardException - if schema is system schema

constructToString

protected java.lang.String constructToString(java.lang.String statementType,
                                             java.lang.String objectName)

storeConstraintDependenciesOnPrivileges

protected void storeConstraintDependenciesOnPrivileges(Activation activation,
                                                       Dependent dependent,
                                                       UUID refTableUUID,
                                                       ProviderInfo[] providers)
                                                throws StandardException
This method saves dependencies of constraints on privileges in the dependency system. It gets called by CreateConstraintConstantAction. Views and triggers and constraints run with definer's privileges. If one of the required privileges is revoked from the definer, the dependent view/trigger/constraint on that privilege will be dropped automatically. In order to implement this behavior, we need to save view/trigger/constraint dependencies on required privileges in the dependency system. Following method accomplishes that part of the equation for constraints only. The dependency collection for constraints is not same as for views and triggers and hence constraints are handled by this special method. Views and triggers can depend on many different kind of privileges where as constraints only depend on REFERENCES privilege on a table (FOREIGN KEY constraints) or EXECUTE privileges on one or more functions (CHECK constraints). Another difference is only one view or trigger can be defined by a sql statement and hence all the dependencies collected for the sql statement apply to the view or trigger in question. As for constraints, one sql statement can defined multiple constraints and hence the all the privileges required by the statement are not necessarily required by all the constraints defined by that sql statement. We need to identify right privileges for right constraints for a given sql statement. Because of these differences between constraints and views (and triggers), there are 2 different methods in this class to save their privileges in the dependency system. For each required privilege, we now register a dependency on a role if that role was required to find an applicable privilege.

Parameters:
activation - The execution environment for this constant action.
dependent - Make this object depend on required privileges
refTableUUID - Make sure we are looking for REFERENCES privilege for right table
providers - set of providers for this constraint
Throws:
StandardException - Thrown on failure

findRoleUsage

private static PermissionsDescriptor findRoleUsage(Activation activation,
                                                   StatementPermission statPerm)
                                            throws StandardException
We have determined that the statement permission described by statPerm is not granted to the current user nor to PUBLIC, so it must be granted to the current role or one of the roles inherited by the current role. Find the relevant permission descriptor and return it.

Returns:
the permission descriptor that yielded the privilege
Throws:
StandardException

trackRoleDependency

private static void trackRoleDependency(Activation activation,
                                        Dependent dependent,
                                        DDLConstantAction.SettableBoolean roleDepAdded)
                                 throws StandardException
The statement permission needed for dependent has been found to rely on the current role. If not already done, register the dependency so that if the current role (or any of the roles it inherits) is revoked (or dropped), we can invalidate dependent.

Parameters:
activation - the current activation
dependent - the view, constraint or trigger that is dependent on the current role for some privilege.
roleDepAdded - keeps track of whether a dependeny on the current role has aleady been registered.
Throws:
StandardException

storeViewTriggerDependenciesOnPrivileges

protected void storeViewTriggerDependenciesOnPrivileges(Activation activation,
                                                        Dependent dependent)
                                                 throws StandardException
This method saves dependencies of views and triggers on privileges in the dependency system. It gets called by CreateViewConstantAction and CreateTriggerConstantAction. Views and triggers and constraints run with definer's privileges. If one of the required privileges is revoked from the definer, the dependent view/trigger/constraint on that privilege will be dropped automatically. In order to implement this behavior, we need to save view/trigger/constraint dependencies on required privileges in the dependency system. Following method accomplishes that part of the equation for views and triggers. The dependency collection for constraints is not same as for views and triggers and hence constraints are not covered by this method. Views and triggers can depend on many different kind of privileges where as constraints only depend on REFERENCES privilege on a table. Another difference is only one view or trigger can be defined by a sql statement and hence all the dependencies collected for the sql statement apply to the view or trigger in question. As for constraints, one sql statement can defined multiple constraints and hence the all the privileges required by the statement are not necessarily required by all the constraints defined by that sql statement. We need to identify right privileges for right constraints for a given sql statement. Because of these differences between constraints and views (and triggers), there are 2 different methods in this class to save their privileges in the dependency system. For each required privilege, we now register of a dependency on a role if that role was required to find an applicable privilege.

Parameters:
activation - The execution environment for this constant action.
dependent - Make this object depend on required privileges
Throws:
StandardException - Thrown on failure

inProviderSet

private boolean inProviderSet(ProviderInfo[] providers,
                              UUID routineId)

addColumnDependencies

protected void addColumnDependencies(LanguageConnectionContext lcc,
                                     DataDictionary dd,
                                     TableDescriptor td,
                                     ColumnInfo ci)
                              throws StandardException
Add dependencies of a column on providers. These can arise if a generated column depends on a user created function.

Throws:
StandardException

adjustUDTDependencies

protected void adjustUDTDependencies(LanguageConnectionContext lcc,
                                     DataDictionary dd,
                                     TableDescriptor td,
                                     ColumnInfo[] columnInfos,
                                     boolean dropWholeTable)
                              throws StandardException
Adjust dependencies of a table on ANSI UDTs. We only add one dependency between a table and a UDT. If the table already depends on the UDT, we don't add a redundant dependency.

Throws:
StandardException

adjustUDTDependencies

private void adjustUDTDependencies(LanguageConnectionContext lcc,
                                   DataDictionary dd,
                                   Dependent dependent,
                                   java.util.HashMap addUdtMap,
                                   java.util.HashMap dropUdtMap)
                            throws StandardException
Add and drop dependencies of an object on UDTs.

Parameters:
lcc - Interpreter's state variable for this session.
dd - Metadata
dependent - Object which depends on UDT
addUdtMap - Map of UDTs for which dependencies should be added
dropUdtMap - Map of UDT for which dependencies should be dropped
Throws:
StandardException

adjustUDTDependencies

protected void adjustUDTDependencies(LanguageConnectionContext lcc,
                                     DataDictionary dd,
                                     AliasDescriptor ad,
                                     boolean adding)
                              throws StandardException
Add and drop dependencies of a routine on UDTs.

Parameters:
lcc - Interpreter's state variable for this session.
dd - Metadata
ad - Alias descriptor for the routine
adding - True if we are adding dependencies, false if we're dropping them
Throws:
StandardException

Built on Thu 2012-03-29 21:53:33+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.