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.StringclassPrefixprivate SchemaDescriptorcompilationSchemaprivate ProviderListcurrentAPLprivate DependentcurrentDependentprivate intcurrPrivTypeprivate java.lang.ObjectcursorInfoprivate java.util.ArrayList<SchemaDescriptor>defaultSchemaStackSaved execution time default schema, if we need to change it temporarily.private DependencyManagerdmprivate booleanfirstOnStackprivate booleaninUseprivate LanguageConnectionContextlccprivate LanguageConnectionFactorylcfprivate java.util.HashMap<java.lang.String,int[]>namedScopesprivate longnextClassNameprivate intnextColumnNumberprivate intnextEquivalenceClassprivate intnextResultSetNumberprivate intnextSubqueryNumberprivate intnextTableNumberprivate DataTypeDescriptor[]parameterDescriptorsprivate java.util.List<ParameterNode>parameterListprivate Parserparserprivate java.util.ArrayList<VisitableFilter>privilegeCheckFiltersprivate java.util.ArrayList<java.lang.Integer>privTypeStackprivate java.util.HashMap<UUID,SequenceDescriptor>referencedSequencesprivate intreliabilityprivate java.util.HashMap<StatementTablePermission,StatementColumnPermission>requiredColumnPrivilegesprivate java.util.HashMap<StatementRolePermission,StatementRolePermission>requiredRolePrivilegesprivate java.util.HashMap<UUID,java.lang.Integer>requiredRoutinePrivilegesprivate java.util.HashMap<StatementSchemaPermission,StatementSchemaPermission>requiredSchemaPrivilegesprivate java.util.HashMap<StatementTablePermission,StatementTablePermission>requiredTablePrivilegesprivate java.util.HashMap<UUID,java.lang.String>requiredUsagePrivilegesprivate booleanreturnParameterFlagprivate java.util.List<java.lang.Object>savedObjectsprivate intscanIsolationLevelprivate static intSCOPE_CELLprivate booleanskippingTypePrivilegesprivate SortCostControllersortCostControllerprivate java.util.HashMap<java.lang.Long,StoreCostController>storeCostControllersMap that contains all store cost controllers opened in this compiler context.private TypeCompilerFactorytypeCompilerFactoryprivate java.sql.SQLWarningwarnings-
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 voidaddPrivilegeFilter(VisitableFilter vf)Add a filter for determining which QueryTreeNodes give rise to privilege checks at run time.private voidaddProviderToAuxiliaryList(Provider p)Add a Provider to the current AuxiliaryProviderList, if one exists.voidaddReferencedSequence(SequenceDescriptor sd)Add a sequence descriptor to the list of referenced sequences.voidaddRequiredColumnPriv(ColumnDescriptor column)Add a column privilege to the list of used column privileges.voidaddRequiredRolePriv(java.lang.String roleName, int privType)Add a required role privilege to the list privileges.voidaddRequiredRoutinePriv(AliasDescriptor routine)Add a routine execute privilege to the list of used routine privileges.voidaddRequiredSchemaPriv(java.lang.String schemaName, java.lang.String aid, int privType)Add a required schema privilege to the list privileges.voidaddRequiredTablePriv(TableDescriptor table)Add a table or view privilege to the list of used table privileges.voidaddRequiredUsagePriv(PrivilegedSQLObject usableObject)Add a usage privilege to the list of required privileges.intaddSavedObject(java.lang.Object obj)Add an object to the pool that is created at compile time and used at execution time.voidaddWarning(java.sql.SQLWarning warning)Add a compile time warning.voidbeginScope(java.lang.String scopeName)Record that the compiler is entering a named scope.voidcleanupOnError(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 voidcloseSortCostControllers()private voidcloseStoreCostControllers()voidcreateDependency(Dependent d, Provider p)Add a dependency between two objects.voidcreateDependency(Provider p)Add a dependency for the current dependent.voidendScope(java.lang.String scopeName)Record that the compiler is exiting a named scope.voidfirstOnStack()Mark this CompilerContext as the first on the stack, so we can avoid continually popping and pushing a CompilerContext.ClassFactorygetClassFactory()Return the class factory to use in this compilation.SchemaDescriptorgetCompilationSchema()Get the compilation schema descriptor for this compilation context.ProviderListgetCurrentAuxiliaryProviderList()Get the current auxiliary provider list from this CompilerContext.java.lang.ObjectgetCursorInfo()Get the cursor info stored in the context.booleangetInUse()Return the in use state for the compiler context.JavaFactorygetJavaFactory()Get the JavaFactory from this CompilerContext.intgetNextColumnNumber()Get the current next column number (for generated column names) from this CompilerContext.intgetNextEquivalenceClass()Get the next equivalence class for equijoin clauses.intgetNextResultSetNumber()Get the current next ResultSet number from this CompilerContext.intgetNextSubqueryNumber()Get the current next subquery number from this CompilerContext.intgetNextTableNumber()Get the current next table number from this CompilerContext.intgetNumResultSets()Get the number of Results in the current statement from this CompilerContext.intgetNumSubquerys()Get the number of subquerys in the current statement from this CompilerContext.intgetNumTables()Get the number of tables in the current statement from this CompilerContext.OptimizerFactorygetOptimizerFactory()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 ?ParsergetParser()Get the Parser from this CompilerContextintgetReliability()Return the reliability requirements of this clause.java.util.List<StatementPermission>getRequiredPermissionsList()booleangetReturnParameterFlag()Is the callable statement uses ?java.lang.Object[]getSavedObjects()Get the saved object pool (for putting into the prepared statement).intgetScanIsolationLevel()Get the isolation level for the scans in this query.SortCostControllergetSortCostController()Get a SortCostController.StoreCostControllergetStoreCostController(long conglomerateNumber)Get a StoreCostController for the given conglomerate.TypeCompilerFactorygetTypeCompilerFactory()Get the TypeCompilerFactory from this CompilerContext.java.lang.StringgetUniqueClassName()Get a unique Class name from this CompilerContext.java.sql.SQLWarninggetWarnings()Get the chain of compile time warnings.private voidinitRequiredPriv()booleanisFirstOnStack()Is this the first CompilerContext on the stack?booleanisReferenced(SequenceDescriptor sd)Report whether the given sequence has been referenced already.booleanpassesPrivilegeFilters(Visitable visitable)Return true if a QueryTreeNode passes all of the filters which determine whether the QueryTreeNode gives rise to run time privilege checks.voidpopCompilationSchema()Pop the default schema to use when compiling.voidpopCurrentPrivType()voidpushCompilationSchema(SchemaDescriptor sd)Push a default schema to use when compiling.voidpushCurrentPrivType(int privType)Sets the current privilege type context.voidremovePrivilegeFilter(VisitableFilter vf)Remove a filter for determining which QueryTreeNodes give rise to privilege checks at run time.voidresetContext()Reset compiler context (as for instance, when we recycle a context for use by another compilation.voidresetNextResultSetNumber()Reset the next ResultSet number from this CompilerContext.intscopeDepth(java.lang.String scopeName)Get the current depth for the named scope.SchemaDescriptorsetCompilationSchema(SchemaDescriptor newDefault)Set the compilation schema descriptor for this compilation context.voidsetCurrentAuxiliaryProviderList(ProviderList apl)Set the current auxiliary provider list for this CompilerContext.voidsetCurrentDependent(Dependent d)Set the current dependent from this CompilerContext.voidsetCursorInfo(java.lang.Object cursorInfo)Set paramsvoidsetInUse(boolean inUse)Set the in use state for the compiler context.voidsetParameterList(java.util.List<ParameterNode> parameterList)Set the parameter list.voidsetReliability(int reliability)Sets which kind of query fragments are NOT allowed.voidsetReturnParameterFlag()If callable statement uses ?voidsetSavedObjects(java.util.List<java.lang.Object> objs)Set the saved object pool (for putting into the prepared statement).voidsetScanIsolationLevel(int isolationLevel)Set the isolation level for the scans in this query.booleanskippingTypePrivileges()Return whether we are skipping USAGE privileges for user-defined typesbooleanskipTypePrivileges(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 StandardExceptionDescription copied from interface:ContextContexts 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:
cleanupOnErrorin 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:
resetContextin interfaceCompilerContext
-
getParser
public Parser getParser()
Description copied from interface:CompilerContextGet the Parser from this CompilerContext. *- Specified by:
getParserin interfaceCompilerContext- Returns:
- The parser associated with this CompilerContext
-
getOptimizerFactory
public OptimizerFactory getOptimizerFactory()
Get the OptimizerFactory for this context- Specified by:
getOptimizerFactoryin interfaceCompilerContext- Returns:
- The OptimizerFactory for this context.
-
getNextColumnNumber
public int getNextColumnNumber()
Description copied from interface:CompilerContextGet the current next column number (for generated column names) from this CompilerContext.- Specified by:
getNextColumnNumberin interfaceCompilerContext- Returns:
- int The next column number for the current statement.
-
getNextTableNumber
public int getNextTableNumber()
Description copied from interface:CompilerContextGet the current next table number from this CompilerContext.- Specified by:
getNextTableNumberin interfaceCompilerContext- Returns:
- int The next table number for the current statement.
-
getNumTables
public int getNumTables()
Description copied from interface:CompilerContextGet the number of tables in the current statement from this CompilerContext.- Specified by:
getNumTablesin 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:
getNextSubqueryNumberin 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:
getNumSubquerysin interfaceCompilerContext- Returns:
- int The number of subquerys in the current statement.
-
getNextResultSetNumber
public int getNextResultSetNumber()
Description copied from interface:CompilerContextGet the current next ResultSet number from this CompilerContext.- Specified by:
getNextResultSetNumberin interfaceCompilerContext- Returns:
- int The next ResultSet number for the current statement.
-
resetNextResultSetNumber
public void resetNextResultSetNumber()
Description copied from interface:CompilerContextReset the next ResultSet number from this CompilerContext.- Specified by:
resetNextResultSetNumberin interfaceCompilerContext
-
getNumResultSets
public int getNumResultSets()
Description copied from interface:CompilerContextGet the number of Results in the current statement from this CompilerContext.- Specified by:
getNumResultSetsin interfaceCompilerContext- Returns:
- The number of ResultSets in the current statement.
-
getUniqueClassName
public java.lang.String getUniqueClassName()
Description copied from interface:CompilerContextGet a unique Class name from this CompilerContext. Ensures it is globally unique for this JVM.- Specified by:
getUniqueClassNamein interfaceCompilerContext- Returns:
- String A unique-enough class name.
-
getNextEquivalenceClass
public int getNextEquivalenceClass()
Get the next equivalence class for equijoin clauses.- Specified by:
getNextEquivalenceClassin interfaceCompilerContext- Returns:
- The next equivalence class for equijoin clauses.
-
getClassFactory
public ClassFactory getClassFactory()
Description copied from interface:CompilerContextReturn the class factory to use in this compilation.- Specified by:
getClassFactoryin interfaceCompilerContext
-
getJavaFactory
public JavaFactory getJavaFactory()
Description copied from interface:CompilerContextGet the JavaFactory from this CompilerContext.- Specified by:
getJavaFactoryin interfaceCompilerContext- Returns:
- The JavaFactory associated with this CompilerContext
-
setCurrentDependent
public void setCurrentDependent(Dependent d)
Description copied from interface:CompilerContextSet 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:
setCurrentDependentin interfaceCompilerContext- Parameters:
d- The Dependent currently being compiled.
-
getCurrentAuxiliaryProviderList
public ProviderList getCurrentAuxiliaryProviderList()
Get the current auxiliary provider list from this CompilerContext.- Specified by:
getCurrentAuxiliaryProviderListin interfaceCompilerContext- Returns:
- The current AuxiliaryProviderList.
-
setCurrentAuxiliaryProviderList
public void setCurrentAuxiliaryProviderList(ProviderList apl)
Set the current auxiliary provider list for this CompilerContext.- Specified by:
setCurrentAuxiliaryProviderListin interfaceCompilerContext- Parameters:
apl- The new current AuxiliaryProviderList.
-
createDependency
public void createDependency(Provider p) throws StandardException
Description copied from interface:CompilerContextAdd a dependency for the current dependent.- Specified by:
createDependencyin 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:
createDependencyin 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:CompilerContextAdd 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:
addSavedObjectin 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:CompilerContextGet the saved object pool (for putting into the prepared statement). This turns it into its storable form, an array of objects.- Specified by:
getSavedObjectsin interfaceCompilerContext- Returns:
- the saved object pool.
-
setSavedObjects
public void setSavedObjects(java.util.List<java.lang.Object> objs)
Description copied from interface:CompilerContextSet the saved object pool (for putting into the prepared statement).- Specified by:
setSavedObjectsin 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:CompilerContextSet params- Specified by:
setCursorInfoin interfaceCompilerContext- Parameters:
cursorInfo- the cursor info- See Also:
CompilerContext.setCursorInfo(java.lang.Object)
-
getCursorInfo
public java.lang.Object getCursorInfo()
Description copied from interface:CompilerContextGet the cursor info stored in the context.- Specified by:
getCursorInfoin interfaceCompilerContext- Returns:
- the cursor info
- See Also:
CompilerContext.getCursorInfo()
-
firstOnStack
public void firstOnStack()
Description copied from interface:CompilerContextMark this CompilerContext as the first on the stack, so we can avoid continually popping and pushing a CompilerContext.- Specified by:
firstOnStackin interfaceCompilerContext- See Also:
CompilerContext.firstOnStack()
-
isFirstOnStack
public boolean isFirstOnStack()
Description copied from interface:CompilerContextIs this the first CompilerContext on the stack?- Specified by:
isFirstOnStackin interfaceCompilerContext- See Also:
CompilerContext.isFirstOnStack()
-
setInUse
public void setInUse(boolean inUse)
Set the in use state for the compiler context.- Specified by:
setInUsein 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:
getInUsein 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:
setReliabilityin 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:
getReliabilityin 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:CompilerContextGet a StoreCostController for the given conglomerate.- Specified by:
getStoreCostControllerin 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:CompilerContextGet a SortCostController.- Specified by:
getSortCostControllerin 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:
getCompilationSchemain interfaceCompilerContext- Returns:
- the compilation schema descirptor
-
setCompilationSchema
public SchemaDescriptor setCompilationSchema(SchemaDescriptor newDefault)
Set the compilation schema descriptor for this compilation context.- Specified by:
setCompilationSchemain interfaceCompilerContext- Parameters:
newDefault- the compilation schema- Returns:
- the previous compilation schema descirptor
-
pushCompilationSchema
public void pushCompilationSchema(SchemaDescriptor sd)
Description copied from interface:CompilerContextPush 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:
pushCompilationSchemain 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:CompilerContextPop the default schema to use when compiling.- Specified by:
popCompilationSchemain interfaceCompilerContext- See Also:
CompilerContext.popCompilationSchema()
-
setParameterList
public void setParameterList(java.util.List<ParameterNode> parameterList)
Description copied from interface:CompilerContextSet the parameter list.- Specified by:
setParameterListin 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:CompilerContextGet the parameter list.- Specified by:
getParameterListin interfaceCompilerContext- Returns:
- The parameter list.
- See Also:
CompilerContext.getParameterList()
-
setReturnParameterFlag
public void setReturnParameterFlag()
Description copied from interface:CompilerContextIf callable statement uses ? = form- Specified by:
setReturnParameterFlagin interfaceCompilerContext- See Also:
CompilerContext.setReturnParameterFlag()
-
getReturnParameterFlag
public boolean getReturnParameterFlag()
Description copied from interface:CompilerContextIs the callable statement uses ? for return parameter.- Specified by:
getReturnParameterFlagin 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:CompilerContextSet the isolation level for the scans in this query.- Specified by:
setScanIsolationLevelin interfaceCompilerContext- Parameters:
isolationLevel- The isolation level to use.- See Also:
CompilerContext.setScanIsolationLevel(int)
-
getScanIsolationLevel
public int getScanIsolationLevel()
Description copied from interface:CompilerContextGet the isolation level for the scans in this query.- Specified by:
getScanIsolationLevelin interfaceCompilerContext- Returns:
- The isolation level for the scans in this query.
- See Also:
CompilerContext.getScanIsolationLevel()
-
getTypeCompilerFactory
public TypeCompilerFactory getTypeCompilerFactory()
Description copied from interface:CompilerContextGet the TypeCompilerFactory from this CompilerContext.- Specified by:
getTypeCompilerFactoryin 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:
addWarningin interfaceCompilerContext
-
getWarnings
public java.sql.SQLWarning getWarnings()
Get the chain of compile time warnings.- Specified by:
getWarningsin 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:
pushCurrentPrivTypein interfaceCompilerContext- Parameters:
privType- One of the privilege types in org.apache.derby.iapi.sql.conn.Authorizer.
-
popCurrentPrivType
public void popCurrentPrivType()
- Specified by:
popCurrentPrivTypein interfaceCompilerContext
-
addRequiredColumnPriv
public void addRequiredColumnPriv(ColumnDescriptor column)
Add a column privilege to the list of used column privileges.- Specified by:
addRequiredColumnPrivin 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:
addRequiredTablePrivin 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:
addRequiredRoutinePrivin interfaceCompilerContext- See Also:
CompilerContext.addRequiredRoutinePriv(org.apache.derby.iapi.sql.dictionary.AliasDescriptor)
-
addRequiredUsagePriv
public void addRequiredUsagePriv(PrivilegedSQLObject usableObject)
Description copied from interface:CompilerContextAdd a usage privilege to the list of required privileges.- Specified by:
addRequiredUsagePrivin 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:
addRequiredSchemaPrivin 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:
addRequiredRolePrivin interfaceCompilerContext- See Also:
CompilerContext.addRequiredRolePriv(java.lang.String, int)
-
getRequiredPermissionsList
public java.util.List<StatementPermission> getRequiredPermissionsList()
- Specified by:
getRequiredPermissionsListin interfaceCompilerContext- Returns:
- The list of required privileges.
-
addReferencedSequence
public void addReferencedSequence(SequenceDescriptor sd)
Description copied from interface:CompilerContextAdd a sequence descriptor to the list of referenced sequences.- Specified by:
addReferencedSequencein interfaceCompilerContext
-
isReferenced
public boolean isReferenced(SequenceDescriptor sd)
Report whether the given sequence has been referenced already.- Specified by:
isReferencedin interfaceCompilerContext
-
addPrivilegeFilter
public void addPrivilegeFilter(VisitableFilter vf)
Description copied from interface:CompilerContextAdd 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:
addPrivilegeFilterin interfaceCompilerContext
-
removePrivilegeFilter
public void removePrivilegeFilter(VisitableFilter vf)
Description copied from interface:CompilerContextRemove a filter for determining which QueryTreeNodes give rise to privilege checks at run time.- Specified by:
removePrivilegeFilterin interfaceCompilerContext
-
passesPrivilegeFilters
public boolean passesPrivilegeFilters(Visitable visitable) throws StandardException
Description copied from interface:CompilerContextReturn true if a QueryTreeNode passes all of the filters which determine whether the QueryTreeNode gives rise to run time privilege checks.- Specified by:
passesPrivilegeFiltersin interfaceCompilerContext- Throws:
StandardException
-
beginScope
public void beginScope(java.lang.String scopeName)
Description copied from interface:CompilerContextRecord that the compiler is entering a named scope. Increment the depth counter for that scope.- Specified by:
beginScopein interfaceCompilerContext
-
endScope
public void endScope(java.lang.String scopeName)
Description copied from interface:CompilerContextRecord that the compiler is exiting a named scope. Decrement the depth counter for that scope.- Specified by:
endScopein interfaceCompilerContext
-
scopeDepth
public int scopeDepth(java.lang.String scopeName)
Description copied from interface:CompilerContextGet 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:
scopeDepthin interfaceCompilerContext
-
skipTypePrivileges
public boolean skipTypePrivileges(boolean skip)
Set whether we should skip adding USAGE privileges for user-defined types- Specified by:
skipTypePrivilegesin interfaceCompilerContext
-
skippingTypePrivileges
public boolean skippingTypePrivileges()
Return whether we are skipping USAGE privileges for user-defined types- Specified by:
skippingTypePrivilegesin interfaceCompilerContext
-
-