Top Description Fields Constructors Methods
org.apache.derby.impl.sql.compile

pack-priv abstract Class DDLStatementNode

extends StatementNode
Class Inheritance
Known Direct Subclasses
org.apache.derby.impl.sql.compile.CreateSchemaNode, org.apache.derby.impl.sql.compile.RevokeRoleNode, org.apache.derby.impl.sql.compile.DropAliasNode, org.apache.derby.impl.sql.compile.DropIndexNode, org.apache.derby.impl.sql.compile.DropRoleNode, org.apache.derby.impl.sql.compile.DropSchemaNode, org.apache.derby.impl.sql.compile.DropSequenceNode, org.apache.derby.impl.sql.compile.DropTableNode, org.apache.derby.impl.sql.compile.DropTriggerNode, org.apache.derby.impl.sql.compile.DropViewNode, org.apache.derby.impl.sql.compile.GrantNode, org.apache.derby.impl.sql.compile.GrantRoleNode, org.apache.derby.impl.sql.compile.RenameNode, org.apache.derby.impl.sql.compile.RevokeNode, org.apache.derby.impl.sql.compile.SavepointNode, org.apache.derby.impl.sql.compile.AlterTableNode, org.apache.derby.impl.sql.compile.CreateAliasNode, org.apache.derby.impl.sql.compile.CreateIndexNode, org.apache.derby.impl.sql.compile.CreateRoleNode, org.apache.derby.impl.sql.compile.CreateSequenceNode, org.apache.derby.impl.sql.compile.CreateTableNode, org.apache.derby.impl.sql.compile.CreateTriggerNode, org.apache.derby.impl.sql.compile.CreateViewNode
Imports
org.apache.derby.catalog.UUID, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.ClassName, .SQLState, org.apache.derby.iapi.services.classfile.VMOpcode, org.apache.derby.iapi.services.compiler.MethodBuilder, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.compile.CompilerContext, .Visitor, org.apache.derby.iapi.sql.conn.Authorizer, org.apache.derby.iapi.sql.dictionary.DataDictionary, .SchemaDescriptor, .TableDescriptor

A DDLStatementNode represents any type of DDL statement: CREATE TABLE, CREATE INDEX, ALTER TABLE, etc.

Field Summary

Modifier and TypeField and Description
public static final int
public static final int
public static final int
pack-priv boolean
implicitCreateSchema

sub-classes can set this to be true to allow implicit creation of the main object's schema at execution time.

private boolean
public static final int
public static final int
private TableName
public static final int
public static final int
Inherited from org.apache.derby.impl.sql.compile.StatementNode:
EMPTY_TD_LISTNEED_CURSOR_ACTIVATIONNEED_DDL_ACTIVATIONNEED_NOTHING_ACTIVATIONNEED_PARAM_ACTIVATIONNEED_ROW_ACTIVATION

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
acceptChildren(Visitor
the visitor
v
)

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.acceptChildren.

Accept a visitor on all child nodes.

pack-priv int
private TableDescriptor
checkTableDescriptor(TableDescriptor td, boolean doSystemTableCheck)

pack-priv final void
generate(ActivationClassBuilder
The ActivationClassBuilder for the class being built
acb
,
MethodBuilder
The execute() method to be built
mb
)

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.generate.

Generic generate code for all DDL statements.

pack-priv String

Returns:

the full name
getFullName
()

Return the full dot expression name of the object being dropped.

public final TableName
pack-priv String

Returns:

the relative name
getRelativeName
()

Return the name of the table being dropped.

protected final SchemaDescriptor

Returns:

Schema Descriptor
getSchemaDescriptor
()

Get a schema descriptor for this DDL object.

protected final SchemaDescriptor

Returns:

Schema Descriptor
getSchemaDescriptor
(boolean
If check for schema owner is needed
ownerCheck
,
boolean
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
doSystemSchemaCheck
)

Get a schema descriptor for this DDL object.

protected final TableDescriptor
protected final TableDescriptor

Returns:

the validated table descriptor, never null
getTableDescriptor
(boolean doSystemTableCheck)

Validate that the table is ok for DDL -- e.g. that it exists, it is not a view.

protected final TableDescriptor
protected final TableDescriptor

Returns:

the validated table descriptor, never null
getTableDescriptor
(TableName tableName)

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.

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.

public boolean

Returns:

true
isAtomic
()

Overrides org.apache.derby.impl.sql.compile.StatementNode.isAtomic.

A DDL statement is always atomic

private TableDescriptor

Returns:

TableDescriptor for the give TableName
justGetDescriptor
(TableName tableName)

Just get the table descriptor.

pack-priv FromList
makeFromList(DataDictionary
Metadata.
dd
,
TableElementList
the parenthesized list of columns and constraints in a CREATE/ALTER TABLE statement
tableElementList
,
boolean
true if this is for CREATE TABLE. false if this is for ALTER TABLE
creatingTable
)

Make a from list for binding query fragments in a CREATE/ALTER TABLE statement.

public String

Returns:

This object as a String
toString
()

Overrides org.apache.derby.impl.sql.compile.StatementNode.toString.

