Class DDLConstantAction
- java.lang.Object
-
- 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
Nested Classes Modifier and Type Class Description private static class
DDLConstantAction.SettableBoolean
Mutable Boolean wrapper, initially false
-
Field Summary
-
Fields inherited from interface org.apache.derby.iapi.sql.execute.ConstantAction
WHEN_MATCHED_THEN_DELETE, WHEN_MATCHED_THEN_UPDATE, WHEN_NOT_MATCHED_THEN_INSERT
-
-
Constructor Summary
Constructors Constructor Description DDLConstantAction()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addColumnDependencies(LanguageConnectionContext lcc, DataDictionary dd, TableDescriptor td, ColumnInfo ci)
Add dependencies of a column on providers.private void
adjustUDTDependencies(LanguageConnectionContext lcc, DataDictionary dd, Dependent dependent, java.util.HashMap<java.lang.String,AliasDescriptor> addUdtMap, java.util.HashMap<java.lang.String,AliasDescriptor> dropUdtMap)
Add and drop dependencies of an object on UDTs.protected void
adjustUDTDependencies(LanguageConnectionContext lcc, DataDictionary dd, AliasDescriptor ad, boolean adding)
Add and drop dependencies of a routine 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
-
-
-
-
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 dictionaryschemaId
- the schema idstatementType
- 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 dictionaryactivation
- activationschemaName
- 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 TransactionControllerheapConglomerateNumber
- 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 privilegesrefTableUUID
- Make sure we are looking for REFERENCES privilege for right tableproviders
- 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 activationdependent
- the view, constraint or trigger that is dependent on the current role for some privilege.roleDepAdded
- keeps track of whether a dependency on the current role has already 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<java.lang.String,AliasDescriptor> addUdtMap, java.util.HashMap<java.lang.String,AliasDescriptor> dropUdtMap) throws StandardException
Add and drop dependencies of an object on UDTs.- Parameters:
lcc
- Interpreter's state variable for this session.dd
- Metadatadependent
- Object which depends on UDTaddUdtMap
- Map of UDTs for which dependencies should be addeddropUdtMap
- 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
- Metadataad
- Alias descriptor for the routineadding
- True if we are adding dependencies, false if we're dropping them- Throws:
StandardException
-
-