org.apache.derby.impl.sql.compile
Class QueryTreeNode
- java.lang.Object
-
- org.apache.derby.impl.sql.compile.QueryTreeNode
-
- All Implemented Interfaces:
- Visitable
- Direct Known Subclasses:
- ColumnDefinitionNode, ConstraintDefinitionNode, GetCurrentConnectionNode, MatchingClauseNode, OrderedColumn, OrderedColumnList, Predicate, ResultSetNode, StatementNode, StaticClassFieldReferenceNode, TableName, ValueNode, WindowNode
public abstract class QueryTreeNode extends java.lang.Object implements Visitable
QueryTreeNode is the root class for all query tree nodes. All query tree nodes inherit from QueryTreeNode except for those that extend QueryTreeNodeVector.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description Visitableaccept(Visitor v)Accept a visitor, and callv.visit()on child nodes as necessary.voidaddTag(java.lang.String tag)Add a tag to this Visitable.static voidbindOffsetFetch(ValueNode offset, ValueNode fetchFirst)Bind the parameters of OFFSET n ROWS and FETCH FIRST n ROWS ONLY, if any.DataTypeDescriptorbindRowMultiSet(DataTypeDescriptor originalDTD)Bind the UDTs in a table type.TypeDescriptorbindUserCatalogType(TypeDescriptor td)Bind user defined types as necessaryDataTypeDescriptorbindUserType(DataTypeDescriptor originalDTD)Bind a UDT.voidcheckReliability(int fragmentBitMask, java.lang.String fragmentType)Bind time logic.voidcheckReliability(java.lang.String fragmentType, int fragmentBitMask)Bind time logic.voidcreateTypeDependency(DataTypeDescriptor dtd)Declare a dependency on a type and check that you have privilege to use it.intgetBeginOffset()Gets the beginning offset of the SQL substring which this query node represents.DataDictionarygetDataDictionary()Get the DataDictionaryintgetEndOffset()Gets the ending offset of the SQL substring which this query node represents.ExecutionFactorygetExecutionFactory()GenericConstantActionFactorygetGenericConstantActionFactory()Gets the constant action factory for this database.<N extends QueryTreeNode>
java.util.SortedSet<N>getOffsetOrderedNodes(java.lang.Class<N> type)Get all child nodes of a specific type, and return them in the order in which they appear in the SQL text.OptimizerFactorygetOptimizerFactory()Gets the NodeFactory for this database.OptTracegetOptimizerTracer()Convenience method for finding the optimizer tracerDataTypeDescriptor[]getParameterTypes()Parameter info is stored in the compiler context.AliasDescriptorgetUDTDesc(DataTypeDescriptor dtd)Get the AliasDescriptor of a UDTbooleanisAtomic()ConstantActionmakeConstantAction()This creates a class that will do the work that's constant across all Executions of a PreparedStatement.static TableNamemakeTableName(ContextManager contextManager, java.lang.String schemaName, java.lang.String flatName)TableNamemakeTableName(java.lang.String schemaName, java.lang.String flatName)booleanoptimizerTracingIsOn()Convenience method for checking whether optimizer tracing is onintorReliability(int newBits)OR in more reliability bits and return the old reliability value.booleanreferencesSessionSchema()Return true if the node references SESSION schema tables (temporary or permanent)voidsetBeginOffset(int beginOffset)Sets the beginning offset of the SQL substring which this query node represents.voidsetEndOffset(int endOffset)Sets the ending offset of the SQL substring which this query node represents.booleantaggedWith(java.lang.String tag)Return true if this Visitable is tagged with the indicated tag.java.lang.StringtoString()Format this node as a string Each sub-class of QueryTreeNode should implement its own toString() method.voidtreePrint()Print this tree for debugging purposes.
-
-
-
Method Detail
-
getOptimizerFactory
public final OptimizerFactory getOptimizerFactory()
Gets the NodeFactory for this database.- Returns:
- the node factory for this database.
-
getOptimizerTracer
public OptTrace getOptimizerTracer()
Convenience method for finding the optimizer tracer
-
optimizerTracingIsOn
public boolean optimizerTracingIsOn()
Convenience method for checking whether optimizer tracing is on
-
getGenericConstantActionFactory
public final GenericConstantActionFactory getGenericConstantActionFactory()
Gets the constant action factory for this database.- Returns:
- the constant action factory.
-
getExecutionFactory
public final ExecutionFactory getExecutionFactory()
-
getBeginOffset
public int getBeginOffset()
Gets the beginning offset of the SQL substring which this query node represents.- Returns:
- The beginning offset of the SQL substring. -1 means unknown.
-
setBeginOffset
public void setBeginOffset(int beginOffset)
Sets the beginning offset of the SQL substring which this query node represents.- Parameters:
beginOffset- The beginning offset of the SQL substring.
-
getEndOffset
public int getEndOffset()
Gets the ending offset of the SQL substring which this query node represents.- Returns:
- The ending offset of the SQL substring. -1 means unknown.
-
setEndOffset
public void setEndOffset(int endOffset)
Sets the ending offset of the SQL substring which this query node represents.- Parameters:
endOffset- The ending offset of the SQL substring.
-
treePrint
public void treePrint()
Print this tree for debugging purposes. This recurses through all the sub-nodes and prints them indented by their depth in the tree.
-
toString
public java.lang.String toString()
Format this node as a string Each sub-class of QueryTreeNode should implement its own toString() method. In each case, toString() should format the class members that are not sub-types of QueryTreeNode (printSubNodes() takes care of following the references to sub-nodes, and toString() takes care of all members that are not sub-nodes). Newlines should be used liberally - one good way to do this is to have a newline at the end of each formatted member. It's also a good idea to put the name of each member in front of the formatted value. For example, the code might look like: "memberName: " + memberName + "\n" + ... Vector members containing subclasses of QueryTreeNode should subclass QueryTreeNodeVector. Such subclasses form a special case: These classes should not implement printSubNodes, since there is generic handling in QueryTreeNodeVector. They should only implement toString if they contain additional members.- Overrides:
toStringin classjava.lang.Object- Returns:
- This node formatted as a String
-
referencesSessionSchema
public boolean referencesSessionSchema() throws StandardExceptionReturn true if the node references SESSION schema tables (temporary or permanent)- Returns:
- true if references SESSION schema tables, else false
- Throws:
StandardException- Thrown on error
-
getParameterTypes
public DataTypeDescriptor[] getParameterTypes() throws StandardException
Parameter info is stored in the compiler context. Hide this from the callers.- Returns:
- null
- Throws:
StandardException- on error
-
makeConstantAction
public ConstantAction makeConstantAction() throws StandardException
This creates a class that will do the work that's constant across all Executions of a PreparedStatement. It's up to our subclasses to override this method if they need to compile constant actions into PreparedStatements.- Throws:
StandardException- Thrown on failure
-
getDataDictionary
public final DataDictionary getDataDictionary()
Get the DataDictionary- Returns:
- The DataDictionary
-
accept
public final Visitable accept(Visitor v) throws StandardException
Accept a visitor, and callv.visit()on child nodes as necessary. Sub-classes should not override this method, but instead override theacceptChildren(Visitor)method.- Specified by:
acceptin interfaceVisitable- Parameters:
v- the visitor- Throws:
StandardException- on error
-
addTag
public void addTag(java.lang.String tag)
Description copied from interface:VisitableAdd a tag to this Visitable.
-
taggedWith
public boolean taggedWith(java.lang.String tag)
Description copied from interface:VisitableReturn true if this Visitable is tagged with the indicated tag.- Specified by:
taggedWithin interfaceVisitable
-
makeTableName
public TableName makeTableName(java.lang.String schemaName, java.lang.String flatName) throws StandardException
- Throws:
StandardException
-
makeTableName
public static TableName makeTableName(ContextManager contextManager, java.lang.String schemaName, java.lang.String flatName) throws StandardException
- Throws:
StandardException
-
isAtomic
public boolean isAtomic() throws StandardException- Throws:
StandardException
-
checkReliability
public void checkReliability(java.lang.String fragmentType, int fragmentBitMask) throws StandardExceptionBind time logic. Raises an error if this ValueNode, once compiled, returns unstable results AND if we're in a context where unstable results are forbidden. Called by children who may NOT appear in the WHERE subclauses of ADD TABLE clauses.- Parameters:
fragmentType- Type of fragment as a String, for inclusion in error messages.fragmentBitMask- Type of fragment as a bitmask of possible fragment types- Throws:
StandardException- Thrown on error
-
checkReliability
public void checkReliability(int fragmentBitMask, java.lang.String fragmentType) throws StandardExceptionBind time logic. Raises an error if this ValueNode, once compiled, returns unstable results AND if we're in a context where unstable results are forbidden. Called by children who may NOT appear in the WHERE subclauses of ADD TABLE clauses.- Parameters:
fragmentBitMask- Type of fragment as a bitmask of possible fragment typesfragmentType- Type of fragment as a String, to be fetch for the error message.- Throws:
StandardException- Thrown on error
-
bindUserType
public DataTypeDescriptor bindUserType(DataTypeDescriptor originalDTD) throws StandardException
Bind a UDT. This involves looking it up in the DataDictionary and filling in its class name.- Parameters:
originalDTD- A datatype: might be an unbound UDT and might not be- Returns:
- The bound UDT if originalDTD was an unbound UDT; otherwise returns originalDTD.
- Throws:
StandardException
-
bindUserCatalogType
public TypeDescriptor bindUserCatalogType(TypeDescriptor td) throws StandardException
Bind user defined types as necessary- Throws:
StandardException
-
getUDTDesc
public AliasDescriptor getUDTDesc(DataTypeDescriptor dtd) throws StandardException
Get the AliasDescriptor of a UDT- Throws:
StandardException
-
bindRowMultiSet
public DataTypeDescriptor bindRowMultiSet(DataTypeDescriptor originalDTD) throws StandardException
Bind the UDTs in a table type.- Parameters:
originalDTD- A datatype: might be an unbound UDT and might not be- Returns:
- The bound table type if originalDTD was an unbound table type; otherwise returns originalDTD.
- Throws:
StandardException
-
createTypeDependency
public void createTypeDependency(DataTypeDescriptor dtd) throws StandardException
Declare a dependency on a type and check that you have privilege to use it. This is only used if the type is an ANSI UDT.- Parameters:
dtd- Type which may have a dependency declared on it.- Throws:
StandardException
-
orReliability
public int orReliability(int newBits)
OR in more reliability bits and return the old reliability value.
-
bindOffsetFetch
public static void bindOffsetFetch(ValueNode offset, ValueNode fetchFirst) throws StandardException
Bind the parameters of OFFSET n ROWS and FETCH FIRST n ROWS ONLY, if any.- Parameters:
offset- the OFFSET parameter, if anyfetchFirst- the FETCH parameter, if any- Throws:
StandardException- Thrown on error
-
getOffsetOrderedNodes
public <N extends QueryTreeNode> java.util.SortedSet<N> getOffsetOrderedNodes(java.lang.Class<N> type) throws StandardException
Get all child nodes of a specific type, and return them in the order in which they appear in the SQL text.- Type Parameters:
N- the type of node to look for- Parameters:
type- the type of node to look for- Returns:
- all nodes of the specified type
- Throws:
StandardException- if an error occurs
-
-
DataMelt 3.0 © DataMelt by jWork.ORG