Visitable
JavaValueNode
, MatchingClauseNode
, OrderedColumn
, Predicate
, PrivilegeNode
, QueryTreeNodeVector
, ResultSetNode
, StatementNode
, TableElementNode
, TableName
, TablePrivilegesNode
, ValueNode
, WindowNode
public abstract class QueryTreeNode extends java.lang.Object implements Visitable
Modifier and Type | Field | Description |
---|---|---|
(package private) static int |
AUTOINCREMENT_CREATE_MODIFY |
|
(package private) static int |
AUTOINCREMENT_CYCLE |
|
(package private) static int |
AUTOINCREMENT_INC_INDEX |
|
(package private) static int |
AUTOINCREMENT_IS_AUTOINCREMENT_INDEX |
|
(package private) static int |
AUTOINCREMENT_START_INDEX |
|
private int |
beginOffset |
|
private ContextManager |
cm |
|
private GenericConstantActionFactory |
constantActionFactory |
|
private int |
endOffset |
|
private boolean |
isPrivilegeCollectionRequired |
In Derby SQL Standard Authorization, views, triggers and constraints
execute with definer's privileges.
|
private LanguageConnectionContext |
lcc |
|
private java.util.ArrayList<java.lang.String> |
visitableTags |
Constructor | Description |
---|---|
QueryTreeNode(ContextManager cm) |
Modifier and Type | Method | Description |
---|---|---|
Visitable |
accept(Visitor v) |
Accept a visitor, and call
v.visit() on child nodes as
necessary. |
(package private) void |
acceptChildren(Visitor v) |
Accept a visitor on all child nodes.
|
void |
addTag(java.lang.String tag) |
Add a tag to this Visitable.
|
(package private) void |
addUDTUsagePriv(java.util.List<ValueNode> valueNodes) |
Add USAGE privilege for all UDTs mentioned in the indicated ValueNodes.
|
(package private) void |
addUDTUsagePriv(ValueNode val) |
Add USAGE privilege for a single UDT.
|
static void |
bindOffsetFetch(ValueNode offset,
ValueNode fetchFirst) |
Bind the parameters of OFFSET n ROWS and FETCH FIRST n ROWS ONLY, if
any.
|
DataTypeDescriptor |
bindRowMultiSet(DataTypeDescriptor originalDTD) |
Bind the UDTs in a table type.
|
TypeDescriptor |
bindUserCatalogType(TypeDescriptor td) |
Bind user defined types as necessary
|
DataTypeDescriptor |
bindUserType(DataTypeDescriptor originalDTD) |
Bind a UDT.
|
void |
checkReliability(int fragmentBitMask,
java.lang.String fragmentType) |
Bind time logic.
|
void |
checkReliability(java.lang.String fragmentType,
int fragmentBitMask) |
Bind time logic.
|
private static boolean |
containsInfo(java.lang.String str) |
|
(package private) DataValueDescriptor |
convertDefaultNode(DataTypeDescriptor typeDescriptor) |
Translate a Default node into a default value, given a type descriptor.
|
protected void |
copyTagsFrom(QueryTreeNode that) |
Copy the tags from another QueryTreeNode
|
private void |
createTypeDependency(AliasDescriptor ad) |
Declare a dependency on an ANSI UDT, identified by its AliasDescriptor,
and check that you have privilege to use it.
|
void |
createTypeDependency(DataTypeDescriptor dtd) |
Declare a dependency on a type and check that you have privilege to use
it.
|
protected static void |
debugFlush() |
Flush the debug stream out
|
(package private) static void |
debugPrint(java.lang.String outputString) |
Print a String for debugging
|
(package private) void |
disablePrivilegeCollection() |
Triggers, constraints and views get executed with their definers'
privileges and they can exist in the system only if their definers
still have all the privileges to create them.
|
(package private) static java.lang.String |
formatNodeString(java.lang.String nodeString,
int depth) |
Format a node that has been converted to a String for printing
as part of a tree.
|
(package private) void |
generate(ActivationClassBuilder acb,
MethodBuilder mb) |
Do the code generation for this node.
|
(package private) void |
generateAuthorizeCheck(ActivationClassBuilder acb,
MethodBuilder mb,
int sqlOperation) |
Add an authorization check into the passed in method.
|
int |
getBeginOffset() |
Gets the beginning offset of the SQL substring which this
query node represents.
|
protected ClassFactory |
getClassFactory() |
Get the ClassFactory to use with this database.
|
protected CompilerContext |
getCompilerContext() |
Get the CompilerContext
|
(package private) static Context |
getContext(java.lang.String contextID) |
Privileged lookup of a Context.
|
(package private) ContextManager |
getContextManager() |
Get the current ContextManager.
|
DataDictionary |
getDataDictionary() |
Get the DataDictionary
|
(package private) DependencyManager |
getDependencyManager() |
|
int |
getEndOffset() |
Gets the ending offset of the SQL substring which this
query node represents.
|
ExecutionFactory |
getExecutionFactory() |
|
GenericConstantActionFactory |
getGenericConstantActionFactory() |
Gets the constant action factory for this database.
|
protected int |
getIntProperty(java.lang.String value,
java.lang.String key) |
Get the int value of a Property
|
protected LanguageConnectionContext |
getLanguageConnectionContext() |
Gets the LanguageConnectionContext for this connection.
|
protected long |
getLongProperty(java.lang.String value,
java.lang.String key) |
Get the long value of a Property
|
(package private) ConstantNode |
getNullNode(DataTypeDescriptor type) |
Get a ConstantNode to represent a typed null value.
|
<N extends QueryTreeNode> |
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.
|
OptimizerFactory |
getOptimizerFactory() |
Gets the NodeFactory for this database.
|
OptTrace |
getOptimizerTracer() |
Convenience method for finding the optimizer tracer
|
DataTypeDescriptor[] |
getParameterTypes() |
Parameter info is stored in the compiler context.
|
(package private) SchemaDescriptor |
getSchemaDescriptor(java.lang.String schemaName) |
Get the descriptor for the named schema.
|
(package private) SchemaDescriptor |
getSchemaDescriptor(java.lang.String schemaName,
boolean raiseError) |
Get the descriptor for the named schema.
|
protected int |
getStatementType() |
Return the type of statement, something from
StatementType.
|
protected TableDescriptor |
getTableDescriptor(java.lang.String tableName,
SchemaDescriptor schema) |
Get the descriptor for the named table within the given schema.
|
protected TypeCompiler |
getTypeCompiler(TypeId typeId) |
Get the TypeCompiler associated with the given TypeId
|
AliasDescriptor |
getUDTDesc(DataTypeDescriptor dtd) |
Get the AliasDescriptor of a UDT
|
boolean |
isAtomic() |
|
(package private) boolean |
isPrivilegeCollectionRequired() |
Return true from this method means that we need to collect privilege
requirement for this node.
|
(package private) static boolean |
isSessionSchema(java.lang.String schemaName) |
Checks if the passed schema name is for SESSION schema
|
(package private) boolean |
isSessionSchema(SchemaDescriptor sd) |
Checks if the passed schema descriptor is for SESSION schema
|
ConstantAction |
makeConstantAction() |
This creates a class that will do the work that's constant
across all Executions of a PreparedStatement.
|
TableName |
makeTableName(java.lang.String schemaName,
java.lang.String flatName) |
|
static TableName |
makeTableName(ContextManager contextManager,
java.lang.String schemaName,
java.lang.String flatName) |
|
protected java.lang.String |
nodeHeader() |
Return header information for debug printing of this query
tree node.
|
boolean |
optimizerTracingIsOn() |
Convenience method for checking whether optimizer tracing is on
|
int |
orReliability(int newBits) |
OR in more reliability bits and return the old reliability value.
|
(package private) ValueNode |
parseSearchCondition(java.lang.String sql,
boolean internalSQL) |
Parse an SQL fragment that represents a
<search condition> . |
(package private) StatementNode |
parseStatement(java.lang.String sql,
boolean internalSQL) |
Parse the a SQL statement from the body
of another SQL statement.
|
private Visitable |
parseStatementOrSearchCondition(java.lang.String sql,
boolean internalSQL,
boolean isStatement) |
Parse a full SQL statement or a fragment representing a
<search
condition> . |
(package private) void |
printLabel(int depth,
java.lang.String label) |
Print the given label at the given indentation depth.
|
(package private) void |
printSubNodes(int depth) |
Print the sub-nodes of this node.
|
boolean |
referencesSessionSchema() |
Return true if the node references SESSION schema tables (temporary or permanent)
|
(package private) TableName |
resolveTableToSynonym(TableName tabName) |
Resolve table/view reference to a synonym.
|
void |
setBeginOffset(int beginOffset) |
Sets the beginning offset of the SQL substring which this
query node represents.
|
void |
setEndOffset(int endOffset) |
Sets the ending offset of the SQL substring which this
query node represents.
|
(package private) void |
setRefActionInfo(long fkIndexConglomId,
int[] fkColArray,
java.lang.String parentResultSetId,
boolean dependentScan) |
set the Information gathered from the parent table that is
required to perform a referential action on dependent table.
|
(package private) void |
stackPrint() |
Print call stack for debug purposes
|
boolean |
taggedWith(java.lang.String tag) |
Return true if this Visitable is tagged with the indicated tag.
|
private void |
throwReliabilityException(java.lang.String fragmentType,
int fragmentBitMask) |
Common code for the 2 checkReliability functions.
|
java.lang.String |
toString() |
Format this node as a string
Each sub-class of QueryTreeNode should implement its own toString()
method.
|
void |
treePrint() |
Print this tree for debugging purposes.
|
(package private) void |
treePrint(int depth) |
Print this tree for debugging purposes.
|
(package private) void |
verifyClassExist(java.lang.String javaClassName) |
Verify that a java class exists, is accessible (public)
and not a class representing a primitive type.
|
static final int AUTOINCREMENT_START_INDEX
static final int AUTOINCREMENT_INC_INDEX
static final int AUTOINCREMENT_IS_AUTOINCREMENT_INDEX
static final int AUTOINCREMENT_CREATE_MODIFY
static final int AUTOINCREMENT_CYCLE
private int beginOffset
private int endOffset
private ContextManager cm
private LanguageConnectionContext lcc
private GenericConstantActionFactory constantActionFactory
private java.util.ArrayList<java.lang.String> visitableTags
private boolean isPrivilegeCollectionRequired
QueryTreeNode(ContextManager cm)
final ContextManager getContextManager()
public final OptimizerFactory getOptimizerFactory()
public OptTrace getOptimizerTracer()
public boolean optimizerTracingIsOn()
public final GenericConstantActionFactory getGenericConstantActionFactory()
public final ExecutionFactory getExecutionFactory()
protected final ClassFactory getClassFactory()
protected final LanguageConnectionContext getLanguageConnectionContext()
public int getBeginOffset()
public void setBeginOffset(int beginOffset)
beginOffset
- The beginning offset of the SQL substring.public int getEndOffset()
public void setEndOffset(int endOffset)
endOffset
- The ending offset of the SQL substring.protected java.lang.String nodeHeader()
static java.lang.String formatNodeString(java.lang.String nodeString, int depth)
nodeString
- The node formatted as a Stringdepth
- The depth to indent the given nodepublic void treePrint()
void stackPrint()
void treePrint(int depth)
depth
- The depth of this node in the tree, thus,
the amount to indent it when printing it.private static boolean containsInfo(java.lang.String str)
static void debugPrint(java.lang.String outputString)
outputString
- The String to printprotected static void debugFlush()
void printSubNodes(int depth)
depth
- The depth to indent the sub-nodespublic java.lang.String toString()
toString
in class java.lang.Object
void printLabel(int depth, java.lang.String label)
depth
- The depth of indentation to use when printing
the labellabel
- The String to printpublic boolean referencesSessionSchema() throws StandardException
StandardException
- Thrown on errorfinal boolean isSessionSchema(SchemaDescriptor sd)
StandardException
- Thrown on errorstatic boolean isSessionSchema(java.lang.String schemaName)
StandardException
- Thrown on errorfinal void disablePrivilegeCollection()
boolean isPrivilegeCollectionRequired() throws StandardException
StandardException
void generate(ActivationClassBuilder acb, MethodBuilder mb) throws StandardException
acb
- The ActivationClassBuilder for the class being builtmb
- The method for the generated code to go intoStandardException
- Thrown on errorpublic DataTypeDescriptor[] getParameterTypes() throws StandardException
StandardException
- on errorpublic ConstantAction makeConstantAction() throws StandardException
StandardException
- Thrown on failurepublic final DataDictionary getDataDictionary()
final DependencyManager getDependencyManager()
protected final CompilerContext getCompilerContext()
protected final TypeCompiler getTypeCompiler(TypeId typeId)
typeId
- The TypeId to get a TypeCompiler forpublic final Visitable accept(Visitor v) throws StandardException
v.visit()
on child nodes as
necessary. Sub-classes should not override this method, but instead
override the acceptChildren(Visitor)
method.accept
in interface Visitable
v
- the visitorStandardException
- on errorvoid acceptChildren(Visitor v) throws StandardException
accept(v)
on all visitable fields, as well as
super.acceptChildren(v)
to make sure all visitable fields
defined by the super-class are accepted too.v
- the visitorStandardException
- on errors raised by the visitorpublic void addTag(java.lang.String tag)
Visitable
public boolean taggedWith(java.lang.String tag)
Visitable
taggedWith
in interface Visitable
protected void copyTagsFrom(QueryTreeNode that)
protected int getIntProperty(java.lang.String value, java.lang.String key) throws StandardException
value
- Property value as a Stringkey
- Key value of propertyStandardException
- Thrown on failureprotected long getLongProperty(java.lang.String value, java.lang.String key) throws StandardException
value
- Property value as a Stringkey
- Key value of propertyStandardException
- Thrown on failureStatementNode parseStatement(java.lang.String sql, boolean internalSQL) throws StandardException
StandardException
ValueNode parseSearchCondition(java.lang.String sql, boolean internalSQL) throws StandardException
<search condition>
.sql
- a fragment of an SQL statementinternalSQL
- true
if the SQL fragment is allowed to
contain internal syntax, false
otherwiseValueNode
representing the parse tree of the
SQL fragmentStandardException
- if an error happens while parsingprivate Visitable parseStatementOrSearchCondition(java.lang.String sql, boolean internalSQL, boolean isStatement) throws StandardException
<search
condition>
. This is a worker method that contains common logic for
parseStatement(java.lang.String, boolean)
and parseSearchCondition(java.lang.String, boolean)
.sql
- the SQL statement or fragment to parseinternalSQL
- true
if it is allowed to contain internal
syntax, false
otherwiseisStatement
- true
if sql
is a full SQL statement,
false
if it is a fragmentStandardException
- if an error happens while parsingprotected int getStatementType()
ConstantNode getNullNode(DataTypeDescriptor type) throws StandardException
type
- Type of the null node.StandardException
- Thrown on errorDataValueDescriptor convertDefaultNode(DataTypeDescriptor typeDescriptor) throws StandardException
typeDescriptor
- A description of the required data type.StandardException
- Thrown on errorpublic TableName makeTableName(java.lang.String schemaName, java.lang.String flatName) throws StandardException
StandardException
public static TableName makeTableName(ContextManager contextManager, java.lang.String schemaName, java.lang.String flatName) throws StandardException
StandardException
public boolean isAtomic() throws StandardException
StandardException
protected final TableDescriptor getTableDescriptor(java.lang.String tableName, SchemaDescriptor schema) throws StandardException
tableName
- The name of the table to get the descriptor forschema
- The descriptor for the schema the table lives in.
If null, use the current (default) schema.StandardException
- Thrown on failurefinal SchemaDescriptor getSchemaDescriptor(java.lang.String schemaName) throws StandardException
schemaName
- The name of the schema we're interested in.
If the name is NULL, get the descriptor for the
current compilation schema.StandardException
- Thrown on errorfinal SchemaDescriptor getSchemaDescriptor(java.lang.String schemaName, boolean raiseError) throws StandardException
schemaName
- The name of the schema we're interested in.
If the name is NULL, get the descriptor for the current compilation schema.raiseError
- True to raise an error if the schema does not exist,
false to return null if the schema does not exist.StandardException
- Schema does not exist and raiseError is true.TableName resolveTableToSynonym(TableName tabName) throws StandardException
tabName
- to match for a synonymStandardException
- Thrown on errorvoid verifyClassExist(java.lang.String javaClassName) throws StandardException
javaClassName
- The name of the java class to resolve.StandardException
- Thrown on errorvoid setRefActionInfo(long fkIndexConglomId, int[] fkColArray, java.lang.String parentResultSetId, boolean dependentScan)
void generateAuthorizeCheck(ActivationClassBuilder acb, MethodBuilder mb, int sqlOperation)
public void checkReliability(java.lang.String fragmentType, int fragmentBitMask) throws StandardException
fragmentType
- Type of fragment as a String, for inclusion in error messages.fragmentBitMask
- Type of fragment as a bitmask of possible fragment typesStandardException
- Thrown on errorpublic void checkReliability(int fragmentBitMask, java.lang.String fragmentType) throws StandardException
fragmentBitMask
- Type of fragment as a bitmask of possible fragment typesfragmentType
- Type of fragment as a String, to be fetch for the error message.StandardException
- Thrown on errorpublic DataTypeDescriptor bindUserType(DataTypeDescriptor originalDTD) throws StandardException
originalDTD
- A datatype: might be an unbound UDT and might not beStandardException
public TypeDescriptor bindUserCatalogType(TypeDescriptor td) throws StandardException
StandardException
public AliasDescriptor getUDTDesc(DataTypeDescriptor dtd) throws StandardException
StandardException
void addUDTUsagePriv(java.util.List<ValueNode> valueNodes) throws StandardException
StandardException
void addUDTUsagePriv(ValueNode val) throws StandardException
StandardException
public DataTypeDescriptor bindRowMultiSet(DataTypeDescriptor originalDTD) throws StandardException
originalDTD
- A datatype: might be an unbound UDT and might not beStandardException
public void createTypeDependency(DataTypeDescriptor dtd) throws StandardException
dtd
- Type which may have a dependency declared on it.StandardException
private void createTypeDependency(AliasDescriptor ad) throws StandardException
StandardException
private void throwReliabilityException(java.lang.String fragmentType, int fragmentBitMask) throws StandardException
fragmentType
- Type of fragment as a string, for inclusion in error messages.fragmentBitMask
- Describes the kinds of expressions we ar suspicious ofStandardException
- Throws an error, always.public int orReliability(int newBits)
public static void bindOffsetFetch(ValueNode offset, ValueNode fetchFirst) throws StandardException
offset
- the OFFSET parameter, if anyfetchFirst
- the FETCH parameter, if anyStandardException
- Thrown on errorpublic <N extends QueryTreeNode> java.util.SortedSet<N> getOffsetOrderedNodes(java.lang.Class<N> type) throws StandardException
N
- the type of node to look fortype
- the type of node to look forStandardException
- if an error occursstatic Context getContext(java.lang.String contextID)
Apache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.