Class DDLStatementNode
java.lang.Object
org.apache.derby.impl.sql.compile.QueryTreeNode
org.apache.derby.impl.sql.compile.StatementNode
org.apache.derby.impl.sql.compile.DDLStatementNode
- All Implemented Interfaces:
Visitable
- Direct Known Subclasses:
AlterTableNode
,CreateAliasNode
,CreateIndexNode
,CreateRoleNode
,CreateSchemaNode
,CreateSequenceNode
,CreateTableNode
,CreateTriggerNode
,CreateViewNode
,DropAliasNode
,DropIndexNode
,DropRoleNode
,DropSchemaNode
,DropSequenceNode
,DropTableNode
,DropTriggerNode
,DropViewNode
,GrantNode
,GrantRoleNode
,RenameNode
,RevokeNode
,RevokeRoleNode
,SavepointNode
A DDLStatementNode represents any type of DDL statement: CREATE TABLE,
CREATE INDEX, ALTER TABLE, etc.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
(package private) boolean
sub-classes can set this to be true to allow implicit creation of the main object's schema at execution time.private boolean
static final int
static final int
private TableName
static final int
static final int
Fields inherited from class org.apache.derby.impl.sql.compile.StatementNode
EMPTY_TD_LIST, NEED_CURSOR_ACTIVATION, NEED_DDL_ACTIVATION, NEED_NOTHING_ACTIVATION, NEED_PARAM_ACTIVATION, NEED_ROW_ACTIVATION
Fields inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_CYCLE, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
Accept a visitor on all child nodes.(package private) int
private TableDescriptor
checkTableDescriptor
(TableDescriptor td, boolean doSystemTableCheck) (package private) final void
generate
(ActivationClassBuilder acb, MethodBuilder mb) Generic generate code for all DDL statements.(package private) String
Return the full dot expression name of the object being dropped.final TableName
(package private) String
Return the name of the table being dropped.protected final SchemaDescriptor
Get a schema descriptor for this DDL object.protected final SchemaDescriptor
getSchemaDescriptor
(boolean ownerCheck, boolean doSystemSchemaCheck) Get a schema descriptor for this DDL object.protected final TableDescriptor
protected final TableDescriptor
getTableDescriptor
(boolean doSystemTableCheck) Validate that the table is ok for DDL -- e.g.protected final TableDescriptor
getTableDescriptor
(UUID tableId) protected final TableDescriptor
getTableDescriptor
(TableName tableName) Validate that the table is ok for DDL -- e.g.protected void
initAndCheck
(Object objectName) Initialize the object name we will be performing the DDL on and check that we are not in the system schema and that DDL is allowed.boolean
isAtomic()
A DDL statement is always atomicprivate TableDescriptor
justGetDescriptor
(TableName tableName) Just get the table descriptor.(package private) FromList
makeFromList
(DataDictionary dd, TableElementList tableElementList, boolean creatingTable) Make a from list for binding query fragments in a CREATE/ALTER TABLE statement.toString()
Convert this object to a String.Methods inherited from class org.apache.derby.impl.sql.compile.StatementNode
bindStatement, executeSchemaName, executeStatementName, generate, getCursorInfo, getSPSName, lockTableForCompilation, makeResultDescription, needsSavepoint, optimizeStatement, statementToString, updateIndexStatisticsFor
Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
accept, addTag, addUDTUsagePriv, addUDTUsagePriv, bindOffsetFetch, bindRowMultiSet, bindUserCatalogType, bindUserType, checkReliability, checkReliability, convertDefaultNode, copyTagsFrom, createTypeDependency, debugFlush, debugPrint, disablePrivilegeCollection, formatNodeString, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContext, getContextManager, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getLongProperty, getNullNode, getOffsetOrderedNodes, getOptimizerFactory, getOptimizerTracer, getParameterTypes, getSchemaDescriptor, getSchemaDescriptor, getStatementType, getTableDescriptor, getTypeCompiler, getUDTDesc, isPrivilegeCollectionRequired, isSessionSchema, isSessionSchema, makeConstantAction, makeTableName, makeTableName, nodeHeader, optimizerTracingIsOn, orReliability, parseSearchCondition, parseStatement, printLabel, printSubNodes, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setEndOffset, setRefActionInfo, stackPrint, taggedWith, treePrint, treePrint, verifyClassExist
-
Field Details
-
UNKNOWN_TYPE
public static final int UNKNOWN_TYPE- See Also:
-
ADD_TYPE
public static final int ADD_TYPE- See Also:
-
DROP_TYPE
public static final int DROP_TYPE- See Also:
-
MODIFY_TYPE
public static final int MODIFY_TYPE- See Also:
-
LOCKING_TYPE
public static final int LOCKING_TYPE- See Also:
-
UPDATE_STATISTICS
public static final int UPDATE_STATISTICS- See Also:
-
DROP_STATISTICS
public static final int DROP_STATISTICS- See Also:
-
tableName
-
initOk
private boolean initOk -
implicitCreateSchema
boolean implicitCreateSchemasub-classes can set this to be true to allow implicit creation of the main object's schema at execution time.
-
-
Constructor Details
-
DDLStatementNode
DDLStatementNode(TableName tableName, ContextManager cm) -
DDLStatementNode
DDLStatementNode(ContextManager cm)
-
-
Method Details
-
initAndCheck
Initialize the object name we will be performing the DDL on and check that we are not in the system schema and that DDL is allowed.- Throws:
StandardException
-
isAtomic
public boolean isAtomic()A DDL statement is always atomic- Overrides:
isAtomic
in classStatementNode
- Returns:
- true
-
getRelativeName
String getRelativeName()Return the name of the table being dropped. This is the unqualified table name.- Returns:
- the relative name
-
getFullName
String getFullName()Return the full dot expression name of the object being dropped.- Returns:
- the full name
-
getObjectName
-
toString
Convert this object to a String. See comments in QueryTreeNode.java for how this should be done for tree printing.- Overrides:
toString
in classStatementNode
- Returns:
- This object as a String
-
activationKind
int activationKind()- Specified by:
activationKind
in classStatementNode
-
generate
Generic generate code for all DDL statements.- Overrides:
generate
in classQueryTreeNode
- Parameters:
acb
- The ActivationClassBuilder for the class being builtmb
- The execute() method to be built- Throws:
StandardException
- Thrown on error
-
getSchemaDescriptor
Get a schema descriptor for this DDL object. Uses this.objectName. Always returns a schema, we lock in the schema name prior to execution. Checks if current authorizationID is owner of the schema.- Returns:
- Schema Descriptor
- Throws:
StandardException
- throws on schema name that doesn't exist
-
getSchemaDescriptor
protected final SchemaDescriptor getSchemaDescriptor(boolean ownerCheck, boolean doSystemSchemaCheck) throws StandardException Get a schema descriptor for this DDL object. Uses this.objectName. Always returns a schema, we lock in the schema name prior to execution. The most common call to this method is with 2nd parameter true which says that SchemaDescriptor should not be requested for system schema. The only time this method will get called with 2nd parameter set to false will be when user has requested for inplace compress using SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE Above inplace compress can be invoked on system tables. A call to SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE internally gets translated into ALTER TABLE sql. When ALTER TABLE is executed for SYSCS_INPLACE_COMPRESS_TABLE, we want to allow SchemaDescriptor request for system tables. DERBY-1062- Parameters:
ownerCheck
- If check for schema owner is neededdoSystemSchemaCheck
- If check for system schema is needed. If set to true, then throw an exception if schema descriptor is requested for a system schema. The only time this param will be set to false is when user is asking for inplace compress of a system table. DERBY-1062- Returns:
- Schema Descriptor
- Throws:
StandardException
- throws on schema name that doesn't exist
-
getTableDescriptor
- Throws:
StandardException
-
getTableDescriptor
protected final TableDescriptor getTableDescriptor(boolean doSystemTableCheck) throws StandardException Validate that the table is ok for DDL -- e.g. that it exists, it is not a view. It is ok for it to be a system table. Also check that its schema is ok. Currently, the only time this method is called is when user has asked for inplace compress. eg call SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE('SYS','SYSTABLES',1,1,1); Inplace compress is allowed on both system and user tables.- Returns:
- the validated table descriptor, never null
- Throws:
StandardException
- on error
-
getTableDescriptor
- Throws:
StandardException
-
getTableDescriptor
Validate that the table is ok for DDL -- e.g. that it exists, it is not a view, and is not a system table, and that its schema is ok.- Returns:
- the validated table descriptor, never null
- Throws:
StandardException
- on error
-
justGetDescriptor
Just get the table descriptor. Don't worry if it belongs to a view, system table, synonym or a real table. Let the caller decide what to do.- Parameters:
tableName
-- Returns:
- TableDescriptor for the give TableName
- Throws:
StandardException
- on error
-
checkTableDescriptor
private TableDescriptor checkTableDescriptor(TableDescriptor td, boolean doSystemTableCheck) throws StandardException - Throws:
StandardException
-
makeFromList
FromList makeFromList(DataDictionary dd, TableElementList tableElementList, boolean creatingTable) throws StandardException Make a from list for binding query fragments in a CREATE/ALTER TABLE statement.- Parameters:
dd
- Metadata.tableElementList
- the parenthesized list of columns and constraints in a CREATE/ALTER TABLE statementcreatingTable
- true if this is for CREATE TABLE. false if this is for ALTER TABLE- Throws:
StandardException
-
acceptChildren
Description copied from class:QueryTreeNode
Accept a visitor on all child nodes. All sub-classes that add fields that should be visited, should override this method and callaccept(v)
on all visitable fields, as well assuper.acceptChildren(v)
to make sure all visitable fields defined by the super-class are accepted too.- Overrides:
acceptChildren
in classQueryTreeNode
- Parameters:
v
- the visitor- Throws:
StandardException
- on errors raised by the visitor
-