Top Description Fields Constructors Methods
org.apache.derby.impl.sql.compile

public abstract Class QueryTreeNode

extends Object
implements Visitable
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.sql.compile.Visitable
Known Direct Subclasses
org.apache.derby.impl.sql.compile.QueryTreeNodeVector, org.apache.derby.impl.sql.compile.ResultSetNode, org.apache.derby.impl.sql.compile.StatementNode, org.apache.derby.impl.sql.compile.TableElementNode, org.apache.derby.impl.sql.compile.TableName, org.apache.derby.impl.sql.compile.TablePrivilegesNode, org.apache.derby.impl.sql.compile.ValueNode, org.apache.derby.impl.sql.compile.WindowNode, org.apache.derby.impl.sql.compile.PrivilegeNode, org.apache.derby.impl.sql.compile.JavaValueNode, org.apache.derby.impl.sql.compile.MatchingClauseNode, org.apache.derby.impl.sql.compile.OrderedColumn, org.apache.derby.impl.sql.compile.Predicate
Imports
java.sql.Types, java.util.ArrayList, .List, .Map, .SortedSet, org.apache.derby.catalog.AliasInfo, .TypeDescriptor, org.apache.derby.catalog.types.RowMultiSetImpl, .SynonymAliasInfo, .UserDefinedTypeIdImpl, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.ClassName, .SQLState, org.apache.derby.iapi.services.classfile.VMOpcode, org.apache.derby.iapi.services.compiler.MethodBuilder, org.apache.derby.iapi.services.context.ContextManager, .Context, .ContextService, org.apache.derby.shared.common.i18n.MessageService, org.apache.derby.iapi.services.loader.ClassFactory, .ClassInspector, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.StatementType, .StatementUtil, org.apache.derby.iapi.sql.compile.CompilerContext, .OptimizerFactory, .OptTrace, .Parser, .TypeCompiler, .Visitable, .Visitor, org.apache.derby.iapi.sql.conn.LanguageConnectionContext, org.apache.derby.iapi.sql.depend.DependencyManager, org.apache.derby.iapi.sql.dictionary.AliasDescriptor, .DataDictionary, .SchemaDescriptor, .TableDescriptor, org.apache.derby.iapi.sql.execute.ConstantAction, .ExecutionFactory, org.apache.derby.iapi.types.DataTypeDescriptor, .DataValueDescriptor, .TypeId, org.apache.derby.impl.sql.execute.GenericConstantActionFactory, .GenericExecutionFactory

QueryTreeNode is the root class for all query tree nodes. All query tree nodes inherit from QueryTreeNode except for those that extend QueryTreeNodeVector.

Field Summary

Modifier and TypeField and Description
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
private int
private ContextManager
private GenericConstantActionFactory
private int
private boolean
isPrivilegeCollectionRequired

In Derby SQL Standard Authorization, views, triggers and constraints execute with definer's privileges.

private LanguageConnectionContext
private ArrayList<String>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public final Visitable
accept(Visitor
the visitor
v
)

Implements org.apache.derby.iapi.sql.compile.Visitable.accept.

Accept a visitor, and call v.visit() on child nodes as necessary.

pack-priv void
acceptChildren(Visitor
the visitor
v
)

Accept a visitor on all child nodes.

public void
addTag(String tag)

Implements org.apache.derby.iapi.sql.compile.Visitable.addTag.

Add a tag to this Visitable.

pack-priv void
addUDTUsagePriv(List<ValueNode> valueNodes)

Add USAGE privilege for all UDTs mentioned in the indicated ValueNodes.

pack-priv void
addUDTUsagePriv(ValueNode val)

Add USAGE privilege for a single UDT.

public static void
bindOffsetFetch(ValueNode
the OFFSET parameter, if any
offset
,
ValueNode
the FETCH parameter, if any
fetchFirst
)

Bind the parameters of OFFSET n ROWS and FETCH FIRST n ROWS ONLY, if any.

public DataTypeDescriptor

Returns:

The bound table type if originalDTD was an unbound table type; otherwise returns originalDTD.
bindRowMultiSet
(DataTypeDescriptor
A datatype: might be an unbound UDT and might not be
originalDTD
)

Bind the UDTs in a table type.

public TypeDescriptor
bindUserCatalogType(TypeDescriptor td)

Bind user defined types as necessary

public DataTypeDescriptor

Returns:

The bound UDT if originalDTD was an unbound UDT; otherwise returns originalDTD.
bindUserType
(DataTypeDescriptor
A datatype: might be an unbound UDT and might not be
originalDTD
)

Bind a UDT.

public void
checkReliability(String
Type of fragment as a String, for inclusion in error messages.
fragmentType
,
int
Type of fragment as a bitmask of possible fragment types
fragmentBitMask
)

