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

public abstract Class ValueNode

extends QueryTreeNode
Class Inheritance
Known Direct Subclasses
org.apache.derby.impl.sql.compile.VirtualColumnNode, org.apache.derby.impl.sql.compile.BaseColumnNode, org.apache.derby.impl.sql.compile.BinaryListOperatorNode, org.apache.derby.impl.sql.compile.CachedValueNode, org.apache.derby.impl.sql.compile.CastNode, org.apache.derby.impl.sql.compile.ColumnReference, org.apache.derby.impl.sql.compile.ConditionalNode, org.apache.derby.impl.sql.compile.ConstantNode, org.apache.derby.impl.sql.compile.CurrentDatetimeOperatorNode, org.apache.derby.impl.sql.compile.CurrentRowLocationNode, org.apache.derby.impl.sql.compile.DefaultNode, org.apache.derby.impl.sql.compile.CoalesceFunctionNode, org.apache.derby.impl.sql.compile.SpecialFunctionNode, org.apache.derby.impl.sql.compile.GenerationClauseNode, org.apache.derby.impl.sql.compile.JavaToSQLValueNode, org.apache.derby.impl.sql.compile.NextSequenceNode, org.apache.derby.impl.sql.compile.OperatorNode, org.apache.derby.impl.sql.compile.ParameterNode, org.apache.derby.impl.sql.compile.ResultColumn, org.apache.derby.impl.sql.compile.SubqueryNode
Imports
java.util.List, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.SQLState, 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.Optimizable, .TypeCompiler, org.apache.derby.iapi.store.access.Qualifier, org.apache.derby.iapi.types.DataTypeDescriptor, .DataValueFactory, .StringDataValue, .TypeId, org.apache.derby.iapi.util.JBitSet

A ValueNode is an abstract class for all nodes that can represent data values, that is, constants, columns, and expressions.

Field Summary

Modifier and TypeField and Description
private DataTypeDescriptor
dataTypeServices

The data type for this node.

pack-priv boolean
Inherited from org.apache.derby.impl.sql.compile.QueryTreeNode:
AUTOINCREMENT_CREATE_MODIFYAUTOINCREMENT_CYCLEAUTOINCREMENT_INC_INDEXAUTOINCREMENT_IS_AUTOINCREMENT_INDEXAUTOINCREMENT_START_INDEX

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv ValueNode
bindExpression(FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates)

pack-priv ValueNode

Returns:

The new top of the expression tree.
bindExpression
(FromList
The FROM list to use for binding
fromList
,
SubqueryList
The SubqueryList we are building as we hit SubqueryNodes.
subqueryList
,
List<AggregateNode>
The aggregate list being built as we find AggregateNodes
aggregates
,
boolean forQueryRewrite)

Bind this expression.

pack-priv boolean

Returns:

boolean Whether or not source.expression is a ColumnReference or a VirtualColumnNode.
categorize
(JBitSet
JBitSet with bit map of referenced FromTables
referencedTabs
,
boolean
Whether or not to consider method calls, field references and conditional nodes when building bit map
simplePredsOnly
)

Categorize this predicate.

pack-priv ValueNode

Returns:

The modified expression
changeToCNF
(boolean
Whether or not we are under a top level AndNode.
underTopAndNode
)

Finish putting an expression into conjunctive normal form.

public ValueNode

Returns:

bound coercion of this node to a builtin type as necessary
checkIsBoolean
()

Bind time logic.

pack-priv void
checkTopPredicatesForEqualsConditions(int
The tableNumber of the table from which the columns of interest come from.
tableNumber
,
boolean[]
Array of booleans for noting which columns are in = predicates without columns from the subquery block. May be null.
eqOuterCols
,
int[]
Array of table numbers in this query block.
tableNumbers
,
JBitSet[]
Array of bits for noting which columns are in = predicates for each table in the query block. May be null.
tableColMap
,
boolean
True if tableNumber is the table containing result columns
resultColTable
)

Update the array of columns in = conditions with expressions without column references from the same table.

pack-priv boolean

Returns:

True means this expression tree represents a constant value.
constantExpression
(PredicateList whereClause)

Return whether or not this expression tree represents a constant value.

pack-priv void
copyFields(ValueNode
The ValueNode to copy from.
oldVN
)

Copy all of the "appropriate fields" for a shallow copy.

pack-priv ValueNode

Returns:

The modified expression
eliminateNots
(boolean
Whether or not we are under a NotNode.
underNotNode
)

Eliminate NotNodes in the current query block.

pack-priv ValueNode

Returns:

a constant representing the value to which this node is guaranteed to evaluate, or this if the value is not known
evaluateConstantExpressions
()

If this node is known to always evaluate to the same value, return a node that represents that known value as a constant.

pack-priv ValueNode

Returns:

The modified expression
genEqualsFalseTree
()

Transform this into this = false.

pack-priv final void
generate(ActivationClassBuilder
The ActivationClassBuilder for the class being built
acb
,
MethodBuilder
The method the expression will go into
mb
)

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

Do the code generation for this node.

pack-priv void
generateExpression(ExpressionClassBuilder
The ExpressionClassBuilder for the class being built
acb
,
MethodBuilder
The method the expression will go into
mb
)

