Top Description Inners Constructors Methods
org.apache.derby.impl.sql.execute

pack-priv abstract Class DDLConstantAction

extends Object
implements ConstantAction
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.sql.execute.ConstantAction
Known Direct Subclasses
org.apache.derby.impl.sql.execute.DDLSingleTableConstantAction, org.apache.derby.impl.sql.execute.DropAliasConstantAction, org.apache.derby.impl.sql.execute.DropRoleConstantAction, org.apache.derby.impl.sql.execute.DropSchemaConstantAction, org.apache.derby.impl.sql.execute.DropSequenceConstantAction, org.apache.derby.impl.sql.execute.DropStatisticsConstantAction, org.apache.derby.impl.sql.execute.DropViewConstantAction, org.apache.derby.impl.sql.execute.GrantRoleConstantAction, org.apache.derby.impl.sql.execute.RevokeRoleConstantAction, org.apache.derby.impl.sql.execute.SavepointConstantAction, org.apache.derby.impl.sql.execute.SetConstraintsConstantAction, org.apache.derby.impl.sql.execute.CreateAliasConstantAction, org.apache.derby.impl.sql.execute.CreateRoleConstantAction, org.apache.derby.impl.sql.execute.CreateSchemaConstantAction, org.apache.derby.impl.sql.execute.CreateSequenceConstantAction, org.apache.derby.impl.sql.execute.CreateTableConstantAction, org.apache.derby.impl.sql.execute.CreateViewConstantAction
Imports
java.util.HashMap, .HashSet, .List, org.apache.derby.catalog.AliasInfo, .DependableFinder, .UUID, .TypeDescriptor, org.apache.derby.catalog.types.AggregateAliasInfo, .RoutineAliasInfo, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.iapi.sql.Activation, org.apache.derby.iapi.sql.conn.Authorizer, .LanguageConnectionContext, org.apache.derby.iapi.sql.depend.DependencyManager, .Dependent, .Provider, .ProviderInfo, org.apache.derby.iapi.sql.dictionary.AliasDescriptor, .ColPermsDescriptor, .ColumnDescriptor, .ColumnDescriptorList, .DefaultDescriptor, .DependencyDescriptor, .DataDictionary, .TableDescriptor, .PermissionsDescriptor, .RoleGrantDescriptor, .SchemaDescriptor, .StatementColumnPermission, .StatementPermission, .StatementGenericPermission, .StatementSchemaPermission, .StatementRolePermission, .StatementRoutinePermission, .StatementTablePermission, .RoleClosureIterator, org.apache.derby.iapi.sql.execute.ConstantAction, org.apache.derby.iapi.store.access.ConglomerateController, .TransactionController, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.types.DataTypeDescriptor

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

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
DDLConstantAction.SettableBoolean

Mutable Boolean wrapper, initially false

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
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, TableDescriptor td, ColumnInfo[] columnInfos, boolean dropWholeTable)

Adjust dependencies of a table on ANSI UDTs.

private void
adjustUDTDependencies(LanguageConnectionContext
Interpreter's state variable for this session.
lcc
,
DataDictionary
Metadata
dd
,
Dependent
Object which depends on UDT
dependent
,
HashMap<String, AliasDescriptor>
Map of UDTs for which dependencies should be added
addUdtMap
,
HashMap<String, AliasDescriptor>
Map of UDT for which dependencies should be dropped
dropUdtMap
)

Add and drop dependencies of an object on UDTs.

protected void
adjustUDTDependencies(LanguageConnectionContext
Interpreter's state variable for this session.
lcc
,
DataDictionary
Metadata
dd
,
AliasDescriptor
Alias descriptor for the routine
ad
,
boolean
True if we are adding dependencies, false if we're dropping them
adding
)

Add and drop dependencies of a routine on UDTs.

protected String
constructToString(String statementType, String objectName)

private static void
private static PermissionsDescriptor

Returns:

the permission descriptor that yielded the privilege
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.

pack-priv static SchemaDescriptor

Returns:

the schema descriptor
getAndCheckSchemaDescriptor
(DataDictionary
the data dictionary
dd
,
UUID
the schema id
schemaId
,
String
string describing type of statement for error reporting. e.g. "ALTER STATEMENT"
statementType
)

Get the schema descriptor for the schemaid.

pack-priv static SchemaDescriptor

Returns:

the schema descriptor
getSchemaDescriptorForCreate
(DataDictionary
the data dictionary
dd
,
Activation
activation
activation
,
String
name of the schema
schemaName
)

Get the schema descriptor in the creation of an object in the passed in schema.

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

pack-priv final void
lockTableForDDL(TransactionController
The TransactionController
tc
,
long
The conglomerate number for the heap.
heapConglomerateNumber
,
boolean
Whether or not to lock the table in exclusive mode.
exclusiveMode
)

Lock the table in exclusive or share mode to prevent deadlocks.

protected void
storeConstraintDependenciesOnPrivileges(Activation
The execution environment for this constant action.
activation
,
Dependent
Make this object depend on required privileges
dependent
,
UUID
Make sure we are looking for REFERENCES privilege for right table
refTableUUID
,
ProviderInfo[]
set of providers for this constraint
providers
)

This method saves dependencies of constraints on privileges in the dependency system.