Bind time logic.

public void
checkReliability(int
Type of fragment as a bitmask of possible fragment types
fragmentBitMask
,
String
Type of fragment as a String, to be fetch for the error message.
fragmentType
)

Bind time logic.

private static boolean
pack-priv DataValueDescriptor
convertDefaultNode(DataTypeDescriptor
A description of the required data type.
typeDescriptor
)

Translate a Default node into a default value, given a type descriptor.

protected void
copyTagsFrom(QueryTreeNode that)

Copy the tags from another QueryTreeNode

public void
createTypeDependency(DataTypeDescriptor
Type which may have a dependency declared on it.
dtd
)

Declare a dependency on a type and check that you have privilege to use it.

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.

protected static void
debugFlush()

Flush the debug stream out

pack-priv static void
debugPrint(String
The String to print
outputString
)

Print a String for debugging

pack-priv final 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.

pack-priv static String

Returns:

The node String reformatted with tab indentation
formatNodeString
(String
The node formatted as a String
nodeString
,
int
The depth to indent the given node
depth
)

Format a node that has been converted to a String for printing as part of a tree.

pack-priv void
generate(ActivationClassBuilder
The ActivationClassBuilder for the class being built
acb
,
MethodBuilder
The method for the generated code to go into
mb
)

Do the code generation for this node.

pack-priv void
generateAuthorizeCheck(ActivationClassBuilder acb, MethodBuilder mb, int sqlOperation)

Add an authorization check into the passed in method.

public int

Returns:

The beginning offset of the SQL substring. -1 means unknown.
getBeginOffset
()

Gets the beginning offset of the SQL substring which this query node represents.

protected final ClassFactory
getClassFactory()

Get the ClassFactory to use with this database.

protected final CompilerContext

Returns:

The CompilerContext
getCompilerContext
()

Get the CompilerContext

pack-priv static Context
getContext(final String contextID)

Must be package protected so that user code can't call this entry point.

pack-priv final ContextManager

Returns:

The current ContextManager.
getContextManager
()

Get the current ContextManager.

public final DataDictionary

Returns:

The DataDictionary
getDataDictionary
()

Get the DataDictionary

pack-priv final DependencyManager
public int

Returns:

The ending offset of the SQL substring. -1 means unknown.
getEndOffset
()

Gets the ending offset of the SQL substring which this query node represents.

public final ExecutionFactory
public final GenericConstantActionFactory

Returns:

the constant action factory.
getGenericConstantActionFactory
()

Gets the constant action factory for this database.

protected int

Returns:

The int value of the property
getIntProperty
(String
Property value as a String
value
,
String
Key value of property
key
)

Get the int value of a Property

protected final LanguageConnectionContext

Returns:

the lcc for this connection
getLanguageConnectionContext
()

Gets the LanguageConnectionContext for this connection.

protected long

Returns:

The long value of the property
getLongProperty
(String
Property value as a String
value
,
String
Key value of property
key
)

Get the long value of a Property

pack-priv ConstantNode

Returns:

A ConstantNode with the specified type, and a value of null
getNullNode
(DataTypeDescriptor
Type of the null node.
type
)

Get a ConstantNode to represent a typed null value.

public <
the type of node to look for
N extends QueryTreeNode
>
SortedSet<N>

Returns:

all nodes of the specified type
getOffsetOrderedNodes
(Class<N>
the type of node to look for
type
)

Get all child nodes of a specific type, and return them in the order in which they appear in the SQL text.

public final OptimizerFactory

Returns:

the node factory for this database.
getOptimizerFactory
()

Gets the NodeFactory for this database.

public OptTrace
getOptimizerTracer()

Convenience method for finding the optimizer tracer

public DataTypeDescriptor[]

Returns:

null
getParameterTypes
()

Parameter info is stored in the compiler context.

pack-priv final SchemaDescriptor

Returns:

The descriptor for the schema.
getSchemaDescriptor
(String
The name of the schema we're interested in. If the name is NULL, get the descriptor for the current compilation schema.
schemaName
)

Get the descriptor for the named schema.

pack-priv final SchemaDescriptor

Returns:

Valid SchemaDescriptor or null if raiseError is false and the schema does not exist.
getSchemaDescriptor
(String
The name of the schema we're interested in. If the name is NULL, get the descriptor for the current compilation schema.
schemaName
,
boolean
True to raise an error if the schema does not exist, false to return null if the schema does not exist.
raiseError
)

Get the descriptor for the named schema.

protected int

Returns:

the type of statement
getStatementType
()

Return the type of statement, something from StatementType.

protected final TableDescriptor

Returns:

