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

pack-priv abstract Class DMLStatementNode

extends StatementNode
Class Inheritance
Known Direct Subclasses
org.apache.derby.impl.sql.compile.CallStatementNode, org.apache.derby.impl.sql.compile.CursorNode, org.apache.derby.impl.sql.compile.DMLModStatementNode
Imports
java.util.List, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.ResultColumnDescriptor, .ResultDescription, org.apache.derby.iapi.sql.compile.Visitor, org.apache.derby.iapi.sql.conn.Authorizer, org.apache.derby.iapi.sql.dictionary.DataDictionary, org.apache.derby.iapi.util.JBitSet

A DMLStatementNode represents any type of DML statement: a cursor declaration, an INSERT statement, and UPDATE statement, or a DELETE statement. All DML statements have result sets, but they do different things with them. A SELECT statement sends its result set to the client, an INSERT statement inserts its result set into a table, a DELETE statement deletes from a table the rows corresponding to the rows in its result set, and an UPDATE statement updates the rows in a base table corresponding to the rows in its result set.

Field Summary

Modifier and TypeField and Description
pack-priv ResultSetNode
resultSet

The result set is the rows that result from running the statement.

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

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 the visitor for all visitable children of this node.

pack-priv int

Returns:

either (NEED_ROW_ACTIVATION | NEED_PARAM_ACTIVATION) or (NEED_ROW_ACTIVATION) depending on params
activationKind
()

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

Returns the type of activation this class generates.

pack-priv QueryTreeNode

Returns:

The bound query tree
bind
(DataDictionary
The DataDictionary to use to look up columns, tables, etc.
dataDictionary
)

Bind this DMLStatementNode.

protected void
bindExpressions()

Bind the expressions in this DML statement.

protected void
bindExpressionsWithTables()

Bind the expressions in the underlying ResultSets with tables.

pack-priv QueryTreeNode

Returns:

The bound query tree
bindResultSetsWithTables
(DataDictionary
The DataDictionary to use to look up columns, tables, etc.
dataDictionary
)

Bind only the underlying ResultSets with tables.

protected void
bindTables(DataDictionary
The data dictionary to use to look up the tables
dataDictionary
)

Bind the tables in this DML statement.

pack-priv void
generateParameterValueSet(ActivationClassBuilder
The ActivationClassBuilder for the class we're building
acb
)

Generate the code to create the ParameterValueSet, if necessary, when constructing the activation.

pack-priv int

Returns:

true if the statement is atomic
getPrivType
()

Return default privilege needed for this node.

pack-priv ResultSetNode

Returns:

ResultSetNode The ResultSetNode from this DMLStatementNode.
getResultSetNode
()

Get the ResultSetNode from this DML Statement.

public boolean

Returns:

true if the statement is atomic
isAtomic
()

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

A read statement is atomic (DMLMod overrides us) if there are no work units, and no SELECT nodes, or if its SELECT nodes are all arguments to a function.

public ResultDescription

Returns:

A ResultDescription for this DML statement
makeResultDescription
()

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

Make a ResultDescription for use in a PreparedStatement.

public void
optimizeStatement()

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

Optimize a DML statement (which is the only type of statement that should need optimizing, I think).

pack-priv void
printSubNodes(int
The depth of this node in the tree
depth
)

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

Prints the sub-nodes of this object.

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

Field Detail

resultSetback to summary
pack-priv ResultSetNode resultSet

The result set is the rows that result from running the statement. What this means for SELECT statements is fairly obvious. For a DELETE, there is one result column representing the key of the row to be deleted (most likely, the location of the row in the underlying heap). For an UPDATE, the row consists of the key of the row to be updated plus the updated columns. For an INSERT, the row consists of the new column values to be inserted, with no key (the system generates a key). The parser doesn't know anything about keys, so the columns representing the keys will be added after parsing (perhaps in the binding phase?).

Constructor Detail

DMLStatementNodeback to summary
pack-priv DMLStatementNode(ResultSetNode resultSet, ContextManager cm)

Method Detail

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

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

Accept the visitor for all visitable children of this node.

Parameters
v:Visitor

the visitor

Annotations
@Override
Exceptions
StandardException:
on error
activationKindback to summary
pack-priv int activationKind()

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

Returns the type of activation this class generates.

Returns:int