Generate code for this calculation.

pack-priv ValueNode

Returns:

The modified expression
genIsNullTree
(boolean
if true, transform this into IS NOT NULL; otherwise, transform this into IS NULL
notNull
)

Transform this into this IS NULL or IS NOT NULL.

pack-priv ValueNode

Returns:

ValueNode The new tree.
genSQLJavaSQLTree
()

Generate a SQL->Java->SQL conversion tree above the current node and bind the new nodes individually.

pack-priv ValueNode

Returns:

ValueNode A clone of this node.
getClone
()

Return a clone of this node.

pack-priv String

Returns:

the default column name for an expression -- null.
getColumnName
()

This is null so that the caller will substitute in the resultset generated name as needed.

pack-priv Object

Returns:

An Object representing the bind time value of this expression tree. (null if not a bind time constant.)
getConstantValueAsObject
()

Return an Object representing the bind time value of this expression tree.

protected final DataValueFactory
getDataValueFactory()

Return the DataValueFactory

protected int

Returns:

The variant type for the underlying expression.
getOrderableVariantType
()

Return the variant type for the underlying expression.

pack-priv String

Returns:

the default schema name for an expression -- null
getSchemaName
()

This returns the user-supplied schema name of the column.

pack-priv ResultColumn

Returns:

The source of this ValueNode, null if this node is not sourced by a column.
getSourceResultColumn
()

Get the source for this ValueNode.

pack-priv String

Returns:

the default table name for an expression -- null
getTableName
()

This returns the user-supplied table name of the column.

pack-priv JBitSet

Returns:

A bit map of table numbers referred to in this expression
getTablesReferenced
()

Get a bit map of table references in this expression

pack-priv boolean

Returns:

Whether or not this predicate has been transformed.
getTransformed
()

Return whether or not this predicate has been transformed.

pack-priv final TypeCompiler

Returns:

This ValueNode's TypeCompiler
getTypeCompiler
()

Get the TypeCompiler from this ValueNode, based on its TypeId using getTypeId().

pack-priv TypeId

Returns:

The TypeId from this ValueNode. This may be null if the node isn't bound yet.
getTypeId
()

Get the TypeId from this ValueNode.

pack-priv DataTypeDescriptor

Returns:

The DataTypeServices from this ValueNode. This may be null if the node isn't bound yet.
getTypeServices
()

Get the DataTypeServices from this ValueNode.

pack-priv boolean
isBinaryEqualsOperatorNode()

Returns true if this value node is a equals operator.

pack-priv boolean

Returns:

Whether or not this node represents a false constant.
isBooleanFalse
()

Does this represent a false constant.

pack-priv boolean

Returns:

Whether or not this node represents a true constant.
isBooleanTrue
()

Does this represent a true constant.

pack-priv boolean

Returns:

boolean Whether or not this expression tree is cloneable.
isCloneable
()

Return whether or not this expression tree is cloneable.

pack-priv boolean

Returns:

Whether or not this expression tree represents a constant expression.
isConstantExpression
()

Return whether or not this expression tree represents a constant expression.

pack-priv abstract boolean

Returns:

true if the two nodes are equivalent, false otherwise.
isEquivalent
(ValueNode
the node to compare this ValueNode against.
other
)

Tests if this node is equivalent to the specified ValueNode.

pack-priv boolean
isInListProbeNode()

Returns true if this value node is an operator created for optimized performance of an IN list.

pack-priv boolean
isParameterNode()

Returns TRUE if this is a parameter node.

pack-priv boolean
isRelationalOperator()

Returns true if this ValueNode is a relational operator.

pack-priv boolean

Returns:

true if this and o represent the same logical node type, i.e. kind.
isSameNodeKind
(ValueNode
The other value node whose kind we want to compare with.
other
)

Some node classes represent several logical node types (to reduce footprint), which we call kinds.

pack-priv boolean
optimizableEqualityNode(Optimizable
the table being optimized. Column reference must be from this table.
optTable
,
int
the column number. One of the operands of this predicate must be the column number specified by optTable/columnNumber
columnNumber
,
boolean
if set to true we also consider IS NULL predicates; otherwise consider only = predicates.
isNullOkay
)

Return true if the predicate represents an optimizable equality node.

pack-priv ValueNode

Returns:

The modified expression
preprocess
(int
Number of tables in the DML Statement
numTables
,
FromList
FromList from outer query block
outerFromList
,
SubqueryList
SubqueryList from outer query block
outerSubqueryList
,
PredicateList
PredicateList from outer query block
outerPredicateList
)

Preprocess an expression tree.

pack-priv ValueNode

Returns:

The modified expression
putAndsOnTop
()

Do the 1st step in putting an expression into conjunctive normal form.

pack-priv ValueNode

Returns:

ValueNode The remapped expression tree.
remapColumnReferencesToExpressions
()

Remap all ColumnReferences in this tree to be clones of the underlying expression.

pack-priv boolean

Returns:

Whether this node's type will be determined from the context
requiresTypeFromContext
()

Returns TRUE if the type of this node will be determined from the context in which it is getting used.