The descriptor for the table, null if table does not exist.
getTableDescriptor
(String
The name of the table to get the descriptor for
tableName
,
SchemaDescriptor
The descriptor for the schema the table lives in. If null, use the current (default) schema.
schema
)

Get the descriptor for the named table within the given schema.

protected final TypeCompiler

Returns:

The corresponding TypeCompiler
getTypeCompiler
(TypeId
The TypeId to get a TypeCompiler for
typeId
)

Get the TypeCompiler associated with the given TypeId

public AliasDescriptor
getUDTDesc(DataTypeDescriptor dtd)

Get the AliasDescriptor of a UDT

public boolean
pack-priv boolean

Returns:

true if need to collect privilege requirement for this node
isPrivilegeCollectionRequired
()

Return true from this method means that we need to collect privilege requirement for this node.

pack-priv final boolean

Returns:

true if the passed schema descriptor is for SESSION schema
isSessionSchema
(SchemaDescriptor sd)

Checks if the passed schema descriptor is for SESSION schema

pack-priv static boolean

Returns:

true if the passed schema name is for SESSION schema
isSessionSchema
(String schemaName)

Checks if the passed schema name is for SESSION schema

public ConstantAction
makeConstantAction()

This creates a class that will do the work that's constant across all Executions of a PreparedStatement.

public TableName
makeTableName(String schemaName, String flatName)

public static TableName
makeTableName(ContextManager contextManager, String schemaName, String flatName)

protected String

Returns:

Header information for debug printing of this query tree node.
nodeHeader
()

Return header information for debug printing of this query tree node.

public boolean
optimizerTracingIsOn()

Convenience method for checking whether optimizer tracing is on

public int
orReliability(int newBits)

OR in more reliability bits and return the old reliability value.

pack-priv ValueNode

Returns:

a ValueNode representing the parse tree of the SQL fragment
parseSearchCondition
(String
a fragment of an SQL statement
sql
,
boolean
true if the SQL fragment is allowed to contain internal syntax, false otherwise
internalSQL
)

Parse an SQL fragment that represents a <search condition>.

pack-priv StatementNode
parseStatement(String sql, boolean internalSQL)

Parse the a SQL statement from the body of another SQL statement.

private Visitable

Returns:

a parse tree
parseStatementOrSearchCondition
(String
the SQL statement or fragment to parse
sql
,
boolean
true if it is allowed to contain internal syntax, false otherwise
internalSQL
,
boolean
true if sql is a full SQL statement, false if it is a fragment
isStatement
)

Parse a full SQL statement or a fragment representing a <search condition>.

pack-priv void
printLabel(int
The depth of indentation to use when printing the label
depth
,
String
The String to print
label
)

Print the given label at the given indentation depth.

pack-priv void
printSubNodes(int
The depth to indent the sub-nodes
depth
)

Print the sub-nodes of this node.

public boolean

Returns:

true if references SESSION schema tables, else false
referencesSessionSchema
()

Return true if the node references SESSION schema tables (temporary or permanent)

pack-priv TableName

Returns:

Synonym TableName if a match is found, NULL otherwise.
resolveTableToSynonym
(TableName
to match for a synonym
tabName
)

Resolve table/view reference to a synonym.

public void
setBeginOffset(int
The beginning offset of the SQL substring.
beginOffset
)

Sets the beginning offset of the SQL substring which this query node represents.

public void
setEndOffset(int
The ending offset of the SQL substring.
endOffset
)

Sets the ending offset of the SQL substring which this query node represents.

pack-priv void
setRefActionInfo(long fkIndexConglomId, int[] fkColArray, String parentResultSetId, boolean dependentScan)

set the Information gathered from the parent table that is required to perform a referential action on dependent table.

pack-priv void
stackPrint()

Print call stack for debug purposes

public boolean
taggedWith(String tag)

Implements org.apache.derby.iapi.sql.compile.Visitable.taggedWith.

Return true if this Visitable is tagged with the indicated tag.

private void
throwReliabilityException(String
Type of fragment as a string, for inclusion in error messages.
fragmentType
,
int
Describes the kinds of expressions we ar suspicious of
fragmentBitMask
)

Common code for the 2 checkReliability functions.

public String

Returns:

This node formatted as a String
toString
()

Overrides java.lang.Object.toString.

Format this node as a string Each sub-class of QueryTreeNode should implement its own toString() method.

public void
treePrint()

Print this tree for debugging purposes.

pack-priv void
treePrint(int
The depth of this node in the tree, thus, the amount to indent it when printing it.
depth
)

Print this tree for debugging purposes.

pack-priv void
verifyClassExist(String
The name of the java class to resolve.
javaClassName
)

Verify that a java class exists, is accessible (public) and not a class representing a primitive type.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait