Class CompilerContextImpl
- java.lang.Object
-
- org.apache.derby.iapi.services.context.ContextImpl
-
- org.apache.derby.impl.sql.compile.CompilerContextImpl
-
- All Implemented Interfaces:
Context
,CompilerContext
public class CompilerContextImpl extends ContextImpl implements CompilerContext
CompilerContextImpl, implementation of CompilerContext. CompilerContext and hence CompilerContextImpl objects are private to a LanguageConnectionContext.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
classPrefix
private SchemaDescriptor
compilationSchema
private ProviderList
currentAPL
private Dependent
currentDependent
private int
currPrivType
private java.lang.Object
cursorInfo
private java.util.ArrayList<SchemaDescriptor>
defaultSchemaStack
Saved execution time default schema, if we need to change it temporarily.private DependencyManager
dm
private boolean
firstOnStack
private boolean
inUse
private LanguageConnectionContext
lcc
private LanguageConnectionFactory
lcf
private java.util.HashMap<java.lang.String,int[]>
namedScopes
private long
nextClassName
private int
nextColumnNumber
private int
nextEquivalenceClass
private int
nextResultSetNumber
private int
nextSubqueryNumber
private int
nextTableNumber
private DataTypeDescriptor[]
parameterDescriptors
private java.util.List<ParameterNode>
parameterList
private Parser
parser
private java.util.ArrayList<VisitableFilter>
privilegeCheckFilters
private java.util.ArrayList<java.lang.Integer>
privTypeStack
private java.util.HashMap<UUID,SequenceDescriptor>
referencedSequences
private int
reliability
private java.util.HashMap<StatementTablePermission,StatementColumnPermission>
requiredColumnPrivileges
private java.util.HashMap<StatementRolePermission,StatementRolePermission>
requiredRolePrivileges
private java.util.HashMap<UUID,java.lang.Integer>
requiredRoutinePrivileges
private java.util.HashMap<StatementSchemaPermission,StatementSchemaPermission>
requiredSchemaPrivileges
private java.util.HashMap<StatementTablePermission,StatementTablePermission>
requiredTablePrivileges
private java.util.HashMap<UUID,java.lang.String>
requiredUsagePrivileges
private boolean
returnParameterFlag
private java.util.List<java.lang.Object>
savedObjects
private int
scanIsolationLevel
private static int
SCOPE_CELL
private boolean
skippingTypePrivileges
private SortCostController
sortCostController
private java.util.HashMap<java.lang.Long,StoreCostController>
storeCostControllers
Map that contains all store cost controllers opened in this compiler context.private TypeCompilerFactory
typeCompilerFactory
private java.sql.SQLWarning
warnings
-
Fields inherited from interface org.apache.derby.iapi.sql.compile.CompilerContext
AGGREGATE_RESTRICTION, CASE_OPERAND_RESTRICTION, CHECK_CONSTRAINT, COLUMN_REFERENCE_ILLEGAL, CONDITIONAL_RESTRICTION, CONTEXT_ID, CURRENT_CONNECTION_ILLEGAL, DATETIME_ILLEGAL, DEFAULT_RESTRICTION, DIAGNOSTICS_ILLEGAL, FUNCTION_CALL_ILLEGAL, GENERATION_CLAUSE_RESTRICTION, GROUP_BY_RESTRICTION, HAVING_CLAUSE_RESTRICTION, IGNORE_MISSING_CLASSES, INTERNAL_SQL_ILLEGAL, INTERNAL_SQL_LEGAL, MODIFIES_SQL_DATA_PROCEDURE_ILLEGAL, NEXT_VALUE_FOR_ILLEGAL, NON_DETERMINISTIC_ILLEGAL, ON_CLAUSE_RESTRICTION, SCHEMA_ILLEGAL, SQL_IN_ROUTINES_ILLEGAL, SQL_LEGAL, SUBQUERY_ILLEGAL, UNNAMED_PARAMETER_ILLEGAL, USER_ILLEGAL, WHERE_CLAUSE_RESTRICTION, WHERE_SCOPE
-
-
Constructor Summary
Constructors Constructor Description CompilerContextImpl(ContextManager cm, LanguageConnectionContext lcc, TypeCompilerFactory typeCompilerFactory)
This constructor creates and saves the parser using the language connection factory when the context is created (when the first statement comes in, likely).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPrivilegeFilter(VisitableFilter vf)
Add a filter for determining which QueryTreeNodes give rise to privilege checks at run time.private void
addProviderToAuxiliaryList(Provider p)
Add a Provider to the current AuxiliaryProviderList, if one exists.void
addReferencedSequence(SequenceDescriptor sd)
Add a sequence descriptor to the list of referenced sequences.void
addRequiredColumnPriv(ColumnDescriptor column)
Add a column privilege to the list of used column privileges.void
addRequiredRolePriv(java.lang.String roleName, int privType)
Add a required role privilege to the list privileges.void
addRequiredRoutinePriv(AliasDescriptor routine)
Add a routine execute privilege to the list of used routine privileges.void
addRequiredSchemaPriv(java.lang.String schemaName, java.lang.String aid, int privType)
Add a required schema privilege to the list privileges.void
addRequiredTablePriv(TableDescriptor table)
Add a table or view privilege to the list of used table privileges.void
addRequiredUsagePriv(PrivilegedSQLObject usableObject)
Add a usage privilege to the list of required privileges.int
addSavedObject(java.lang.Object obj)
Add an object to the pool that is created at compile time and used at execution time.void
addWarning(java.sql.SQLWarning warning)
Add a compile time warning.void
beginScope(java.lang.String scopeName)
Record that the compiler is entering a named scope.void
cleanupOnError(java.lang.Throwable error)
Contexts will be passed errors that are caught by the outer system when they are serious enough to require corrective action.private void
closeSortCostControllers()
private void
closeStoreCostControllers()
void
createDependency(Dependent d, Provider p)
Add a dependency between two objects.void
createDependency(Provider p)
Add a dependency for the current dependent.void
endScope(java.lang.String scopeName)
Record that the compiler is exiting a named scope.void
firstOnStack()
Mark this CompilerContext as the first on the stack, so we can avoid continually popping and pushing a CompilerContext.ClassFactory
getClassFactory()
Return the class factory to use in this compilation.SchemaDescriptor
getCompilationSchema()
Get the compilation schema descriptor for this compilation context.ProviderList
getCurrentAuxiliaryProviderList()
Get the current auxiliary provider list from this CompilerContext.java.lang.Object
getCursorInfo()
Get the cursor info stored in the context.boolean
getInUse()
Return the in use state for the compiler context.JavaFactory
getJavaFactory()
Get the JavaFactory from this CompilerContext.int
getNextColumnNumber()
Get the current next column number (for generated column names) from this CompilerContext.int
getNextEquivalenceClass()
Get the next equivalence class for equijoin clauses.int
getNextResultSetNumber()
Get the current next ResultSet number from this CompilerContext.int
getNextSubqueryNumber()
Get the current next subquery number from this CompilerContext.int
getNextTableNumber()
Get the current next table number from this CompilerContext.int
getNumResultSets()
Get the number of Results in the current statement from this CompilerContext.int
getNumSubquerys()
Get the number of subquerys in the current statement from this CompilerContext.int
getNumTables()
Get the number of tables in the current statement from this CompilerContext.OptimizerFactory
getOptimizerFactory()
Get the OptimizerFactory for this contextjava.util.List<ParameterNode>
getParameterList()
Get the parameter list.(package private) DataTypeDescriptor[]
getParameterTypes()
Get an array of type descriptors for all the ?Parser
getParser()
Get the Parser from this CompilerContextint
getReliability()
Return the reliability requirements of this clause.java.util.List<StatementPermission>
getRequiredPermissionsList()
boolean
getReturnParameterFlag()
Is the callable statement uses ?java.lang.Object[]
getSavedObjects()
Get the saved object pool (for putting into the prepared statement).int
getScanIsolationLevel()
Get the isolation level for the scans in this query.SortCostController
getSortCostController()
Get a SortCostController.StoreCostController
getStoreCostController(long conglomerateNumber)
Get a StoreCostController for the given conglomerate.TypeCompilerFactory
getTypeCompilerFactory()
Get the TypeCompilerFactory from this CompilerContext.java.lang.String
getUniqueClassName()
Get a unique Class name from this CompilerContext.java.sql.SQLWarning
getWarnings()
Get the chain of compile time warnings.private void
initRequiredPriv()
boolean
isFirstOnStack()
Is this the first CompilerContext on the stack?boolean
isReferenced(SequenceDescriptor sd)
Report whether the given sequence has been referenced already.boolean
passesPrivilegeFilters(Visitable visitable)
Return true if a QueryTreeNode passes all of the filters which determine whether the QueryTreeNode gives rise to run time privilege checks.void
popCompilationSchema()
Pop the default schema to use when compiling.void
popCurrentPrivType()
void
pushCompilationSchema(SchemaDescriptor sd)
Push a default schema to use when compiling.void
pushCurrentPrivType(int privType)
Sets the current privilege type context.void
removePrivilegeFilter(VisitableFilter vf)
Remove a filter for determining which QueryTreeNodes give rise to privilege checks at run time.void
resetContext()
Reset compiler context (as for instance, when we recycle a context for use by another compilation.void
resetNextResultSetNumber()
Reset the next ResultSet number from this CompilerContext.int
scopeDepth(java.lang.String scopeName)
Get the current depth for the named scope.SchemaDescriptor
setCompilationSchema(SchemaDescriptor newDefault)
Set the compilation schema descriptor for this compilation context.void
setCurrentAuxiliaryProviderList(ProviderList apl)
Set the current auxiliary provider list for this CompilerContext.void
setCurrentDependent(Dependent d)
Set the current dependent from this CompilerContext.void
setCursorInfo(java.lang.Object cursorInfo)
Set paramsvoid
setInUse(boolean inUse)
Set the in use state for the compiler context.void
setParameterList(java.util.List<ParameterNode> parameterList)
Set the parameter list.void
setReliability(int reliability)
Sets which kind of query fragments are NOT allowed.void
setReturnParameterFlag()
If callable statement uses ?void
setSavedObjects(java.util.List<java.lang.Object> objs)
Set the saved object pool (for putting into the prepared statement).void
setScanIsolationLevel(int isolationLevel)
Set the isolation level for the scans in this query.boolean
skippingTypePrivileges()
Return whether we are skipping USAGE privileges for user-defined typesboolean
skipTypePrivileges(boolean skip)
Set whether we should skip adding USAGE privileges for user-defined types-
Methods inherited from class org.apache.derby.iapi.services.context.ContextImpl
appendErrorInfo, getContextManager, getIdName, isLastHandler, popMe, pushMe
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.derby.iapi.services.context.Context
getContextManager, getIdName, isLastHandler, popMe, pushMe
-
-
-
-
Field Detail
-
SCOPE_CELL
private static final int SCOPE_CELL
- See Also:
- Constant Field Values
-
parser
private final Parser parser
-
lcc
private final LanguageConnectionContext lcc
-
lcf
private final LanguageConnectionFactory lcf
-
typeCompilerFactory
private TypeCompilerFactory typeCompilerFactory
-
currentDependent
private Dependent currentDependent
-
dm
private DependencyManager dm
-
firstOnStack
private boolean firstOnStack
-
inUse
private boolean inUse
-
reliability
private int reliability
-
nextColumnNumber
private int nextColumnNumber
-
nextTableNumber
private int nextTableNumber
-
nextSubqueryNumber
private int nextSubqueryNumber
-
nextResultSetNumber
private int nextResultSetNumber
-
scanIsolationLevel
private int scanIsolationLevel
-
nextEquivalenceClass
private int nextEquivalenceClass
-
nextClassName
private long nextClassName
-
savedObjects
private java.util.List<java.lang.Object> savedObjects
-
classPrefix
private java.lang.String classPrefix
-
compilationSchema
private SchemaDescriptor compilationSchema
-
privilegeCheckFilters
private java.util.ArrayList<VisitableFilter> privilegeCheckFilters
-
namedScopes
private java.util.HashMap<java.lang.String,int[]> namedScopes
-
skippingTypePrivileges
private boolean skippingTypePrivileges
-
defaultSchemaStack
private java.util.ArrayList<SchemaDescriptor> defaultSchemaStack
Saved execution time default schema, if we need to change it temporarily.
-
currentAPL
private ProviderList currentAPL
-
returnParameterFlag
private boolean returnParameterFlag
-
storeCostControllers
private final java.util.HashMap<java.lang.Long,StoreCostController> storeCostControllers
Map that contains all store cost controllers opened in this compiler context. Conglomerate id (long) is the key.
-
sortCostController
private SortCostController sortCostController
-
parameterList
private java.util.List<ParameterNode> parameterList
-
parameterDescriptors
private DataTypeDescriptor[] parameterDescriptors
-
cursorInfo
private java.lang.Object cursorInfo
-
warnings
private java.sql.SQLWarning warnings
-
privTypeStack
private final java.util.ArrayList<java.lang.Integer> privTypeStack
-
currPrivType
private int currPrivType
-
requiredColumnPrivileges
private java.util.HashMap<StatementTablePermission,StatementColumnPermission> requiredColumnPrivileges
-
requiredTablePrivileges
private java.util.HashMap<StatementTablePermission,StatementTablePermission> requiredTablePrivileges
-
requiredSchemaPrivileges
private java.util.HashMap<StatementSchemaPermission,StatementSchemaPermission> requiredSchemaPrivileges
-
requiredRoutinePrivileges
private java.util.HashMap<UUID,java.lang.Integer> requiredRoutinePrivileges
-
requiredUsagePrivileges
private java.util.HashMap<UUID,java.lang.String> requiredUsagePrivileges
-
requiredRolePrivileges
private java.util.HashMap<StatementRolePermission,StatementRolePermission> requiredRolePrivileges
-
referencedSequences
private java.util.HashMap<UUID,SequenceDescriptor> referencedSequences
-
-
Constructor Detail
-
CompilerContextImpl
public CompilerContextImpl(ContextManager cm, LanguageConnectionContext lcc, TypeCompilerFactory typeCompilerFactory)
This constructor creates and saves the parser using the language connection factory when the context is created (when the first statement comes in, likely).
-
-
Method Detail
-
cleanupOnError
public void cleanupOnError(java.lang.Throwable error) throws StandardException
Description copied from interface:Context
Contexts will be passed errors that are caught by the outer system when they are serious enough to require corrective action. They will be told what the error is, so that they can react appropriately. Most of the time, the contexts will react by either doing nothing or by removing themselves from the context manager. If there are no other references to the context, removing itself from the manager equates to freeing it.
On an exception that is session severity or greater the Context must push itself off the stack. This is to ensure that after a session has been closed there are no Contexts on the stack that potentially hold references to objects, thus delaying their garbage collection.Contexts must release all their resources before removing themselves from their context manager.
The context manager will "unwind" the contexts during cleanup in the reverse order they were placed on its global stack.
If error is an instance of StandardException then an implementation of this method may throw a new exception if and only if the new exception is an instance of StandardException that is more severe than the original error or the new exception is a not an instance of StandardException (e.g java.lang.NullPointerException).
- Specified by:
cleanupOnError
in interfaceContext
- Throws:
StandardException
- thrown by makeInvalid() call
-
resetContext
public void resetContext()
Reset compiler context (as for instance, when we recycle a context for use by another compilation.- Specified by:
resetContext
in interfaceCompilerContext
-
getParser
public Parser getParser()
Description copied from interface:CompilerContext
Get the Parser from this CompilerContext. *- Specified by:
getParser
in interfaceCompilerContext
- Returns:
- The parser associated with this CompilerContext
-
getOptimizerFactory
public OptimizerFactory getOptimizerFactory()
Get the OptimizerFactory for this context- Specified by:
getOptimizerFactory
in interfaceCompilerContext
- Returns:
- The OptimizerFactory for this context.
-
getNextColumnNumber
public int getNextColumnNumber()
Description copied from interface:CompilerContext
Get the current next column number (for generated column names) from this CompilerContext.- Specified by:
getNextColumnNumber
in interfaceCompilerContext
- Returns:
- int The next column number for the current statement.
-
getNextTableNumber
public int getNextTableNumber()
Description copied from interface:CompilerContext
Get the current next table number from this CompilerContext.- Specified by:
getNextTableNumber
in interfaceCompilerContext
- Returns:
- int The next table number for the current statement.
-
getNumTables
public int getNumTables()
Description copied from interface:CompilerContext
Get the number of tables in the current statement from this CompilerContext.- Specified by:
getNumTables
in interfaceCompilerContext
- Returns:
- int The number of tables in the current statement.
-
getNextSubqueryNumber
public int getNextSubqueryNumber()
Get the current next subquery number from this CompilerContext.- Specified by:
getNextSubqueryNumber
in interfaceCompilerContext
- Returns:
- int The next subquery number for the current statement.
-
getNumSubquerys
public int getNumSubquerys()
Get the number of subquerys in the current statement from this CompilerContext.- Specified by:
getNumSubquerys
in interfaceCompilerContext
- Returns:
- int The number of subquerys in the current statement.
-
getNextResultSetNumber
public int getNextResultSetNumber()
Description copied from interface:CompilerContext
Get the current next ResultSet number from this CompilerContext.- Specified by:
getNextResultSetNumber
in interfaceCompilerContext
- Returns:
- int The next ResultSet number for the current statement.
-
resetNextResultSetNumber
public void resetNextResultSetNumber()
Description copied from interface:CompilerContext
Reset the next ResultSet number from this CompilerContext.- Specified by:
resetNextResultSetNumber
in interfaceCompilerContext
-
getNumResultSets
public int getNumResultSets()
Description copied from interface:CompilerContext
Get the number of Results in the current statement from this CompilerContext.- Specified by:
getNumResultSets
in interfaceCompilerContext
- Returns:
- The number of ResultSets in the current statement.
-
getUniqueClassName
public java.lang.String getUniqueClassName()
Description copied from interface:CompilerContext
Get a unique Class name from this CompilerContext. Ensures it is globally unique for this JVM.- Specified by:
getUniqueClassName
in interfaceCompilerContext
- Returns:
- String A unique-enough class name.
-
getNextEquivalenceClass
public int getNextEquivalenceClass()
Get the next equivalence class for equijoin clauses.- Specified by:
getNextEquivalenceClass
in interfaceCompilerContext
- Returns:
- The next equivalence class for equijoin clauses.
-
getClassFactory
public ClassFactory getClassFactory()
Description copied from interface:CompilerContext
Return the class factory to use in this compilation.- Specified by:
getClassFactory
in interfaceCompilerContext
-
getJavaFactory
public JavaFactory getJavaFactory()
Description copied from interface:CompilerContext
Get the JavaFactory from this CompilerContext.- Specified by:
getJavaFactory
in interfaceCompilerContext
- Returns:
- The JavaFactory associated with this CompilerContext
-
setCurrentDependent
public void setCurrentDependent(Dependent d)
Description copied from interface:CompilerContext
Set the current dependent from this CompilerContext. This should be called at the start of a compile to register who has the dependencies needed for the compilation.- Specified by:
setCurrentDependent
in interfaceCompilerContext
- Parameters:
d
- The Dependent currently being compiled.
-
getCurrentAuxiliaryProviderList
public ProviderList getCurrentAuxiliaryProviderList()
Get the current auxiliary provider list from this CompilerContext.- Specified by:
getCurrentAuxiliaryProviderList
in interfaceCompilerContext
- Returns:
- The current AuxiliaryProviderList.
-
setCurrentAuxiliaryProviderList
public void setCurrentAuxiliaryProviderList(ProviderList apl)
Set the current auxiliary provider list for this CompilerContext.- Specified by:
setCurrentAuxiliaryProviderList
in interfaceCompilerContext
- Parameters:
apl
- The new current AuxiliaryProviderList.
-
createDependency
public void createDependency(Provider p) throws StandardException
Description copied from interface:CompilerContext
Add a dependency for the current dependent.- Specified by:
createDependency
in interfaceCompilerContext
- Parameters:
p
- The Provider of the dependency.- Throws:
StandardException
- thrown on failure.
-
createDependency
public void createDependency(Dependent d, Provider p) throws StandardException
Add a dependency between two objects.- Specified by:
createDependency
in interfaceCompilerContext
- Parameters:
d
- The Dependent object.p
- The Provider of the dependency.- Throws:
StandardException
- thrown on failure.
-
addProviderToAuxiliaryList
private void addProviderToAuxiliaryList(Provider p)
Add a Provider to the current AuxiliaryProviderList, if one exists.- Parameters:
p
- The Provider to add.
-
addSavedObject
public int addSavedObject(java.lang.Object obj)
Description copied from interface:CompilerContext
Add an object to the pool that is created at compile time and used at execution time. Use the integer to reference it in execution constructs. Execution code will have to generate:(#objectType) (this.getPreparedStatement().getSavedObject(#int))
- Specified by:
addSavedObject
in interfaceCompilerContext
- Parameters:
obj
- object to add to the pool of saved objects- Returns:
- the entry # for the object
-
getSavedObjects
public java.lang.Object[] getSavedObjects()
Description copied from interface:CompilerContext
Get the saved object pool (for putting into the prepared statement). This turns it into its storable form, an array of objects.- Specified by:
getSavedObjects
in interfaceCompilerContext
- Returns:
- the saved object pool.
-
setSavedObjects
public void setSavedObjects(java.util.List<java.lang.Object> objs)
Description copied from interface:CompilerContext
Set the saved object pool (for putting into the prepared statement).- Specified by:
setSavedObjects
in interfaceCompilerContext
- Parameters:
objs
- The new saved objects- See Also:
CompilerContext.setSavedObjects(java.util.List<java.lang.Object>)
-
setCursorInfo
public void setCursorInfo(java.lang.Object cursorInfo)
Description copied from interface:CompilerContext
Set params- Specified by:
setCursorInfo
in interfaceCompilerContext
- Parameters:
cursorInfo
- the cursor info- See Also:
CompilerContext.setCursorInfo(java.lang.Object)
-
getCursorInfo
public java.lang.Object getCursorInfo()
Description copied from interface:CompilerContext
Get the cursor info stored in the context.- Specified by:
getCursorInfo
in interfaceCompilerContext
- Returns:
- the cursor info
- See Also:
CompilerContext.getCursorInfo()
-
firstOnStack
public void firstOnStack()
Description copied from interface:CompilerContext
Mark this CompilerContext as the first on the stack, so we can avoid continually popping and pushing a CompilerContext.- Specified by:
firstOnStack
in interfaceCompilerContext
- See Also:
CompilerContext.firstOnStack()
-
isFirstOnStack
public boolean isFirstOnStack()
Description copied from interface:CompilerContext
Is this the first CompilerContext on the stack?- Specified by:
isFirstOnStack
in interfaceCompilerContext
- See Also:
CompilerContext.isFirstOnStack()
-
setInUse
public void setInUse(boolean inUse)
Set the in use state for the compiler context.- Specified by:
setInUse
in interfaceCompilerContext
- Parameters:
inUse
- The new inUse state for the compiler context.
-
getInUse
public boolean getInUse()
Return the in use state for the compiler context.- Specified by:
getInUse
in interfaceCompilerContext
- Returns:
- boolean The in use state for the compiler context.
-
setReliability
public void setReliability(int reliability)
Sets which kind of query fragments are NOT allowed. Basically, these are fragments which return unstable results. CHECK CONSTRAINTS and CREATE PUBLICATION want to forbid certain kinds of fragments.- Specified by:
setReliability
in interfaceCompilerContext
- Parameters:
reliability
- bitmask of types of query fragments to be forbidden see the reliability bitmasks in CompilerContext.java
-
getReliability
public int getReliability()
Return the reliability requirements of this clause. See setReliability() for a definition of clause reliability.- Specified by:
getReliability
in interfaceCompilerContext
- Returns:
- a bitmask of which types of query fragments are to be forbidden
-
getStoreCostController
public StoreCostController getStoreCostController(long conglomerateNumber) throws StandardException
Description copied from interface:CompilerContext
Get a StoreCostController for the given conglomerate.- Specified by:
getStoreCostController
in interfaceCompilerContext
- Parameters:
conglomerateNumber
- The conglomerate for which to get a StoreCostController.- Returns:
- The appropriate StoreCostController.
- Throws:
StandardException
- Thrown on error- See Also:
CompilerContext.getStoreCostController(long)
-
closeStoreCostControllers
private void closeStoreCostControllers()
-
getSortCostController
public SortCostController getSortCostController() throws StandardException
Description copied from interface:CompilerContext
Get a SortCostController.- Specified by:
getSortCostController
in interfaceCompilerContext
- Throws:
StandardException
- Thrown on error- See Also:
CompilerContext.getSortCostController()
-
closeSortCostControllers
private void closeSortCostControllers()
- Throws:
StandardException
- Thrown on error
-
getCompilationSchema
public SchemaDescriptor getCompilationSchema()
Get the compilation schema descriptor for this compilation context. Will be null if no default schema lookups have occured. Ie. the statement is independent of the current schema.- Specified by:
getCompilationSchema
in interfaceCompilerContext
- Returns:
- the compilation schema descirptor
-
setCompilationSchema
public SchemaDescriptor setCompilationSchema(SchemaDescriptor newDefault)
Set the compilation schema descriptor for this compilation context.- Specified by:
setCompilationSchema
in interfaceCompilerContext
- Parameters:
newDefault
- the compilation schema- Returns:
- the previous compilation schema descirptor
-
pushCompilationSchema
public void pushCompilationSchema(SchemaDescriptor sd)
Description copied from interface:CompilerContext
Push a default schema to use when compiling.Sometimes, we need to temporarily change the default schema, for example when recompiling a view, since the execution time default schema may differ from the required default schema when the view was defined. Another case is when compiling generated columns which reference unqualified user functions.
- Specified by:
pushCompilationSchema
in interfaceCompilerContext
- Parameters:
sd
- schema to use- See Also:
CompilerContext.pushCompilationSchema(org.apache.derby.iapi.sql.dictionary.SchemaDescriptor)
-
popCompilationSchema
public void popCompilationSchema()
Description copied from interface:CompilerContext
Pop the default schema to use when compiling.- Specified by:
popCompilationSchema
in interfaceCompilerContext
- See Also:
CompilerContext.popCompilationSchema()
-
setParameterList
public void setParameterList(java.util.List<ParameterNode> parameterList)
Description copied from interface:CompilerContext
Set the parameter list.- Specified by:
setParameterList
in interfaceCompilerContext
- Parameters:
parameterList
- The parameter list.- See Also:
CompilerContext.setParameterList(java.util.List<org.apache.derby.impl.sql.compile.ParameterNode>)
-
getParameterList
public java.util.List<ParameterNode> getParameterList()
Description copied from interface:CompilerContext
Get the parameter list.- Specified by:
getParameterList
in interfaceCompilerContext
- Returns:
- The parameter list.
- See Also:
CompilerContext.getParameterList()
-
setReturnParameterFlag
public void setReturnParameterFlag()
Description copied from interface:CompilerContext
If callable statement uses ? = form- Specified by:
setReturnParameterFlag
in interfaceCompilerContext
- See Also:
CompilerContext.setReturnParameterFlag()
-
getReturnParameterFlag
public boolean getReturnParameterFlag()
Description copied from interface:CompilerContext
Is the callable statement uses ? for return parameter.- Specified by:
getReturnParameterFlag
in interfaceCompilerContext
- Returns:
- true if ? = call else false
- See Also:
CompilerContext.getReturnParameterFlag()
-
getParameterTypes
DataTypeDescriptor[] getParameterTypes()
Get an array of type descriptors for all the ? parameters.
-
setScanIsolationLevel
public void setScanIsolationLevel(int isolationLevel)
Description copied from interface:CompilerContext
Set the isolation level for the scans in this query.- Specified by:
setScanIsolationLevel
in interfaceCompilerContext
- Parameters:
isolationLevel
- The isolation level to use.- See Also:
CompilerContext.setScanIsolationLevel(int)
-
getScanIsolationLevel
public int getScanIsolationLevel()
Description copied from interface:CompilerContext
Get the isolation level for the scans in this query.- Specified by:
getScanIsolationLevel
in interfaceCompilerContext
- Returns:
- The isolation level for the scans in this query.
- See Also:
CompilerContext.getScanIsolationLevel()
-
getTypeCompilerFactory
public TypeCompilerFactory getTypeCompilerFactory()
Description copied from interface:CompilerContext
Get the TypeCompilerFactory from this CompilerContext.- Specified by:
getTypeCompilerFactory
in interfaceCompilerContext
- Returns:
- The TypeCompilerFactory associated with this CompilerContext
- See Also:
CompilerContext.getTypeCompilerFactory()
-
addWarning
public void addWarning(java.sql.SQLWarning warning)
Add a compile time warning.- Specified by:
addWarning
in interfaceCompilerContext
-
getWarnings
public java.sql.SQLWarning getWarnings()
Get the chain of compile time warnings.- Specified by:
getWarnings
in interfaceCompilerContext
-
initRequiredPriv
private void initRequiredPriv()
-
pushCurrentPrivType
public void pushCurrentPrivType(int privType)
Sets the current privilege type context. Column and table nodes do not know how they are being used. Higher level nodes in the query tree do not know what is being referenced. Keeping the context allows the two to come together.- Specified by:
pushCurrentPrivType
in interfaceCompilerContext
- Parameters:
privType
- One of the privilege types in org.apache.derby.iapi.sql.conn.Authorizer.
-
popCurrentPrivType
public void popCurrentPrivType()
- Specified by:
popCurrentPrivType
in interfaceCompilerContext
-
addRequiredColumnPriv
public void addRequiredColumnPriv(ColumnDescriptor column)
Add a column privilege to the list of used column privileges.- Specified by:
addRequiredColumnPriv
in interfaceCompilerContext
- Parameters:
column
- The column whose privileges we're interested in.
-
addRequiredTablePriv
public void addRequiredTablePriv(TableDescriptor table)
Add a table or view privilege to the list of used table privileges.- Specified by:
addRequiredTablePriv
in interfaceCompilerContext
- See Also:
CompilerContext.addRequiredRoutinePriv(org.apache.derby.iapi.sql.dictionary.AliasDescriptor)
-
addRequiredRoutinePriv
public void addRequiredRoutinePriv(AliasDescriptor routine)
Add a routine execute privilege to the list of used routine privileges.- Specified by:
addRequiredRoutinePriv
in interfaceCompilerContext
- See Also:
CompilerContext.addRequiredRoutinePriv(org.apache.derby.iapi.sql.dictionary.AliasDescriptor)
-
addRequiredUsagePriv
public void addRequiredUsagePriv(PrivilegedSQLObject usableObject)
Description copied from interface:CompilerContext
Add a usage privilege to the list of required privileges.- Specified by:
addRequiredUsagePriv
in interfaceCompilerContext
- See Also:
CompilerContext.addRequiredUsagePriv(org.apache.derby.iapi.sql.dictionary.PrivilegedSQLObject)
-
addRequiredSchemaPriv
public void addRequiredSchemaPriv(java.lang.String schemaName, java.lang.String aid, int privType)
Add a required schema privilege to the list privileges.- Specified by:
addRequiredSchemaPriv
in interfaceCompilerContext
- Parameters:
schemaName
- Schema name of the object that is being accessedaid
- Requested authorizationId for new schemaprivType
- CREATE_SCHEMA_PRIV, MODIFY_SCHEMA_PRIV or DROP_SCHEMA_PRIV- See Also:
CompilerContext.addRequiredSchemaPriv(java.lang.String, java.lang.String, int)
-
addRequiredRolePriv
public void addRequiredRolePriv(java.lang.String roleName, int privType)
Add a required role privilege to the list privileges.- Specified by:
addRequiredRolePriv
in interfaceCompilerContext
- See Also:
CompilerContext.addRequiredRolePriv(java.lang.String, int)
-
getRequiredPermissionsList
public java.util.List<StatementPermission> getRequiredPermissionsList()
- Specified by:
getRequiredPermissionsList
in interfaceCompilerContext
- Returns:
- The list of required privileges.
-
addReferencedSequence
public void addReferencedSequence(SequenceDescriptor sd)
Description copied from interface:CompilerContext
Add a sequence descriptor to the list of referenced sequences.- Specified by:
addReferencedSequence
in interfaceCompilerContext
-
isReferenced
public boolean isReferenced(SequenceDescriptor sd)
Report whether the given sequence has been referenced already.- Specified by:
isReferenced
in interfaceCompilerContext
-
addPrivilegeFilter
public void addPrivilegeFilter(VisitableFilter vf)
Description copied from interface:CompilerContext
Add a filter for determining which QueryTreeNodes give rise to privilege checks at run time. The null filter (the default) says that all QueryTreeNodes potentially give rise to privilege checks.- Specified by:
addPrivilegeFilter
in interfaceCompilerContext
-
removePrivilegeFilter
public void removePrivilegeFilter(VisitableFilter vf)
Description copied from interface:CompilerContext
Remove a filter for determining which QueryTreeNodes give rise to privilege checks at run time.- Specified by:
removePrivilegeFilter
in interfaceCompilerContext
-
passesPrivilegeFilters
public boolean passesPrivilegeFilters(Visitable visitable) throws StandardException
Description copied from interface:CompilerContext
Return true if a QueryTreeNode passes all of the filters which determine whether the QueryTreeNode gives rise to run time privilege checks.- Specified by:
passesPrivilegeFilters
in interfaceCompilerContext
- Throws:
StandardException
-
beginScope
public void beginScope(java.lang.String scopeName)
Description copied from interface:CompilerContext
Record that the compiler is entering a named scope. Increment the depth counter for that scope.- Specified by:
beginScope
in interfaceCompilerContext
-
endScope
public void endScope(java.lang.String scopeName)
Description copied from interface:CompilerContext
Record that the compiler is exiting a named scope. Decrement the depth counter for that scope.- Specified by:
endScope
in interfaceCompilerContext
-
scopeDepth
public int scopeDepth(java.lang.String scopeName)
Description copied from interface:CompilerContext
Get the current depth for the named scope. For instance, if we are processing a WHERE clause inside a subquery which is invoked inside an outer WHERE clause, the depth of the whereScope would be 2. Returns 0 if the compiler isn't inside any such scope.- Specified by:
scopeDepth
in interfaceCompilerContext
-
skipTypePrivileges
public boolean skipTypePrivileges(boolean skip)
Set whether we should skip adding USAGE privileges for user-defined types- Specified by:
skipTypePrivileges
in interfaceCompilerContext
-
skippingTypePrivileges
public boolean skippingTypePrivileges()
Return whether we are skipping USAGE privileges for user-defined types- Specified by:
skippingTypePrivileges
in interfaceCompilerContext
-
-