protected void
storeViewTriggerDependenciesOnPrivileges(Activation
The execution environment for this constant action.
activation
,
Dependent
Make this object depend on required privileges
dependent
)

This method saves dependencies of views and triggers on privileges in the dependency system.

private static void
trackRoleDependency(Activation
the current activation
activation
,
Dependent
the view, constraint or trigger that is dependent on the current role for some privilege.
dependent
,
DDLConstantAction.SettableBoolean
keeps track of whether a dependency on the current role has already been registered.
roleDepAdded
)

The statement permission needed for dependent has been found to rely on the current role.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

DDLConstantActionback to summary
pack-priv DDLConstantAction()

Method Detail

addColumnDependenciesback to summary
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.

adjustUDTDependenciesback to summary
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.

adjustUDTDependenciesback to summary
private void adjustUDTDependencies(LanguageConnectionContext lcc, DataDictionary dd, Dependent dependent, HashMap<String, AliasDescriptor> addUdtMap, HashMap<String, AliasDescriptor> dropUdtMap) throws StandardException

Add and drop dependencies of an object on UDTs.

Parameters
lcc:LanguageConnectionContext

Interpreter's state variable for this session.

dd:DataDictionary

Metadata

dependent:Dependent

Object which depends on UDT

addUdtMap:HashMap<String, AliasDescriptor>

Map of UDTs for which dependencies should be added

dropUdtMap:HashMap<String, AliasDescriptor>

Map of UDT for which dependencies should be dropped

adjustUDTDependenciesback to summary
protected void adjustUDTDependencies(LanguageConnectionContext lcc, DataDictionary dd, AliasDescriptor ad, boolean adding) throws StandardException

Add and drop dependencies of a routine on UDTs.

Parameters
lcc:LanguageConnectionContext

Interpreter's state variable for this session.

dd:DataDictionary

Metadata

ad:AliasDescriptor

Alias descriptor for the routine

adding:boolean

True if we are adding dependencies, false if we're dropping them

constructToStringback to summary
protected String constructToString(String statementType, String objectName)
executeCAPreferSubTransback to summary
private static void executeCAPreferSubTrans(CreateSchemaConstantAction csca, TransactionController tc, Activation activation) throws StandardException
findRoleUsageback to summary
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:PermissionsDescriptor

the permission descriptor that yielded the privilege

getAndCheckSchemaDescriptorback to summary
pack-priv static SchemaDescriptor getAndCheckSchemaDescriptor(DataDictionary dd, UUID schemaId, String statementType) throws StandardException

Get the schema descriptor for the schemaid.

Parameters
dd:DataDictionary

the data dictionary

schemaId:UUID

the schema id

statementType:String

string describing type of statement for error reporting. e.g. "ALTER STATEMENT"

Returns:SchemaDescriptor

the schema descriptor

Exceptions
StandardException:
if schema is system schema
getSchemaDescriptorForCreateback to summary
pack-priv static SchemaDescriptor getSchemaDescriptorForCreate(DataDictionary dd, Activation activation, String schemaName) throws StandardException

Get the schema descriptor in the creation of an object in the passed in schema.

Parameters
dd:DataDictionary

the data dictionary

activation:Activation

activation

schemaName:String

name of the schema

Returns:SchemaDescriptor

the schema descriptor

Exceptions
StandardException:
if the schema does not exist
inProviderSetback to summary
private boolean inProviderSet(ProviderInfo[] providers, UUID routineId)
lockTableForDDLback to summary
pack-priv final void lockTableForDDL(TransactionController tc, long heapConglomerateNumber, boolean exclusiveMode) throws StandardException

Lock the table in exclusive or share mode to prevent deadlocks.

Parameters
tc:TransactionController

The TransactionController

heapConglomerateNumber:long

The conglomerate number for the heap.

exclusiveMode:boolean

Whether or not to lock the table in exclusive mode.

Exceptions
StandardException:
if schema is system schema
storeConstraintDependenciesOnPrivilegesback to summary
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:Activation

The execution environment for this constant action.

dependent:Dependent

Make this object depend on required privileges

refTableUUID:UUID

Make sure we are looking for REFERENCES privilege for right table

providers:ProviderInfo[]

set of providers for this constraint

Exceptions
StandardException:
Thrown on failure
storeViewTriggerDependenciesOnPrivilegesback to summary
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:Activation

The execution environment for this constant action.

dependent:Dependent

Make this object depend on required privileges

Exceptions
StandardException:
Thrown on failure
trackRoleDependencyback to summary
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:Activation

the current activation

dependent:Dependent

the view, constraint or trigger that is dependent on the current role for some privilege.

roleDepAdded:DDLConstantAction.SettableBoolean

keeps track of whether a dependency on the current role has already been registered.

org.apache.derby.impl.sql.execute back to summary

private Class DDLConstantAction.SettableBoolean

extends Object
Class Inheritance
  • java.lang.Object
  • org.apache.derby.impl.sql.execute.DDLConstantAction.SettableBoolean

Mutable Boolean wrapper, initially false

Field Summary

Modifier and TypeField and Description
pack-priv boolean

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean
get()

pack-priv void
set(boolean b)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

valueback to summary
pack-priv boolean value

Constructor Detail

SettableBooleanback to summary
pack-priv SettableBoolean()

Method Detail

getback to summary
pack-priv boolean get()
setback to summary
pack-priv void set(boolean b)