either (NEED_ROW_ACTIVATION | NEED_PARAM_ACTIVATION) or (NEED_ROW_ACTIVATION) depending on params

bindback to summary
pack-priv QueryTreeNode bind(DataDictionary dataDictionary) throws StandardException

Bind this DMLStatementNode. This means looking up tables and columns and getting their types, and figuring out the result types of all expressions, as well as doing view resolution, permissions checking, etc.

Parameters
dataDictionary:DataDictionary

The DataDictionary to use to look up columns, tables, etc.

Returns:QueryTreeNode

The bound query tree

Exceptions
StandardException:
Thrown on error
bindExpressionsback to summary
protected void bindExpressions() throws StandardException

Bind the expressions in this DML statement.

Exceptions
StandardException:
Thrown on error
bindExpressionsWithTablesback to summary
protected void bindExpressionsWithTables() throws StandardException

Bind the expressions in the underlying ResultSets with tables.

Exceptions
StandardException:
Thrown on error
bindResultSetsWithTablesback to summary
pack-priv QueryTreeNode bindResultSetsWithTables(DataDictionary dataDictionary) throws StandardException

Bind only the underlying ResultSets with tables. This is necessary for INSERT, where the binding order depends on the underlying ResultSets. This means looking up tables and columns and getting their types, and figuring out the result types of all expressions, as well as doing view resolution, permissions checking, etc.

Parameters
dataDictionary:DataDictionary

The DataDictionary to use to look up columns, tables, etc.

Returns:QueryTreeNode

The bound query tree

Exceptions
StandardException:
Thrown on error
bindTablesback to summary
protected void bindTables(DataDictionary dataDictionary) throws StandardException

Bind the tables in this DML statement.

Parameters
dataDictionary:DataDictionary

The data dictionary to use to look up the tables

Exceptions
StandardException:
Thrown on error
generateParameterValueSetback to summary
pack-priv void generateParameterValueSet(ActivationClassBuilder acb) throws StandardException

Generate the code to create the ParameterValueSet, if necessary, when constructing the activation. Also generate the code to call a method that will throw an exception if we try to execute without all the parameters being set.

Parameters
acb:ActivationClassBuilder

The ActivationClassBuilder for the class we're building

getPrivTypeback to summary
pack-priv int getPrivType()

Return default privilege needed for this node. Other DML nodes can override this method to set their own default privilege.

Returns:int

true if the statement is atomic

getResultSetNodeback to summary
pack-priv ResultSetNode getResultSetNode()

Get the ResultSetNode from this DML Statement. (Useful for view resolution after parsing the view definition.)

Returns:ResultSetNode

ResultSetNode The ResultSetNode from this DMLStatementNode.

isAtomicback to summary
public boolean isAtomic() throws StandardException

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

A read statement is atomic (DMLMod overrides us) if there are no work units, and no SELECT nodes, or if its SELECT nodes are all arguments to a function. This is admittedly a bit simplistic, what if someone has:

	VALUES myfunc(SELECT max(c.commitFunc()) FROM T) 
but we aren't going too far out of our way to catch every possible wierd case. We basically want to be permissive w/o allowing someone to partially commit a write.
Returns:boolean

true if the statement is atomic

Annotations
@Override
Exceptions
StandardException:
on error
makeResultDescriptionback to summary
public ResultDescription makeResultDescription()

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

Make a ResultDescription for use in a PreparedStatement. ResultDescriptions are visible to JDBC only for cursor statements. For other types of statements, they are only used internally to get descriptions of the base tables being affected. For example, for an INSERT statement, the ResultDescription describes the rows in the table being inserted into, which is useful when the values being inserted are of a different type or length than the columns in the base table.

Returns:ResultDescription

A ResultDescription for this DML statement

Annotations
@Override
optimizeStatementback to summary
public void optimizeStatement() throws StandardException

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

Optimize a DML statement (which is the only type of statement that should need optimizing, I think). This method over-rides the one in QueryTreeNode. This method takes a bound tree, and returns an optimized tree. It annotates the bound tree rather than creating an entirely new tree. Throws an exception if the tree is not bound, or if the binding is out of date.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
printSubNodesback to summary
pack-priv void printSubNodes(int depth)

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

Prints the sub-nodes of this object. See QueryTreeNode.java for how tree printing is supposed to work.

Parameters
depth:int

The depth of this node in the tree

Annotations
@Override