public class CompilerContextImpl extends ContextImpl implements CompilerContext
Modifier and Type | Field and 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 |
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 and 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).
|
Modifier and Type | Method and 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 context
|
java.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 CompilerContext
|
int |
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 params
|
void |
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 types
|
boolean |
skipTypePrivileges(boolean skip)
Set whether we should skip adding USAGE privileges for user-defined types
|
appendErrorInfo, getContextManager, getIdName, isLastHandler, popMe, pushMe
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getContextManager, getIdName, isLastHandler, popMe, pushMe
private static final int SCOPE_CELL
private final Parser parser
private final LanguageConnectionContext lcc
private final LanguageConnectionFactory lcf
private TypeCompilerFactory typeCompilerFactory
private Dependent currentDependent
private DependencyManager dm
private boolean firstOnStack
private boolean inUse
private int reliability
private int nextColumnNumber
private int nextTableNumber
private int nextSubqueryNumber
private int nextResultSetNumber
private int scanIsolationLevel
private int nextEquivalenceClass
private long nextClassName
private java.util.List<java.lang.Object> savedObjects
private java.lang.String classPrefix
private SchemaDescriptor compilationSchema
private java.util.ArrayList<VisitableFilter> privilegeCheckFilters
private java.util.HashMap<java.lang.String,int[]> namedScopes
private boolean skippingTypePrivileges
private java.util.ArrayList<SchemaDescriptor> defaultSchemaStack
private ProviderList currentAPL
private boolean returnParameterFlag
private final java.util.HashMap<java.lang.Long,StoreCostController> storeCostControllers
private SortCostController sortCostController
private java.util.List<ParameterNode> parameterList
private DataTypeDescriptor[] parameterDescriptors
private java.lang.Object cursorInfo
private java.sql.SQLWarning warnings
private final java.util.ArrayList<java.lang.Integer> privTypeStack
private int currPrivType
private java.util.HashMap<StatementTablePermission,StatementColumnPermission> requiredColumnPrivileges
private java.util.HashMap<StatementTablePermission,StatementTablePermission> requiredTablePrivileges
private java.util.HashMap<StatementSchemaPermission,StatementSchemaPermission> requiredSchemaPrivileges
private java.util.HashMap<UUID,java.lang.Integer> requiredRoutinePrivileges
private java.util.HashMap<UUID,java.lang.String> requiredUsagePrivileges
private java.util.HashMap<StatementRolePermission,StatementRolePermission> requiredRolePrivileges
private java.util.HashMap<UUID,SequenceDescriptor> referencedSequences
public CompilerContextImpl(ContextManager cm, LanguageConnectionContext lcc, TypeCompilerFactory typeCompilerFactory)
public void cleanupOnError(java.lang.Throwable error) throws StandardException
Context
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).
cleanupOnError
in interface Context
StandardException
- thrown by makeInvalid() callpublic void resetContext()
resetContext
in interface CompilerContext
public Parser getParser()
CompilerContext
getParser
in interface CompilerContext
public OptimizerFactory getOptimizerFactory()
getOptimizerFactory
in interface CompilerContext
public int getNextColumnNumber()
CompilerContext
getNextColumnNumber
in interface CompilerContext
public int getNextTableNumber()
CompilerContext
getNextTableNumber
in interface CompilerContext
public int getNumTables()
CompilerContext
getNumTables
in interface CompilerContext
public int getNextSubqueryNumber()
getNextSubqueryNumber
in interface CompilerContext
public int getNumSubquerys()
getNumSubquerys
in interface CompilerContext
public int getNextResultSetNumber()
CompilerContext
getNextResultSetNumber
in interface CompilerContext
public void resetNextResultSetNumber()
CompilerContext
resetNextResultSetNumber
in interface CompilerContext
public int getNumResultSets()
CompilerContext
getNumResultSets
in interface CompilerContext
public java.lang.String getUniqueClassName()
CompilerContext
getUniqueClassName
in interface CompilerContext
public int getNextEquivalenceClass()
getNextEquivalenceClass
in interface CompilerContext
public ClassFactory getClassFactory()
CompilerContext
getClassFactory
in interface CompilerContext
public JavaFactory getJavaFactory()
CompilerContext
getJavaFactory
in interface CompilerContext
public void setCurrentDependent(Dependent d)
CompilerContext
setCurrentDependent
in interface CompilerContext
d
- The Dependent currently being compiled.public ProviderList getCurrentAuxiliaryProviderList()
getCurrentAuxiliaryProviderList
in interface CompilerContext
public void setCurrentAuxiliaryProviderList(ProviderList apl)
setCurrentAuxiliaryProviderList
in interface CompilerContext
apl
- The new current AuxiliaryProviderList.public void createDependency(Provider p) throws StandardException
CompilerContext
createDependency
in interface CompilerContext
p
- The Provider of the dependency.StandardException
- thrown on failure.public void createDependency(Dependent d, Provider p) throws StandardException
createDependency
in interface CompilerContext
d
- The Dependent object.p
- The Provider of the dependency.StandardException
- thrown on failure.private void addProviderToAuxiliaryList(Provider p)
p
- The Provider to add.public int addSavedObject(java.lang.Object obj)
CompilerContext
(#objectType) (this.getPreparedStatement().getSavedObject(#int))
addSavedObject
in interface CompilerContext
obj
- object to add to the pool of saved objectspublic java.lang.Object[] getSavedObjects()
CompilerContext
getSavedObjects
in interface CompilerContext
public void setSavedObjects(java.util.List<java.lang.Object> objs)
CompilerContext
setSavedObjects
in interface CompilerContext
objs
- The new saved objectsCompilerContext.setSavedObjects(java.util.List<java.lang.Object>)
public void setCursorInfo(java.lang.Object cursorInfo)
CompilerContext
setCursorInfo
in interface CompilerContext
cursorInfo
- the cursor infoCompilerContext.setCursorInfo(java.lang.Object)
public java.lang.Object getCursorInfo()
CompilerContext
getCursorInfo
in interface CompilerContext
CompilerContext.getCursorInfo()
public void firstOnStack()
CompilerContext
firstOnStack
in interface CompilerContext
CompilerContext.firstOnStack()
public boolean isFirstOnStack()
CompilerContext
isFirstOnStack
in interface CompilerContext
CompilerContext.isFirstOnStack()
public void setInUse(boolean inUse)
setInUse
in interface CompilerContext
inUse
- The new inUse state for the compiler context.public boolean getInUse()
getInUse
in interface CompilerContext
public void setReliability(int reliability)
setReliability
in interface CompilerContext
reliability
- bitmask of types of query fragments to be forbidden
see the reliability bitmasks in CompilerContext.javapublic int getReliability()
getReliability
in interface CompilerContext
public StoreCostController getStoreCostController(long conglomerateNumber) throws StandardException
CompilerContext
getStoreCostController
in interface CompilerContext
conglomerateNumber
- The conglomerate for which to get a
StoreCostController.StandardException
- Thrown on errorCompilerContext.getStoreCostController(long)
private void closeStoreCostControllers()
public SortCostController getSortCostController() throws StandardException
CompilerContext
getSortCostController
in interface CompilerContext
StandardException
- Thrown on errorCompilerContext.getSortCostController()
private void closeSortCostControllers()
StandardException
- Thrown on errorpublic SchemaDescriptor getCompilationSchema()
getCompilationSchema
in interface CompilerContext
public SchemaDescriptor setCompilationSchema(SchemaDescriptor newDefault)
setCompilationSchema
in interface CompilerContext
newDefault
- the compilation schemapublic void pushCompilationSchema(SchemaDescriptor sd)
CompilerContext
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.
pushCompilationSchema
in interface CompilerContext
sd
- schema to useCompilerContext.pushCompilationSchema(org.apache.derby.iapi.sql.dictionary.SchemaDescriptor)
public void popCompilationSchema()
CompilerContext
popCompilationSchema
in interface CompilerContext
CompilerContext.popCompilationSchema()
public void setParameterList(java.util.List<ParameterNode> parameterList)
CompilerContext
setParameterList
in interface CompilerContext
parameterList
- The parameter list.CompilerContext.setParameterList(java.util.List<org.apache.derby.impl.sql.compile.ParameterNode>)
public java.util.List<ParameterNode> getParameterList()
CompilerContext
getParameterList
in interface CompilerContext
CompilerContext.getParameterList()
public void setReturnParameterFlag()
CompilerContext
setReturnParameterFlag
in interface CompilerContext
CompilerContext.setReturnParameterFlag()
public boolean getReturnParameterFlag()
CompilerContext
getReturnParameterFlag
in interface CompilerContext
CompilerContext.getReturnParameterFlag()
DataTypeDescriptor[] getParameterTypes()
public void setScanIsolationLevel(int isolationLevel)
CompilerContext
setScanIsolationLevel
in interface CompilerContext
isolationLevel
- The isolation level to use.CompilerContext.setScanIsolationLevel(int)
public int getScanIsolationLevel()
CompilerContext
getScanIsolationLevel
in interface CompilerContext
CompilerContext.getScanIsolationLevel()
public TypeCompilerFactory getTypeCompilerFactory()
CompilerContext
getTypeCompilerFactory
in interface CompilerContext
CompilerContext.getTypeCompilerFactory()
public void addWarning(java.sql.SQLWarning warning)
addWarning
in interface CompilerContext
public java.sql.SQLWarning getWarnings()
getWarnings
in interface CompilerContext
private void initRequiredPriv()
public void pushCurrentPrivType(int privType)
pushCurrentPrivType
in interface CompilerContext
privType
- One of the privilege types in org.apache.derby.iapi.sql.conn.Authorizer.public void popCurrentPrivType()
popCurrentPrivType
in interface CompilerContext
public void addRequiredColumnPriv(ColumnDescriptor column)
addRequiredColumnPriv
in interface CompilerContext
column
- The column whose privileges we're interested in.public void addRequiredTablePriv(TableDescriptor table)
addRequiredTablePriv
in interface CompilerContext
CompilerContext.addRequiredRoutinePriv(org.apache.derby.iapi.sql.dictionary.AliasDescriptor)
public void addRequiredRoutinePriv(AliasDescriptor routine)
addRequiredRoutinePriv
in interface CompilerContext
CompilerContext.addRequiredRoutinePriv(org.apache.derby.iapi.sql.dictionary.AliasDescriptor)
public void addRequiredUsagePriv(PrivilegedSQLObject usableObject)
CompilerContext
addRequiredUsagePriv
in interface CompilerContext
CompilerContext.addRequiredUsagePriv(org.apache.derby.iapi.sql.dictionary.PrivilegedSQLObject)
public void addRequiredSchemaPriv(java.lang.String schemaName, java.lang.String aid, int privType)
addRequiredSchemaPriv
in interface CompilerContext
schemaName
- Schema name of the object that is being accessedaid
- Requested authorizationId for new schemaprivType
- CREATE_SCHEMA_PRIV, MODIFY_SCHEMA_PRIV or DROP_SCHEMA_PRIVCompilerContext.addRequiredSchemaPriv(java.lang.String, java.lang.String, int)
public void addRequiredRolePriv(java.lang.String roleName, int privType)
addRequiredRolePriv
in interface CompilerContext
CompilerContext.addRequiredRolePriv(java.lang.String, int)
public java.util.List<StatementPermission> getRequiredPermissionsList()
getRequiredPermissionsList
in interface CompilerContext
public void addReferencedSequence(SequenceDescriptor sd)
CompilerContext
addReferencedSequence
in interface CompilerContext
public boolean isReferenced(SequenceDescriptor sd)
isReferenced
in interface CompilerContext
public void addPrivilegeFilter(VisitableFilter vf)
CompilerContext
addPrivilegeFilter
in interface CompilerContext
public void removePrivilegeFilter(VisitableFilter vf)
CompilerContext
removePrivilegeFilter
in interface CompilerContext
public boolean passesPrivilegeFilters(Visitable visitable) throws StandardException
CompilerContext
passesPrivilegeFilters
in interface CompilerContext
StandardException
public void beginScope(java.lang.String scopeName)
CompilerContext
beginScope
in interface CompilerContext
public void endScope(java.lang.String scopeName)
CompilerContext
endScope
in interface CompilerContext
public int scopeDepth(java.lang.String scopeName)
CompilerContext
scopeDepth
in interface CompilerContext
public boolean skipTypePrivileges(boolean skip)
skipTypePrivileges
in interface CompilerContext
public boolean skippingTypePrivileges()
skippingTypePrivileges
in interface CompilerContext
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.