Class QueryTreeNode
- java.lang.Object
-
- org.apache.derby.impl.sql.compile.QueryTreeNode
-
- All Implemented Interfaces:
Visitable
- Direct Known Subclasses:
JavaValueNode
,MatchingClauseNode
,OrderedColumn
,Predicate
,PrivilegeNode
,QueryTreeNodeVector
,ResultSetNode
,StatementNode
,TableElementNode
,TableName
,TablePrivilegesNode
,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.
-
-
Field Summary
Fields 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 Summary
Constructors Constructor Description QueryTreeNode(ContextManager cm)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Visitable
accept(Visitor v)
Accept a visitor, and callv.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 necessaryDataTypeDescriptor
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 QueryTreeNodeprivate 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 Propertyprotected 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>
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.OptimizerFactory
getOptimizerFactory()
Gets the NodeFactory for this database.OptTrace
getOptimizerTracer()
Convenience method for finding the optimizer tracerDataTypeDescriptor[]
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 TypeIdAliasDescriptor
getUDTDesc(DataTypeDescriptor dtd)
Get the AliasDescriptor of a UDTboolean
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 schemaConstantAction
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 onint
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 purposesboolean
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.
-
-
-
Field Detail
-
AUTOINCREMENT_START_INDEX
static final int AUTOINCREMENT_START_INDEX
- See Also:
- Constant Field Values
-
AUTOINCREMENT_INC_INDEX
static final int AUTOINCREMENT_INC_INDEX
- See Also:
- Constant Field Values
-
AUTOINCREMENT_IS_AUTOINCREMENT_INDEX
static final int AUTOINCREMENT_IS_AUTOINCREMENT_INDEX
- See Also:
- Constant Field Values
-
AUTOINCREMENT_CREATE_MODIFY
static final int AUTOINCREMENT_CREATE_MODIFY
- See Also:
- Constant Field Values
-
AUTOINCREMENT_CYCLE
static final int AUTOINCREMENT_CYCLE
- See Also:
- Constant Field Values
-
beginOffset
private int beginOffset
-
endOffset
private int endOffset
-
cm
private ContextManager cm
-
lcc
private LanguageConnectionContext lcc
-
constantActionFactory
private GenericConstantActionFactory constantActionFactory
-
visitableTags
private java.util.ArrayList<java.lang.String> visitableTags
-
isPrivilegeCollectionRequired
private boolean isPrivilegeCollectionRequired
In Derby SQL Standard Authorization, views, triggers and constraints execute with definer's privileges. Taking a specific eg of views user1 create table t1 (c11 int); create view v1 as select * from user1.t1; grant select on v1 to user2; user2 select * from user1.v1; Running with definer's privileges mean that since user2 has select privileges on view v1 owned by user1, then that is sufficient for user2 to do a select from view v1. View v1 underneath might access some objects that user2 doesn't have privileges on, but that is not a problem since views execute with definer's privileges. In order to implement this behavior, when doing a select from view v1, we only want to check for select privilege on view v1. While processing the underlying query for view v1, we want to stop collecting the privilege requirements for the query underneath. Following flag, isPrivilegeCollectionRequired is used for this purpose. The flag will be true when we are the top level of view and then it is turned off while we process the query underlying the view v1.
-
-
Constructor Detail
-
QueryTreeNode
QueryTreeNode(ContextManager cm)
-
-
Method Detail
-
getContextManager
final ContextManager getContextManager()
Get the current ContextManager.- Returns:
- The current ContextManager.
-
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()
-
getClassFactory
protected final ClassFactory getClassFactory()
Get the ClassFactory to use with this database.
-
getLanguageConnectionContext
protected final LanguageConnectionContext getLanguageConnectionContext()
Gets the LanguageConnectionContext for this connection.- Returns:
- the lcc for this connection
-
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.
-
nodeHeader
protected java.lang.String nodeHeader()
Return header information for debug printing of this query tree node.- Returns:
- Header information for debug printing of this query tree node.
-
formatNodeString
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. This method indents the String to the given depth by inserting tabs at the beginning of the string, and also after every newline.- Parameters:
nodeString
- The node formatted as a Stringdepth
- The depth to indent the given node- Returns:
- The node String reformatted with tab indentation
-
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.
-
stackPrint
void stackPrint()
Print call stack for debug purposes
-
treePrint
void treePrint(int depth)
Print this tree for debugging purposes. This recurses through all the sub-nodes and prints them indented by their depth in the tree, starting with the given indentation.- Parameters:
depth
- The depth of this node in the tree, thus, the amount to indent it when printing it.
-
containsInfo
private static boolean containsInfo(java.lang.String str)
-
debugPrint
static void debugPrint(java.lang.String outputString)
Print a String for debugging- Parameters:
outputString
- The String to print
-
debugFlush
protected static void debugFlush()
Flush the debug stream out
-
printSubNodes
void printSubNodes(int depth)
Print the sub-nodes of this node. Each sub-class of QueryTreeNode is expected to provide its own printSubNodes() method. In each case, it calls super.printSubNodes(), passing along its depth, to get the sub-nodes of the super-class. Then it prints its own sub-nodes by calling treePrint() on each of its members that is a type of QueryTreeNode. In each case where it calls treePrint(), it should pass "depth + 1" to indicate that the sub-node should be indented one more level when printing. Also, it should call printLabel() to print the name of each sub-node before calling treePrint() on the sub-node, so that the reader of the printed tree can tell what the sub-node is. This printSubNodes() exists in here merely to act as a backstop. In other words, the calls to printSubNodes() move up the type hierarchy, and in this node the calls stop. I would have liked to put the call to super.printSubNodes() in this super-class, but Java resolves "super" statically, so it wouldn't get to the right super-class.- Parameters:
depth
- The depth to indent the sub-nodes
-
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:
toString
in classjava.lang.Object
- Returns:
- This node formatted as a String
-
printLabel
void printLabel(int depth, java.lang.String label)
Print the given label at the given indentation depth.- Parameters:
depth
- The depth of indentation to use when printing the labellabel
- The String to print
-
referencesSessionSchema
public boolean referencesSessionSchema() throws StandardException
Return 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
-
isSessionSchema
final boolean isSessionSchema(SchemaDescriptor sd)
Checks if the passed schema descriptor is for SESSION schema- Returns:
- true if the passed schema descriptor is for SESSION schema
- Throws:
StandardException
- Thrown on error
-
isSessionSchema
static boolean isSessionSchema(java.lang.String schemaName)
Checks if the passed schema name is for SESSION schema- Returns:
- true if the passed schema name is for SESSION schema
- Throws:
StandardException
- Thrown on error
-
disablePrivilegeCollection
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. Based on this, any time a trigger/view/constraint is executing, we do not need to waste time in checking if the definer still has the right set of privileges. At compile time, we will make sure that we do not collect the privilege requirement for objects accessed with definer privileges by calling the following method.
-
isPrivilegeCollectionRequired
boolean isPrivilegeCollectionRequired() throws StandardException
Return true from this method means that we need to collect privilege requirement for this node. For following cases, this method will return true. 1)execute view - collect privilege to access view but do not collect privilege requirements for objects accessed by actual view uqery 2)execute select - collect privilege requirements for objects accessed by select statement 3)create view - collect privileges for select statement : the select statement for create view falls under 2) category above.- Returns:
- true if need to collect privilege requirement for this node
- Throws:
StandardException
-
generate
void generate(ActivationClassBuilder acb, MethodBuilder mb) throws StandardException
Do the code generation for this node. This is a place-holder method - it should be over-ridden in the sub-classes.- Parameters:
acb
- The ActivationClassBuilder for the class being builtmb
- The method for the generated code to go into- 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
-
getDependencyManager
final DependencyManager getDependencyManager()
-
getCompilerContext
protected final CompilerContext getCompilerContext()
Get the CompilerContext- Returns:
- The CompilerContext
-
getTypeCompiler
protected final TypeCompiler getTypeCompiler(TypeId typeId)
Get the TypeCompiler associated with the given TypeId- Parameters:
typeId
- The TypeId to get a TypeCompiler for- Returns:
- The corresponding TypeCompiler
-
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:
accept
in interfaceVisitable
- Parameters:
v
- the visitor- Throws:
StandardException
- on error
-
acceptChildren
void acceptChildren(Visitor v) throws StandardException
Accept a visitor on all child nodes. All sub-classes that add fields that should be visited, should override this method and callaccept(v)
on all visitable fields, as well assuper.acceptChildren(v)
to make sure all visitable fields defined by the super-class are accepted too.- Parameters:
v
- the visitor- Throws:
StandardException
- on errors raised by the visitor
-
addTag
public void addTag(java.lang.String tag)
Description copied from interface:Visitable
Add a tag to this Visitable.
-
taggedWith
public boolean taggedWith(java.lang.String tag)
Description copied from interface:Visitable
Return true if this Visitable is tagged with the indicated tag.- Specified by:
taggedWith
in interfaceVisitable
-
copyTagsFrom
protected void copyTagsFrom(QueryTreeNode that)
Copy the tags from another QueryTreeNode
-
getIntProperty
protected int getIntProperty(java.lang.String value, java.lang.String key) throws StandardException
Get the int value of a Property- Parameters:
value
- Property value as a Stringkey
- Key value of property- Returns:
- The int value of the property
- Throws:
StandardException
- Thrown on failure
-
getLongProperty
protected long getLongProperty(java.lang.String value, java.lang.String key) throws StandardException
Get the long value of a Property- Parameters:
value
- Property value as a Stringkey
- Key value of property- Returns:
- The long value of the property
- Throws:
StandardException
- Thrown on failure
-
parseStatement
StatementNode parseStatement(java.lang.String sql, boolean internalSQL) throws StandardException
Parse the a SQL statement from the body of another SQL statement. Pushes and pops a separate CompilerContext to perform the compilation.- Throws:
StandardException
-
parseSearchCondition
ValueNode parseSearchCondition(java.lang.String sql, boolean internalSQL) throws StandardException
Parse an SQL fragment that represents a<search condition>
.- Parameters:
sql
- a fragment of an SQL statementinternalSQL
-true
if the SQL fragment is allowed to contain internal syntax,false
otherwise- Returns:
- a
ValueNode
representing the parse tree of the SQL fragment - Throws:
StandardException
- if an error happens while parsing
-
parseStatementOrSearchCondition
private Visitable parseStatementOrSearchCondition(java.lang.String sql, boolean internalSQL, boolean isStatement) throws StandardException
Parse a full SQL statement or a fragment representing a<search condition>
. This is a worker method that contains common logic forparseStatement(java.lang.String, boolean)
andparseSearchCondition(java.lang.String, boolean)
.- Parameters:
sql
- the SQL statement or fragment to parseinternalSQL
-true
if it is allowed to contain internal syntax,false
otherwiseisStatement
-true
ifsql
is a full SQL statement,false
if it is a fragment- Returns:
- a parse tree
- Throws:
StandardException
- if an error happens while parsing
-
getStatementType
protected int getStatementType()
Return the type of statement, something from StatementType.- Returns:
- the type of statement
-
getNullNode
ConstantNode getNullNode(DataTypeDescriptor type) throws StandardException
Get a ConstantNode to represent a typed null value.- Parameters:
type
- Type of the null node.- Returns:
- A ConstantNode with the specified type, and a value of null
- Throws:
StandardException
- Thrown on error
-
convertDefaultNode
DataValueDescriptor convertDefaultNode(DataTypeDescriptor typeDescriptor) throws StandardException
Translate a Default node into a default value, given a type descriptor.- Parameters:
typeDescriptor
- A description of the required data type.- Throws:
StandardException
- Thrown on error
-
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
-
getTableDescriptor
protected final TableDescriptor getTableDescriptor(java.lang.String tableName, SchemaDescriptor schema) throws StandardException
Get the descriptor for the named table within the given schema. If the schema parameter is NULL, it looks for the table in the current (default) schema. Table descriptors include object ids, object types (table, view, etc.) If the schema is SESSION, then before looking into the data dictionary for persistent tables, it first looks into LCC for temporary tables. If no temporary table tableName found for the SESSION schema, then it goes and looks through the data dictionary for persistent table We added getTableDescriptor here so that we can look for non data dictionary tables(ie temp tables) here. Any calls to getTableDescriptor in data dictionary should be only for persistent tables- Parameters:
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.- Returns:
- The descriptor for the table, null if table does not exist.
- Throws:
StandardException
- Thrown on failure
-
getSchemaDescriptor
final SchemaDescriptor getSchemaDescriptor(java.lang.String schemaName) throws StandardException
Get the descriptor for the named schema. If the schemaName parameter is NULL, it gets the descriptor for the current compilation schema. QueryTreeNodes must obtain schemas using this method or the two argument version of it. This is to ensure that the correct default compliation schema is returned and to allow determination of if the statement being compiled depends on the current schema. Schema descriptors include authorization ids and schema ids. SQL92 allows a schema to specify a default character set - we will not support this. Will check default schema for a match before scanning a system table.- Parameters:
schemaName
- The name of the schema we're interested in. If the name is NULL, get the descriptor for the current compilation schema.- Returns:
- The descriptor for the schema.
- Throws:
StandardException
- Thrown on error
-
getSchemaDescriptor
final SchemaDescriptor getSchemaDescriptor(java.lang.String schemaName, boolean raiseError) throws StandardException
Get the descriptor for the named schema. If the schemaName parameter is NULL, it gets the descriptor for the current compilation schema. QueryTreeNodes must obtain schemas using this method or the single argument version of it. This is to ensure that the correct default compliation schema is returned and to allow determination of if the statement being compiled depends on the current schema.- Parameters:
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.- Returns:
- Valid SchemaDescriptor or null if raiseError is false and the schema does not exist.
- Throws:
StandardException
- Schema does not exist and raiseError is true.
-
resolveTableToSynonym
TableName resolveTableToSynonym(TableName tabName) throws StandardException
Resolve table/view reference to a synonym. May have to follow a synonym chain.- Parameters:
tabName
- to match for a synonym- Returns:
- Synonym TableName if a match is found, NULL otherwise.
- Throws:
StandardException
- Thrown on error
-
verifyClassExist
void verifyClassExist(java.lang.String javaClassName) throws StandardException
Verify that a java class exists, is accessible (public) and not a class representing a primitive type.- Parameters:
javaClassName
- The name of the java class to resolve.- Throws:
StandardException
- Thrown on error
-
setRefActionInfo
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.
-
generateAuthorizeCheck
void generateAuthorizeCheck(ActivationClassBuilder acb, MethodBuilder mb, int sqlOperation)
Add an authorization check into the passed in method.
-
checkReliability
public void checkReliability(java.lang.String fragmentType, int fragmentBitMask) throws StandardException
Bind 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 StandardException
Bind 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
-
addUDTUsagePriv
void addUDTUsagePriv(java.util.List<ValueNode> valueNodes) throws StandardException
Add USAGE privilege for all UDTs mentioned in the indicated ValueNodes.- Throws:
StandardException
-
addUDTUsagePriv
void addUDTUsagePriv(ValueNode val) throws StandardException
Add USAGE privilege for a single 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
-
createTypeDependency
private void createTypeDependency(AliasDescriptor ad) throws StandardException
Declare a dependency on an ANSI UDT, identified by its AliasDescriptor, and check that you have privilege to use it.- Throws:
StandardException
-
throwReliabilityException
private void throwReliabilityException(java.lang.String fragmentType, int fragmentBitMask) throws StandardException
Common code for the 2 checkReliability functions. Always throws StandardException.- Parameters:
fragmentType
- Type of fragment as a string, for inclusion in error messages.fragmentBitMask
- Describes the kinds of expressions we ar suspicious of- Throws:
StandardException
- Throws an error, always.
-
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
-
getContext
static Context getContext(java.lang.String contextID)
Privileged lookup of a Context. Must be package protected so that user code can't call this entry point.
-
-