org.apache.derby.impl.sql.compile
Class StatementNode

java.lang.Object
  extended by org.apache.derby.impl.sql.compile.QueryTreeNode
      extended by org.apache.derby.impl.sql.compile.StatementNode
All Implemented Interfaces:
Visitable
Direct Known Subclasses:
DDLStatementNode, DMLStatementNode, ExecSPSNode, MiscellaneousStatementNode, NOPStatementNode, TransactionStatementNode

public abstract class StatementNode
extends QueryTreeNode

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
(package private) static int NEED_CURSOR_ACTIVATION
           
(package private) static int NEED_DDL_ACTIVATION
          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 int NEED_NOTHING_ACTIVATION
           
(package private) static int NEED_PARAM_ACTIVATION
           
(package private) static int NEED_ROW_ACTIVATION
           
 
Fields inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX, isPrivilegeCollectionRequired
 
Constructor Summary
StatementNode()
           
 
Method Summary
(package private) abstract  int activationKind()
           
 void bindStatement()
          Perform the binding operation statement.
 java.lang.String executeSchemaName()
          Returns name of schema in EXECUTE STATEMENT command.
 java.lang.String executeStatementName()
          Returns the name of statement in EXECUTE STATEMENT command.
 GeneratedClass generate(ByteArray byteCode)
          Do code generation for this statement.
 java.lang.String getSPSName()
          Get the name of the SPS that is used to execute this statement.
 boolean isAtomic()
          By default, assume StatementNodes are atomic.
protected  TableDescriptor lockTableForCompilation(TableDescriptor td)
           
 ResultDescription makeResultDescription()
          Only DML statements have result descriptions - for all others return null.
 boolean needsSavepoint()
          Returns whether or not this Statement requires a set/clear savepoint around its execution.
 void optimizeStatement()
          Generates an optimized statement from a bound StatementNode.
abstract  java.lang.String statementToString()
           
 java.lang.String toString()
          Convert this object to a String.
 
Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
accept, acceptChildren, bindOffsetFetch, bindRowMultiSet, bindUserType, checkReliability, checkReliability, convertDefaultNode, createTypeDependency, debugFlush, debugPrint, disablePrivilegeCollection, formatNodeString, foundString, generate, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContextManager, getCursorInfo, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getNodeFactory, getNodeType, getNullNode, getParameterTypes, getRowEstimate, getSchemaDescriptor, getSchemaDescriptor, getStatementType, getTableDescriptor, getTypeCompiler, init, init, init, init, init, init, init, init, init, init, init, init, init, init, isInstanceOf, isPrivilegeCollectionRequired, isSessionSchema, isSessionSchema, makeConstantAction, makeTableName, makeTableName, nodeHeader, orReliability, parseStatement, printLabel, printSubNodes, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setContextManager, setEndOffset, setNodeType, setRefActionInfo, stackPrint, treePrint, treePrint, verifyClassExist
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NEED_DDL_ACTIVATION

static final int NEED_DDL_ACTIVATION
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.

See Also:
Constant Field Values

NEED_CURSOR_ACTIVATION

static final int NEED_CURSOR_ACTIVATION
See Also:
Constant Field Values

NEED_PARAM_ACTIVATION

static final int NEED_PARAM_ACTIVATION
See Also:
Constant Field Values

NEED_ROW_ACTIVATION

static final int NEED_ROW_ACTIVATION
See Also:
Constant Field Values

NEED_NOTHING_ACTIVATION

static final int NEED_NOTHING_ACTIVATION
See Also:
Constant Field Values
Constructor Detail

StatementNode

public StatementNode()
Method Detail

isAtomic

public boolean isAtomic()
                 throws StandardException
By default, assume StatementNodes are atomic. The rare statements that aren't atomic (e.g. CALL method()) override this.

Overrides:
isAtomic in class QueryTreeNode
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/rollback

ONLY 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

public java.lang.String 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

public java.lang.String 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

public java.lang.String 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

public ResultDescription makeResultDescription()
Only DML statements have result descriptions - for all others return null. This method is overridden in DMLStatementNode.

Returns:
null

toString

public java.lang.String toString()
Convert this object to a String. See comments in QueryTreeNode.java for how this should be done for tree printing.

Overrides:
toString in class QueryTreeNode
Returns:
This object as a String

statementToString

public abstract java.lang.String statementToString()

bindStatement

public void bindStatement()
                   throws StandardException
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

public void optimizeStatement()
                       throws StandardException
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

protected TableDescriptor lockTableForCompilation(TableDescriptor td)
                                           throws StandardException
Throws:
StandardException

generate

public GeneratedClass generate(ByteArray byteCode)
                        throws StandardException
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

Built on Thu 2012-03-29 21:53:33+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.