Class UserTypeConstantNode
- java.lang.Object
-
- org.apache.derby.impl.sql.compile.QueryTreeNode
-
- org.apache.derby.impl.sql.compile.ValueNode
-
- org.apache.derby.impl.sql.compile.ConstantNode
-
- org.apache.derby.impl.sql.compile.UserTypeConstantNode
-
- All Implemented Interfaces:
Visitable
class UserTypeConstantNode extends ConstantNode
User type constants. These are created by built-in types that use user types as their implementation. This could also potentially be used by an optimizer that wanted to store plans for frequently-used parameter values. This is also used to represent nulls in user types, which occurs when NULL is inserted into or supplied as the update value for a user type column.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.lang.Object
val
-
Fields inherited from class org.apache.derby.impl.sql.compile.ConstantNode
value
-
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 UserTypeConstantNode(java.sql.Date d, ContextManager cm)
UserTypeConstantNode(java.sql.Time t, ContextManager cm)
UserTypeConstantNode(java.sql.Timestamp t, ContextManager cm)
UserTypeConstantNode(DataValueDescriptor dvd, ContextManager cm)
UserTypeConstantNode(TypeId t, ContextManager cm)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
generateConstant(ExpressionClassBuilder acb, MethodBuilder mb)
Should never be called for UserTypeConstantNode because we have our own generateExpression().(package private) void
generateExpression(ExpressionClassBuilder acb, MethodBuilder mb)
For a UserTypeConstantNode, we have to store away the object somewhere and have a way to get it back at runtime.(package private) java.lang.Object
getConstantValueAsObject()
Return an Object representing the bind time value of this expression tree.java.lang.Object
getObjectValue()
Return the object value of this user defined type.private static TypeId
getTypeId(DataValueDescriptor dvd)
private static int
getWidth(DataValueDescriptor dvd)
(package private) boolean
isNull()
Return whether or not this node represents a typed null constant.-
Methods inherited from class org.apache.derby.impl.sql.compile.ConstantNode
bindExpression, constantExpression, getClone, getOrderableVariantType, getValue, isCloneable, isConstantExpression, isEquivalent, setValue, toString
-
Methods inherited from class org.apache.derby.impl.sql.compile.ValueNode
bindExpression, categorize, changeToCNF, checkIsBoolean, checkTopPredicatesForEqualsConditions, copyFields, eliminateNots, evaluateConstantExpressions, genEqualsFalseTree, generate, genIsNullTree, genSQLJavaSQLTree, getColumnName, getDataValueFactory, getSchemaName, getSourceResultColumn, getTableName, getTablesReferenced, getTransformed, getTypeCompiler, getTypeId, getTypeServices, isBinaryEqualsOperatorNode, isBooleanFalse, isBooleanTrue, isInListProbeNode, isParameterNode, isRelationalOperator, isSameNodeKind, optimizableEqualityNode, preprocess, putAndsOnTop, remapColumnReferencesToExpressions, 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, 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
-
-
-
-
Constructor Detail
-
UserTypeConstantNode
UserTypeConstantNode(TypeId t, ContextManager cm) throws StandardException
- Throws:
StandardException
-
UserTypeConstantNode
UserTypeConstantNode(java.sql.Date d, ContextManager cm) throws StandardException
- Throws:
StandardException
-
UserTypeConstantNode
UserTypeConstantNode(java.sql.Time t, ContextManager cm) throws StandardException
- Throws:
StandardException
-
UserTypeConstantNode
UserTypeConstantNode(java.sql.Timestamp t, ContextManager cm) throws StandardException
- Throws:
StandardException
-
UserTypeConstantNode
UserTypeConstantNode(DataValueDescriptor dvd, ContextManager cm) throws StandardException
- Parameters:
dvd
- Must contain a Date, Time or Timestamp valuecm
- context manager- Throws:
StandardException
-
-
Method Detail
-
getTypeId
private static TypeId getTypeId(DataValueDescriptor dvd)
-
getWidth
private static int getWidth(DataValueDescriptor dvd)
-
getObjectValue
public java.lang.Object getObjectValue()
Return the object value of this user defined type.- Returns:
- the value of this constant. can't use getValue() for this. getValue() returns the DataValueDescriptor for the built-in types that are implemented as user types (date, time, timestamp)
-
isNull
boolean isNull()
Return whether or not this node represents a typed null constant.- Overrides:
isNull
in classConstantNode
-
getConstantValueAsObject
java.lang.Object getConstantValueAsObject()
Return an Object representing the bind time value of this expression tree. If the expression tree does not evaluate to a constant at bind time then we return null. This is useful for bind time resolution of VTIs. RESOLVE: What do we do for primitives?- Overrides:
getConstantValueAsObject
in classValueNode
- Returns:
- An Object representing the bind time value of this expression tree. (null if not a bind time constant.)
-
generateExpression
void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException
For a UserTypeConstantNode, we have to store away the object somewhere and have a way to get it back at runtime. These objects are serializable. This gives us at least two options: 1) serialize it out into a byte array field, and serialize it back in when needed, from the field. 2) have an array of objects in the prepared statement and a #, to find the object directly. Because it is serializable, it will store with the rest of the executable just fine. Choice 2 gives better performance -- the ser/deser cost is paid on database access for the statement, not for each execution of it. However, it requires some infrastructure support from prepared statements. For now, we take choice 3, and make some assumptions about available methods on the user type. This choice has the shortcoming that it will not work for arbitrary user types. REVISIT and implement choice 2 when a general solution is needed.A null is generated as a Null value cast to the type of the constant node.
- Overrides:
generateExpression
in classConstantNode
- Parameters:
acb
- The ExpressionClassBuilder for the class being builtmb
- The method the expression will go into- Throws:
StandardException
- Thrown on error
-
generateConstant
void generateConstant(ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException
Should never be called for UserTypeConstantNode because we have our own generateExpression().- Specified by:
generateConstant
in classConstantNode
- Parameters:
acb
- The ExpressionClassBuilder for the class being builtmb
- The method the expression will go into- Throws:
StandardException
- Thrown on error
-
-