Class StatementNode
java.lang.Object
org.apache.derby.impl.sql.compile.QueryTreeNode
org.apache.derby.impl.sql.compile.StatementNode
- All Implemented Interfaces:
Visitable
- Direct Known Subclasses:
DDLStatementNode
,DMLStatementNode
,ExecSPSNode
,MiscellaneousStatementNode
,NOPStatementNode
,TransactionStatementNode
A StatementNode represents a single statement in the language. It is
the top node for any statement.
StatementNode controls the class generation for query tree nodes.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final TableDescriptor[]
Cached empty list object.(package private) static final int
(package private) static final int
create the outer shell class builder for the class we will be generating, generate the expression to stuff in it, and turn it into a class.(package private) static final int
(package private) static final int
(package private) static final int
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) abstract int
void
Perform the binding operation statement.Returns name of schema in EXECUTE STATEMENT command.Returns the name of statement in EXECUTE STATEMENT command.Do code generation for this statement.Get an object with information about the cursor if there is one.Get the name of the SPS that is used to execute this statement.boolean
isAtomic()
By default, assume StatementNodes are atomic.protected TableDescriptor
Only DML statements have result descriptions - for all others return null.boolean
Returns whether or not this Statement requires a set/clear savepoint around its execution.void
Generates an optimized statement from a bound StatementNode.(package private) abstract String
toString()
Convert this object to a String.Returns a list of base tables for which the index statistics of the associated indexes should be updated.Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
accept, acceptChildren, addTag, addUDTUsagePriv, addUDTUsagePriv, bindOffsetFetch, bindRowMultiSet, bindUserCatalogType, bindUserType, checkReliability, checkReliability, convertDefaultNode, copyTagsFrom, createTypeDependency, debugFlush, debugPrint, disablePrivilegeCollection, formatNodeString, generate, 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
-
EMPTY_TD_LIST
Cached empty list object. -
NEED_DDL_ACTIVATION
static final int NEED_DDL_ACTIVATIONcreate the outer shell class builder for the class we will be generating, generate the expression to stuff in it, and turn it into a class.- See Also:
-
NEED_CURSOR_ACTIVATION
static final int NEED_CURSOR_ACTIVATION- See Also:
-
NEED_PARAM_ACTIVATION
static final int NEED_PARAM_ACTIVATION- See Also:
-
NEED_ROW_ACTIVATION
static final int NEED_ROW_ACTIVATION- See Also:
-
NEED_NOTHING_ACTIVATION
static final int NEED_NOTHING_ACTIVATION- See Also:
-
-
Constructor Details
-
StatementNode
StatementNode(ContextManager cm)
-
-
Method Details
-
isAtomic
By default, assume StatementNodes are atomic. The rare statements that aren't atomic (e.g. CALL method()) override this.- Overrides:
isAtomic
in classQueryTreeNode
- Returns:
- true if the statement is atomic
- Throws:
StandardException
- Thrown on error
-
needsSavepoint
public boolean needsSavepoint()Returns whether or not this Statement requires a set/clear savepoint around its execution. The following statement "types" do not require them: Cursor - unnecessary and won't work in a read only environment Xact - savepoint will get blown away underneath us during commit/rollbackONLY CALLABLE AFTER GENERATION
This implementation returns true, sub-classes can override the method to not require a savepoint.
- Returns:
- boolean Whether or not this Statement requires a set/clear savepoint
-
getSPSName
Get the name of the SPS that is used to execute this statement. Only relevant for an ExecSPSNode -- otherwise, returns null.- Returns:
- the name of the underlying sps
-
executeStatementName
Returns the name of statement in EXECUTE STATEMENT command. Returns null for all other commands.- Returns:
- String null unless overridden for Execute Statement command
-
executeSchemaName
Returns name of schema in EXECUTE STATEMENT command. Returns null for all other commands.- Returns:
- String schema for EXECUTE STATEMENT null for all others
-
makeResultDescription
Only DML statements have result descriptions - for all others return null. This method is overridden in DMLStatementNode.- Returns:
- null
-
getCursorInfo
Get an object with information about the cursor if there is one.- Throws:
StandardException
-
toString
Convert this object to a String. See comments in QueryTreeNode.java for how this should be done for tree printing.- Overrides:
toString
in classQueryTreeNode
- Returns:
- This object as a String
-
statementToString
-
bindStatement
Perform the binding operation statement. Binding consists of permissions checking, view resolution, datatype resolution, and creation of a dependency list (for determining whether a tree or plan is still up to date). This bindStatement() method does nothing. Each StatementNode type that can appear at the top of a tree can override this method with its own bindStatement() method that does "something".- Throws:
StandardException
- Thrown on error
-
optimizeStatement
Generates an optimized statement from a bound StatementNode. Actually, it annotates the tree in place rather than generating a new tree. For non-optimizable statements (for example, CREATE TABLE), return the bound tree without doing anything. For optimizable statements, this method will be over-ridden in the statement's root node (DMLStatementNode in all cases we know about so far). Throws an exception if the tree is not bound, or if the binding is out of date.- Throws:
StandardException
- Thrown on error
-
activationKind
abstract int activationKind() -
lockTableForCompilation
- Throws:
StandardException
-
generate
Do code generation for this statement.- Parameters:
byteCode
- the generated byte code for this statement. if non-null, then the byte code is saved here.- Returns:
- A GeneratedClass for this statement
- Throws:
StandardException
- Thrown on error
-
updateIndexStatisticsFor
Returns a list of base tables for which the index statistics of the associated indexes should be updated.This default implementation always returns an empty list.
- Returns:
- A list of table descriptors (potentially empty).
- Throws:
StandardException
- if accessing the index descriptors of a base table fails
-