Class UnaryDateTimestampOperatorNode
- java.lang.Object
-
- org.apache.derby.impl.sql.compile.QueryTreeNode
-
- org.apache.derby.impl.sql.compile.ValueNode
-
- org.apache.derby.impl.sql.compile.OperatorNode
-
- org.apache.derby.impl.sql.compile.UnaryOperatorNode
-
- org.apache.derby.impl.sql.compile.UnaryDateTimestampOperatorNode
-
- All Implemented Interfaces:
Visitable
class UnaryDateTimestampOperatorNode extends UnaryOperatorNode
This class implements the timestamp( x) and date(x) functions. These two functions implement a few special cases of string conversions beyond the normal string to date/timestamp casts.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
DATE_METHOD_NAME
(package private) static int
K_DATE
(package private) static int
K_TIMESTAMP
(package private) int
kind
This class is used to hold logically different objects for space efficiency.private static java.lang.String
TIMESTAMP_METHOD_NAME
-
Fields inherited from class org.apache.derby.impl.sql.compile.UnaryOperatorNode
K_BASE, K_XMLPARSE, K_XMLSERIALIZE, methodName, operand, operator, receiverInterfaceType, resultInterfaceType, UnaryArgTypes, UnaryMethodNames, UnaryOperators, UnaryResultTypes
-
Fields inherited from class org.apache.derby.impl.sql.compile.ValueNode
transformed
-
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 Constructor Description UnaryDateTimestampOperatorNode(ValueNode operand, int kind, ContextManager cm)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) ValueNode
bindExpression(FromList fromList, SubqueryList subqueryList, java.util.List<AggregateNode> aggregates)
Called by UnaryOperatorNode.bindExpression.(package private) void
generateExpression(ExpressionClassBuilder acb, MethodBuilder mb)
Do code generation for this unary operator.private void
invalidOperandType()
(package private) boolean
isSameNodeKind(ValueNode o)
Some node classes represent several logical node types (to reduce footprint), which we call kinds.-
Methods inherited from class org.apache.derby.impl.sql.compile.UnaryOperatorNode
acceptChildren, addXmlOpMethodParams, bindOperand, bindParameter, categorize, constantExpression, getOperand, getOperatorString, getOrderableVariantType, getParameterOperand, getReceiverInterfaceName, isConstantExpression, isEquivalent, preprocess, printSubNodes, remapColumnReferencesToExpressions, setMethodName, setOperator, toString
-
Methods inherited from class org.apache.derby.impl.sql.compile.OperatorNode
pushSqlXmlUtil
-
Methods inherited from class org.apache.derby.impl.sql.compile.ValueNode
bindExpression, changeToCNF, checkIsBoolean, checkTopPredicatesForEqualsConditions, copyFields, eliminateNots, evaluateConstantExpressions, genEqualsFalseTree, generate, genIsNullTree, genSQLJavaSQLTree, getClone, getColumnName, getConstantValueAsObject, getDataValueFactory, getSchemaName, getSourceResultColumn, getTableName, getTablesReferenced, getTransformed, getTypeCompiler, getTypeId, getTypeServices, isBinaryEqualsOperatorNode, isBooleanFalse, isBooleanTrue, isCloneable, isInListProbeNode, isParameterNode, isRelationalOperator, optimizableEqualityNode, putAndsOnTop, requiresTypeFromContext, selectivity, setCollationInfo, setCollationInfo, setCollationUsingCompilationSchema, setCollationUsingCompilationSchema, setNullability, setTransformed, setType, setType, setType, updatableByCursor, verifyChangeToCNF, verifyEliminateNots, verifyPutAndsOnTop
-
Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
accept, 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, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setEndOffset, setRefActionInfo, stackPrint, taggedWith, treePrint, treePrint, verifyClassExist
-
-
-
-
Field Detail
-
TIMESTAMP_METHOD_NAME
private static final java.lang.String TIMESTAMP_METHOD_NAME
- See Also:
- Constant Field Values
-
DATE_METHOD_NAME
private static final java.lang.String DATE_METHOD_NAME
- See Also:
- Constant Field Values
-
K_DATE
static final int K_DATE
- See Also:
- Constant Field Values
-
K_TIMESTAMP
static final int K_TIMESTAMP
- See Also:
- Constant Field Values
-
kind
final int kind
This class is used to hold logically different objects for space efficiency.kind
represents the logical object type. See alsoValueNode.isSameNodeKind(org.apache.derby.impl.sql.compile.ValueNode)
.
-
-
Constructor Detail
-
UnaryDateTimestampOperatorNode
UnaryDateTimestampOperatorNode(ValueNode operand, int kind, ContextManager cm) throws StandardException
- Parameters:
operand
- The operand of the functionkind
- The kind of the result, Date or Timestamp.cm
- context manager- Throws:
StandardException
-
-
Method Detail
-
bindExpression
ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, java.util.List<AggregateNode> aggregates) throws StandardException
Called by UnaryOperatorNode.bindExpression. If the operand is a constant then evaluate the function at compile time. Otherwise, if the operand input type is the same as the output type then discard this node altogether. If the function is "date" and the input is a timestamp then change this node to a cast.- Overrides:
bindExpression
in classUnaryOperatorNode
- Parameters:
fromList
- The FROM list for the query this expression is in, for binding columns.subqueryList
- The subquery list being built as we find SubqueryNodesaggregates
- The aggregate list being built as we find AggregateNodes- Returns:
- The new top of the expression tree.
- Throws:
StandardException
- Thrown on error
-
invalidOperandType
private void invalidOperandType() throws StandardException
- Throws:
StandardException
-
generateExpression
void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException
Do code generation for this unary operator.- Overrides:
generateExpression
in classUnaryOperatorNode
- Parameters:
acb
- The ExpressionClassBuilder for the class we're generatingmb
- The method the expression will go into- Throws:
StandardException
- Thrown on error
-
isSameNodeKind
boolean isSameNodeKind(ValueNode o)
Description copied from class:ValueNode
Some node classes represent several logical node types (to reduce footprint), which we call kinds. This means that implementations ofValueNode.isEquivalent(org.apache.derby.impl.sql.compile.ValueNode)
cannot always just useinstanceof
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 ofisEquivalent
.- Overrides:
isSameNodeKind
in classUnaryOperatorNode
- Parameters:
o
- The other value node whose kind we want to compare with.- Returns:
true
ifthis
ando
represent the same logical node type, i.e. kind.
-
-