Convert this object to a String.

Inherited from org.apache.derby.impl.sql.compile.StatementNode:
bindStatementexecuteSchemaNameexecuteStatementNamegenerategetCursorInfogetSPSNamelockTableForCompilationmakeResultDescriptionneedsSavepointoptimizeStatementstatementToStringupdateIndexStatisticsFor

Field Detail

ADD_TYPEback to summary
public static final int ADD_TYPE
DROP_STATISTICSback to summary
public static final int DROP_STATISTICS
DROP_TYPEback to summary
public static final int DROP_TYPE
implicitCreateSchemaback to summary
pack-priv boolean implicitCreateSchema

sub-classes can set this to be true to allow implicit creation of the main object's schema at execution time.

initOkback to summary
private boolean initOk
LOCKING_TYPEback to summary
public static final int LOCKING_TYPE
MODIFY_TYPEback to summary
public static final int MODIFY_TYPE
tableNameback to summary
private TableName tableName
UNKNOWN_TYPEback to summary
public static final int UNKNOWN_TYPE
UPDATE_STATISTICSback to summary
public static final int UPDATE_STATISTICS

Constructor Detail

DDLStatementNodeback to summary
pack-priv DDLStatementNode(TableName tableName, ContextManager cm)
DDLStatementNodeback to summary
pack-priv DDLStatementNode(ContextManager cm)

Method Detail

acceptChildrenback to summary
pack-priv void acceptChildren(Visitor v) throws StandardException

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.acceptChildren.

Doc from org.apache.derby.impl.sql.compile.QueryTreeNode.acceptChildren.

Accept a visitor on all child nodes. All sub-classes that add fields that should be visited, should override this method and call accept(v) on all visitable fields, as well as super.acceptChildren(v) to make sure all visitable fields defined by the super-class are accepted too.

Parameters
v:Visitor

the visitor

Annotations
@Override
Exceptions
StandardException:
on errors raised by the visitor
activationKindback to summary
pack-priv int activationKind()

Implements abstract org.apache.derby.impl.sql.compile.StatementNode.activationKind.

checkTableDescriptorback to summary
private TableDescriptor checkTableDescriptor(TableDescriptor td, boolean doSystemTableCheck) throws StandardException
generateback to summary
pack-priv final void generate(ActivationClassBuilder acb, MethodBuilder mb) throws StandardException

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.generate.

Generic generate code for all DDL statements.

Parameters
acb:ActivationClassBuilder

The ActivationClassBuilder for the class being built

mb:MethodBuilder

The execute() method to be built

Annotations
@Override
Exceptions
StandardException:
Thrown on error
getFullNameback to summary
pack-priv String getFullName()

Return the full dot expression name of the object being dropped.

Returns:String

the full name

getObjectNameback to summary
public final TableName getObjectName()
getRelativeNameback to summary
pack-priv String getRelativeName()

Return the name of the table being dropped. This is the unqualified table name.

Returns:String

the relative name

getSchemaDescriptorback to summary
protected final SchemaDescriptor getSchemaDescriptor() 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. Checks if current authorizationID is owner of the schema.

Returns:SchemaDescriptor

Schema Descriptor

Exceptions
StandardException:
throws on schema name that doesn't exist
getSchemaDescriptorback to summary
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:boolean

If check for schema owner is needed

doSystemSchemaCheck:boolean

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:SchemaDescriptor

Schema Descriptor

Exceptions
StandardException:
throws on schema name that doesn't exist
getTableDescriptorback to summary
protected final TableDescriptor getTableDescriptor() throws StandardException
getTableDescriptorback to summary
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:TableDescriptor

the validated table descriptor, never null

Exceptions
StandardException:
on error
getTableDescriptorback to summary
protected final TableDescriptor getTableDescriptor(UUID tableId) throws StandardException
getTableDescriptorback to summary
protected final TableDescriptor getTableDescriptor(TableName tableName) throws StandardException

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:TableDescriptor

the validated table descriptor, never null

Exceptions
StandardException:
on error
initAndCheckback to summary
protected void initAndCheck(Object objectName) throws StandardException

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.

isAtomicback to summary
public boolean isAtomic()

Overrides org.apache.derby.impl.sql.compile.StatementNode.isAtomic.

A DDL statement is always atomic

Returns:boolean

true

Annotations
@Override
justGetDescriptorback to summary
private TableDescriptor justGetDescriptor(TableName tableName) throws StandardException

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.

Returns:TableDescriptor

TableDescriptor for the give TableName

Exceptions
StandardException:
on error
makeFromListback to summary
pack-priv 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:DataDictionary

Metadata.

tableElementList:TableElementList

the parenthesized list of columns and constraints in a CREATE/ALTER TABLE statement

creatingTable:boolean

true if this is for CREATE TABLE. false if this is for ALTER TABLE

toStringback to summary
public String toString()

Overrides org.apache.derby.impl.sql.compile.StatementNode.toString.

Convert this object to a String. See comments in QueryTreeNode.java for how this should be done for tree printing.

Returns:String

This object as a String

Annotations
@Override