public double
selectivity(Optimizable optTable)

The default selectivity for value nodes is 50%.

public void
setCollationInfo(DataTypeDescriptor
Type to take collation type and derivation from.
collationInfoType
)

Set the collation type and derivation of this node based upon the collation information in the passed in type.

public void
setCollationInfo(int
Collation type
collationType
,
int
Collation derivation
collationDerivation
)

Set the collation type and derivation of this node based upon the collation information passed in. This may result in a different object being returned from getTypeServices().

protected final void
setCollationUsingCompilationSchema()

Set the collation based upon the current schema with derivation type implicit.

protected final void
setCollationUsingCompilationSchema(int
This can be StringDataValue#COLLATION_DERIVATION_IMPLICIT StringDataValue#COLLATION_DERIVATION_NONE StringDataValue#COLLATION_DERIVATION_EXPLICIT
collationDerivation
)

There are many subclasses of ValueNode where we want the DataTypeDescriptor of the node to have the same collation type as the compilation schema's collation type.

public void
setNullability(boolean nullability)

Set the nullability of this value.

pack-priv void
setTransformed()

Mark this predicate has having been transformed (other predicates were generated from it).

pack-priv final void
setType(TypeId typeId, boolean isNullable, int maximumWidth)

Set this node's type from type components.

pack-priv final void
setType(TypeId typeId, int precision, int scale, boolean isNullable, int maximumWidth)

Set this node's type from type components.

pack-priv void
setType(DataTypeDescriptor
The DataTypeServices to set in this ValueNode
dataTypeServices
)

Set the DataTypeServices for this ValueNode.

private void
setValueCols(JBitSet[]
Array of bitmaps for noting which columns are in = predicates with columns from each table
tableColMap
,
boolean[]
Array of booleans for noting which columns are in = predicates without columns from the subquery block.
eqOuterCols
,
int
The column to set
colReference
,
int
If -1 set all the bit for all the tables for that column; otherwise set the bit for the specified table
resultTable
)

Set eqOuterCols and the column in all the tables for constants, parmeters and correlation columns The column in the tableColMap is set only for the current table if the table is the result column table.

public String

Returns:

This object as a String
toString
()

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

Convert this object to a String.

public boolean

Returns:

the default updatability for an expression - false
updatableByCursor
()

private void
updateMaps(JBitSet[]
Array of bitmaps for noting which columns are in = predicates with columns from each table
tableColMap
,
boolean[]
Array of booleans for noting which columns are in = predicates without columns from the subquery block.
eqOuterCols
,
int[] tableNumbers, int
table number for which we are setting up the Maps
tableNumber
,
int
-1 if this table is not the result table; otherwise the index into tableNumbers for the result table
resultTable
,
ValueNode
one side of the = predicate
arg1
,
ValueNode
other side of the = predicate
arg2
)

Set the correct bits in tableColMap and set the boolean value in eqOuterCols given two arguments to an = predicate tableColMap[t] - bit is set if the column is in an = predicate with a column in table t, or a bit is set if the column is in an = predicate with a constant,parameter or correlation variable (for all table t, if this tableColMap is not for the table with the result columns) eqOuterCols[c] - is true if the column is in an = predicate with a constant, parameter or correlation variable

pack-priv boolean

Returns:

Boolean which reflects validity of the tree.
verifyChangeToCNF
()

Verify that changeToCNF() did its job correctly.

pack-priv boolean

Returns:

Boolean which reflects validity of the tree.
verifyEliminateNots
()

Verify that eliminateNots() did its job correctly.

pack-priv boolean

Returns:

Boolean which reflects validity of the tree.
verifyPutAndsOnTop
()

Verify that putAndsOnTop() did its job correctly.

Inherited from org.apache.derby.impl.sql.compile.QueryTreeNode:
acceptacceptChildrenaddTagaddUDTUsagePrivaddUDTUsagePrivbindOffsetFetchbindRowMultiSetbindUserCatalogTypebindUserTypecheckReliabilitycheckReliabilityconvertDefaultNodecopyTagsFromcreateTypeDependencydebugFlushdebugPrintdisablePrivilegeCollectionformatNodeStringgenerateAuthorizeCheckgetBeginOffsetgetClassFactorygetCompilerContextgetContextgetContextManagergetDataDictionarygetDependencyManagergetEndOffsetgetExecutionFactorygetGenericConstantActionFactorygetIntPropertygetLanguageConnectionContextgetLongPropertygetNullNodegetOffsetOrderedNodesgetOptimizerFactorygetOptimizerTracergetParameterTypesgetSchemaDescriptorgetSchemaDescriptorgetStatementTypegetTableDescriptorgetTypeCompilergetUDTDescisAtomicisPrivilegeCollectionRequiredisSessionSchemaisSessionSchemamakeConstantActionmakeTableNamemakeTableNamenodeHeaderoptimizerTracingIsOnorReliabilityparseSearchConditionparseStatementprintLabelprintSubNodesreferencesSessionSchemaresolveTableToSynonymsetBeginOffsetsetEndOffsetsetRefActionInfostackPrinttaggedWithtreePrinttreePrintverifyClassExist