Visitable
BaseColumnNode
, BinaryListOperatorNode
, CachedValueNode
, CastNode
, CoalesceFunctionNode
, ColumnReference
, ConditionalNode
, ConstantNode
, CurrentDatetimeOperatorNode
, CurrentRowLocationNode
, DefaultNode
, GenerationClauseNode
, JavaToSQLValueNode
, NextSequenceNode
, OperatorNode
, ParameterNode
, ResultColumn
, SpecialFunctionNode
, SubqueryNode
, VirtualColumnNode
public abstract class ValueNode extends QueryTreeNode
Modifier and Type | Field | Description |
---|---|---|
private DataTypeDescriptor |
dataTypeServices |
The data type for this node.
|
(package private) boolean |
transformed |
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_CYCLE, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX
Constructor | Description |
---|---|
ValueNode(ContextManager cm) |
Modifier and Type | Method | Description |
---|---|---|
(package private) ValueNode |
bindExpression(FromList fromList,
SubqueryList subqueryList,
java.util.List<AggregateNode> aggregates) |
|
(package private) ValueNode |
bindExpression(FromList fromList,
SubqueryList subqueryList,
java.util.List<AggregateNode> aggregates,
boolean forQueryRewrite) |
Bind this expression.
|
(package private) boolean |
categorize(JBitSet referencedTabs,
boolean simplePredsOnly) |
Categorize this predicate.
|
(package private) ValueNode |
changeToCNF(boolean underTopAndNode) |
Finish putting an expression into conjunctive normal
form.
|
ValueNode |
checkIsBoolean() |
Bind time logic.
|
(package private) void |
checkTopPredicatesForEqualsConditions(int tableNumber,
boolean[] eqOuterCols,
int[] tableNumbers,
JBitSet[] tableColMap,
boolean resultColTable) |
Update the array of columns in = conditions with expressions without
column references from the same table.
|
(package private) boolean |
constantExpression(PredicateList whereClause) |
Return whether or not this expression tree represents a constant value.
|
(package private) void |
copyFields(ValueNode oldVN) |
Copy all of the "appropriate fields" for a shallow copy.
|
(package private) ValueNode |
eliminateNots(boolean underNotNode) |
Eliminate NotNodes in the current query block.
|
(package private) ValueNode |
evaluateConstantExpressions() |
If this node is known to always evaluate to the same value, return a
node that represents that known value as a constant.
|
(package private) ValueNode |
genEqualsFalseTree() |
Transform this into this = false.
|
(package private) void |
generate(ActivationClassBuilder acb,
MethodBuilder mb) |
Do the code generation for this node.
|
(package private) void |
generateExpression(ExpressionClassBuilder acb,
MethodBuilder mb) |
Generate code for this calculation.
|
(package private) ValueNode |
genIsNullTree(boolean notNull) |
Transform this into this IS NULL or IS NOT NULL.
|
(package private) ValueNode |
genSQLJavaSQLTree() |
Generate a SQL->Java->SQL conversion tree above the current node
and bind the new nodes individually.
|
(package private) ValueNode |
getClone() |
Return a clone of this node.
|
(package private) java.lang.String |
getColumnName() |
This is null so that the caller will substitute in the resultset generated
name as needed.
|
(package private) java.lang.Object |
getConstantValueAsObject() |
Return an Object representing the bind time value of this
expression tree.
|
protected DataValueFactory |
getDataValueFactory() |
Return the DataValueFactory
|
protected int |
getOrderableVariantType() |
Return the variant type for the underlying expression.
|
(package private) java.lang.String |
getSchemaName() |
This returns the user-supplied schema name of the column.
|
(package private) ResultColumn |
getSourceResultColumn() |
Get the source for this ValueNode.
|
(package private) java.lang.String |
getTableName() |
This returns the user-supplied table name of the column.
|
(package private) JBitSet |
getTablesReferenced() |
Get a bit map of table references in this expression
|
(package private) boolean |
getTransformed() |
Return whether or not this predicate has been transformed.
|
(package private) TypeCompiler |
getTypeCompiler() |
Get the TypeCompiler from this ValueNode, based on its TypeId
using getTypeId().
|
(package private) TypeId |
getTypeId() |
Get the TypeId from this ValueNode.
|
(package private) DataTypeDescriptor |
getTypeServices() |
Get the DataTypeServices from this ValueNode.
|
(package private) boolean |
isBinaryEqualsOperatorNode() |
Returns true if this value node is a equals operator.
|
(package private) boolean |
isBooleanFalse() |
Does this represent a false constant.
|
(package private) boolean |
isBooleanTrue() |
Does this represent a true constant.
|
(package private) boolean |
isCloneable() |
Return whether or not this expression tree is cloneable.
|
(package private) boolean |
isConstantExpression() |
Return whether or not this expression tree represents a constant expression.
|
(package private) abstract boolean |
isEquivalent(ValueNode other) |
Tests if this node is equivalent to the specified ValueNode.
|
(package private) boolean |
isInListProbeNode() |
Returns true if this value node is an operator created
for optimized performance of an IN list.
|
(package private) boolean |
isParameterNode() |
Returns TRUE if this is a parameter node.
|
(package private) boolean |
isRelationalOperator() |
Returns true if this ValueNode is a relational operator.
|
(package private) boolean |
isSameNodeKind(ValueNode other) |
Some node classes represent several logical node types (to reduce
footprint), which we call kinds.
|
(package private) boolean |
optimizableEqualityNode(Optimizable optTable,
int columnNumber,
boolean isNullOkay) |
Return true if the predicate represents an optimizable equality node.
|
(package private) ValueNode |
preprocess(int numTables,
FromList outerFromList,
SubqueryList outerSubqueryList,
PredicateList outerPredicateList) |
Preprocess an expression tree.
|
(package private) ValueNode |
putAndsOnTop() |
Do the 1st step in putting an expression into conjunctive normal
form.
|
(package private) ValueNode |
remapColumnReferencesToExpressions() |
Remap all ColumnReferences in this tree to be clones of the
underlying expression.
|
(package private) boolean |
requiresTypeFromContext() |
Returns TRUE if the type of this node will be determined from the
context in which it is getting used.
|
double |
selectivity(Optimizable optTable) |
The default selectivity for value nodes is 50%.
|
void |
setCollationInfo(int collationType,
int collationDerivation) |
Set the collation type and derivation of this node based upon
the collation information passed in.
|
void |
setCollationInfo(DataTypeDescriptor collationInfoType) |
Set the collation type and derivation of this node based upon
the collation information in the passed in type.
|
protected void |
setCollationUsingCompilationSchema() |
Set the collation based upon the current schema with derivation
type implicit.
|
protected void |
setCollationUsingCompilationSchema(int 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.
|
void |
setNullability(boolean nullability) |
Set the nullability of this value.
|
(package private) void |
setTransformed() |
Mark this predicate has having been transformed (other predicates
were generated from it).
|
(package private) void |
setType(DataTypeDescriptor dataTypeServices) |
Set the DataTypeServices for this ValueNode.
|
(package private) void |
setType(TypeId typeId,
boolean isNullable,
int maximumWidth) |
Set this node's type from type components.
|
(package private) void |
setType(TypeId typeId,
int precision,
int scale,
boolean isNullable,
int maximumWidth) |
Set this node's type from type components.
|
private void |
setValueCols(JBitSet[] tableColMap,
boolean[] eqOuterCols,
int colReference,
int 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.
|
java.lang.String |
toString() |
Convert this object to a String.
|
boolean |
updatableByCursor() |
|
private void |
updateMaps(JBitSet[] tableColMap,
boolean[] eqOuterCols,
int[] tableNumbers,
int tableNumber,
int resultTable,
ValueNode arg1,
ValueNode 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
|
(package private) boolean |
verifyChangeToCNF() |
Verify that changeToCNF() did its job correctly.
|
(package private) boolean |
verifyEliminateNots() |
Verify that eliminateNots() did its job correctly.
|
(package private) boolean |
verifyPutAndsOnTop() |
Verify that putAndsOnTop() did its job correctly.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
accept, acceptChildren, addTag, addUDTUsagePriv, addUDTUsagePriv, bindOffsetFetch, bindRowMultiSet, bindUserCatalogType, bindUserType, checkReliability, checkReliability, convertDefaultNode, copyTagsFrom, createTypeDependency, debugFlush, debugPrint, disablePrivilegeCollection, formatNodeString, 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, isAtomic, isPrivilegeCollectionRequired, isSessionSchema, isSessionSchema, makeConstantAction, makeTableName, makeTableName, nodeHeader, optimizerTracingIsOn, orReliability, parseSearchCondition, parseStatement, printLabel, printSubNodes, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setEndOffset, setRefActionInfo, stackPrint, taggedWith, treePrint, treePrint, verifyClassExist
private DataTypeDescriptor dataTypeServices
boolean transformed
ValueNode(ContextManager cm)
final void setType(TypeId typeId, boolean isNullable, int maximumWidth) throws StandardException
StandardException
final void setType(TypeId typeId, int precision, int scale, boolean isNullable, int maximumWidth) throws StandardException
StandardException
public java.lang.String toString()
toString
in class QueryTreeNode
DataTypeDescriptor getTypeServices()
public void setNullability(boolean nullability) throws StandardException
StandardException
public void setCollationInfo(DataTypeDescriptor collationInfoType) throws StandardException
collationInfoType
- Type to take collation type and derivation from.StandardException
- Error setting type.public void setCollationInfo(int collationType, int collationDerivation) throws StandardException
collationType
- Collation typecollationDerivation
- Collation derivationStandardException
- Error setting typeTypeId getTypeId() throws StandardException
StandardException
protected final DataValueFactory getDataValueFactory()
final TypeCompiler getTypeCompiler() throws StandardException
StandardException
void setType(DataTypeDescriptor dataTypeServices) throws StandardException
dataTypeServices
- The DataTypeServices to set in this
ValueNodeStandardException
protected final void setCollationUsingCompilationSchema() throws StandardException
StandardException
protected final void setCollationUsingCompilationSchema(int collationDerivation) throws StandardException
collationDerivation
- This can be
StringDataValue#COLLATION_DERIVATION_IMPLICIT
StringDataValue#COLLATION_DERIVATION_NONE
StringDataValue#COLLATION_DERIVATION_EXPLICITStandardException
ResultColumn getSourceResultColumn()
void setTransformed()
boolean getTransformed()
ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, java.util.List<AggregateNode> aggregates) throws StandardException
StandardException
ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, java.util.List<AggregateNode> aggregates, boolean forQueryRewrite) throws StandardException
fromList
- The FROM list to use for bindingsubqueryList
- The SubqueryList we are building as we hit
SubqueryNodes.aggregates
- The aggregate list being built as we find AggregateNodesStandardException
- Thrown on errorValueNode genSQLJavaSQLTree() throws StandardException
StandardException
- Thrown on errorValueNode preprocess(int numTables, FromList outerFromList, SubqueryList outerSubqueryList, PredicateList outerPredicateList) throws StandardException
numTables
- Number of tables in the DML StatementouterFromList
- FromList from outer query blockouterSubqueryList
- SubqueryList from outer query blockouterPredicateList
- PredicateList from outer query blockStandardException
- Thrown on errorValueNode evaluateConstantExpressions() throws StandardException
this
if the value is not knownStandardException
- if an error occurs during evaluationConstantExpressionVisitor
ValueNode eliminateNots(boolean underNotNode) throws StandardException
underNotNode
- Whether or not we are under a NotNode.StandardException
- Thrown on errorValueNode genEqualsFalseTree() throws StandardException
StandardException
- Thrown on errorValueNode genIsNullTree(boolean notNull) throws StandardException
notNull
- if true, transform this into IS NOT NULL;
otherwise, transform this into IS NULLStandardException
- Thrown on errorboolean verifyEliminateNots()
ValueNode putAndsOnTop() throws StandardException
StandardException
- Thrown on errorboolean verifyPutAndsOnTop()
ValueNode changeToCNF(boolean underTopAndNode) throws StandardException
underTopAndNode
- Whether or not we are under a top level AndNode.StandardException
- Thrown on errorboolean verifyChangeToCNF()
boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly) throws StandardException
referencedTabs
- JBitSet with bit map of referenced FromTablessimplePredsOnly
- Whether or not to consider method
calls, field references and conditional nodes
when building bit mapStandardException
- Thrown on errorjava.lang.String getSchemaName() throws StandardException
StandardException
java.lang.String getTableName()
public boolean updatableByCursor()
java.lang.String getColumnName()
JBitSet getTablesReferenced() throws StandardException
StandardException
- Thrown on errorboolean isCloneable()
ValueNode getClone() throws StandardException
StandardException
- Thrown on errorvoid copyFields(ValueNode oldVN) throws StandardException
oldVN
- The ValueNode to copy from.StandardException
ValueNode remapColumnReferencesToExpressions() throws StandardException
StandardException
- Thrown on errorboolean isConstantExpression()
boolean constantExpression(PredicateList whereClause)
protected int getOrderableVariantType() throws StandardException
StandardException
- Thrown on errorpublic ValueNode checkIsBoolean() throws StandardException
StandardException
- Thrown on errorjava.lang.Object getConstantValueAsObject() throws StandardException
StandardException
- Thrown on errorfinal void generate(ActivationClassBuilder acb, MethodBuilder mb) throws StandardException
generate
in class QueryTreeNode
acb
- The ActivationClassBuilder for the class being builtmb
- The method the expression will go intoStandardException
- Thrown on errorpublic double selectivity(Optimizable optTable) throws StandardException
StandardException
void checkTopPredicatesForEqualsConditions(int tableNumber, boolean[] eqOuterCols, int[] tableNumbers, JBitSet[] tableColMap, boolean resultColTable) throws StandardException
tableNumber
- The tableNumber of the table from which
the columns of interest come from.eqOuterCols
- Array of booleans for noting which columns
are in = predicates without columns from the
subquery block. May be null.tableNumbers
- Array of table numbers in this query block.tableColMap
- Array of bits for noting which columns
are in = predicates for each table in the
query block. May be null.resultColTable
- True if tableNumber is the table containing result
columnsStandardException
- Thrown on errorboolean isBooleanTrue()
boolean isBooleanFalse()
void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException
acb
- The ExpressionClassBuilder for the class being builtmb
- The method the expression will go intoStandardException
- Thrown on errorprivate void updateMaps(JBitSet[] tableColMap, boolean[] eqOuterCols, int[] tableNumbers, int tableNumber, int resultTable, ValueNode arg1, ValueNode arg2) throws StandardException
tableColMap
- Array of bitmaps for noting which columns are in =
predicates with columns from each tableeqOuterCols
- Array of booleans for noting which columns
are in = predicates without columns from the
subquery block.tableNumber
- table number for which we are setting up the MapsresultTable
- -1 if this table is not the result table; otherwise
the index into tableNumbers for the result tablearg1
- one side of the = predicatearg2
- other side of the = predicateStandardException
- Thrown on errorprivate void setValueCols(JBitSet[] tableColMap, boolean[] eqOuterCols, int colReference, int resultTable)
tableColMap
- Array of bitmaps for noting which columns are in =
predicates with columns from each tableeqOuterCols
- Array of booleans for noting which columns
are in = predicates without columns from the
subquery block.colReference
- The column to setresultTable
- If -1 set all the bit for all the tables for that
column; otherwise set the bit for the specified tableboolean isRelationalOperator()
RelationalOperator
,
BinaryRelationalOperatorNode
,
IsNullNode
boolean isBinaryEqualsOperatorNode()
isRelationalOperator()
boolean isInListProbeNode()
boolean optimizableEqualityNode(Optimizable optTable, int columnNumber, boolean isNullOkay) throws StandardException
optTable
- the table being optimized. Column reference must be from
this table.columnNumber
- the column number. One of the operands of this
predicate must be the column number specified by optTable/columnNumberisNullOkay
- if set to true we also consider IS NULL predicates;
otherwise consider only = predicates.StandardException
boolean requiresTypeFromContext()
boolean isParameterNode()
abstract boolean isEquivalent(ValueNode other) throws StandardException
This method provides basic expression matching facility for the derived class of ValueNode and it is used by the language layer to compare the node structural form of the two expressions for equivalence at bind phase.
Note that it is not comparing the actual row values at runtime to produce a result; hence, when comparing SQL NULLs, they are considered to be equivalent and not unknown.
One usage case of this method in this context is to compare the select column expression against the group by expression to check if they are equivalent. e.g.:
SELECT c1+c2 FROM t1 GROUP BY c1+c2
In general, node equivalence is determined by the derived class of ValueNode. But they generally abide to the rules below:
other
- the node to compare this ValueNode against.true
if the two nodes are equivalent,
false
otherwise.StandardException
boolean isSameNodeKind(ValueNode other)
isEquivalent(org.apache.derby.impl.sql.compile.ValueNode)
cannot always just use instanceof
to check if the other node
represents the same kind. Hence this method needs to be
overridden by all node classes that represent several kinds.
This default implementation does not look at kinds.
It is only called from implementations of isEquivalent
.other
- The other value node whose kind we want to compare with.true
if this
and o
represent the same
logical node type, i.e. kind.Apache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.