Interface CompilerContext
-
- All Superinterfaces:
Context
- All Known Implementing Classes:
CompilerContextImpl
public interface CompilerContext extends Context
CompilerContext stores the parser and type id factory to be used by the compiler. Stack compiler contexts when a new, local parser is needed (if calling the compiler recursively from within the compiler, for example). CompilerContext objects are private to a LanguageConnectionContext. History: 5/22/97 Moved getExternalInterfaceFactory() to LanguageConnectionContext because it had to be used at execution. - Jeff
-
-
Field Summary
Fields Modifier and Type Field Description static intAGGREGATE_RESTRICTIONstatic intCASE_OPERAND_RESTRICTIONstatic intCHECK_CONSTRAINTstatic intCOLUMN_REFERENCE_ILLEGALstatic intCONDITIONAL_RESTRICTIONstatic java.lang.StringCONTEXT_IDthis is the ID we expect compiler contexts to be stored into a context manager under.static intCURRENT_CONNECTION_ILLEGALstatic intDATETIME_ILLEGALstatic intDEFAULT_RESTRICTIONstatic intDIAGNOSTICS_ILLEGALstatic intFUNCTION_CALL_ILLEGALstatic intGENERATION_CLAUSE_RESTRICTIONstatic intGROUP_BY_RESTRICTIONstatic intHAVING_CLAUSE_RESTRICTIONstatic intIGNORE_MISSING_CLASSESstatic intINTERNAL_SQL_ILLEGALstatic intINTERNAL_SQL_LEGALAny SQL we support is legalstatic intMODIFIES_SQL_DATA_PROCEDURE_ILLEGALCalling procedures that modify sql data from before triggers is illegal.static intNEXT_VALUE_FOR_ILLEGALstatic intNON_DETERMINISTIC_ILLEGALstatic intON_CLAUSE_RESTRICTIONstatic intSCHEMA_ILLEGALstatic intSQL_IN_ROUTINES_ILLEGALstatic intSQL_LEGALStandard SQL is legalstatic intSUBQUERY_ILLEGALstatic intUNNAMED_PARAMETER_ILLEGALstatic intUSER_ILLEGALstatic intWHERE_CLAUSE_RESTRICTIONstatic java.lang.StringWHERE_SCOPE
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddPrivilegeFilter(VisitableFilter vf)Add a filter for determining which QueryTreeNodes give rise to privilege checks at run time.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 of privileges.voidaddRequiredRoutinePriv(AliasDescriptor routine)Add a routine execute privilege to the list of used routine privileges.voidaddRequiredSchemaPriv(java.lang.String schema, java.lang.String aid, int privType)Add a schema privilege to the list of used 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 o)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.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 from this CompilerContext.java.util.List<ParameterNode>getParameterList()Get the parameter list.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.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 and pushes the previous on onto a stack.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 interface org.apache.derby.iapi.services.context.Context
cleanupOnError, getContextManager, getIdName, isLastHandler, popMe, pushMe
-
-
-
-
Field Detail
-
CONTEXT_ID
static final java.lang.String CONTEXT_ID
this is the ID we expect compiler contexts to be stored into a context manager under.- See Also:
- Constant Field Values
-
DATETIME_ILLEGAL
static final int DATETIME_ILLEGAL
- See Also:
- Constant Field Values
-
CURRENT_CONNECTION_ILLEGAL
static final int CURRENT_CONNECTION_ILLEGAL
- See Also:
- Constant Field Values
-
FUNCTION_CALL_ILLEGAL
static final int FUNCTION_CALL_ILLEGAL
- See Also:
- Constant Field Values
-
UNNAMED_PARAMETER_ILLEGAL
static final int UNNAMED_PARAMETER_ILLEGAL
- See Also:
- Constant Field Values
-
DIAGNOSTICS_ILLEGAL
static final int DIAGNOSTICS_ILLEGAL
- See Also:
- Constant Field Values
-
SUBQUERY_ILLEGAL
static final int SUBQUERY_ILLEGAL
- See Also:
- Constant Field Values
-
USER_ILLEGAL
static final int USER_ILLEGAL
- See Also:
- Constant Field Values
-
COLUMN_REFERENCE_ILLEGAL
static final int COLUMN_REFERENCE_ILLEGAL
- See Also:
- Constant Field Values
-
IGNORE_MISSING_CLASSES
static final int IGNORE_MISSING_CLASSES
- See Also:
- Constant Field Values
-
SCHEMA_ILLEGAL
static final int SCHEMA_ILLEGAL
- See Also:
- Constant Field Values
-
INTERNAL_SQL_ILLEGAL
static final int INTERNAL_SQL_ILLEGAL
- See Also:
- Constant Field Values
-
MODIFIES_SQL_DATA_PROCEDURE_ILLEGAL
static final int MODIFIES_SQL_DATA_PROCEDURE_ILLEGAL
Calling procedures that modify sql data from before triggers is illegal.- See Also:
- Constant Field Values
-
NON_DETERMINISTIC_ILLEGAL
static final int NON_DETERMINISTIC_ILLEGAL
- See Also:
- Constant Field Values
-
SQL_IN_ROUTINES_ILLEGAL
static final int SQL_IN_ROUTINES_ILLEGAL
- See Also:
- Constant Field Values
-
NEXT_VALUE_FOR_ILLEGAL
static final int NEXT_VALUE_FOR_ILLEGAL
- See Also:
- Constant Field Values
-
SQL_LEGAL
static final int SQL_LEGAL
Standard SQL is legal- See Also:
- Constant Field Values
-
INTERNAL_SQL_LEGAL
static final int INTERNAL_SQL_LEGAL
Any SQL we support is legal- See Also:
- Constant Field Values
-
CHECK_CONSTRAINT
static final int CHECK_CONSTRAINT
- See Also:
- Constant Field Values
-
DEFAULT_RESTRICTION
static final int DEFAULT_RESTRICTION
- See Also:
- Constant Field Values
-
GENERATION_CLAUSE_RESTRICTION
static final int GENERATION_CLAUSE_RESTRICTION
- See Also:
- Constant Field Values
-
WHERE_CLAUSE_RESTRICTION
static final int WHERE_CLAUSE_RESTRICTION
- See Also:
- Constant Field Values
-
HAVING_CLAUSE_RESTRICTION
static final int HAVING_CLAUSE_RESTRICTION
- See Also:
- Constant Field Values
-
ON_CLAUSE_RESTRICTION
static final int ON_CLAUSE_RESTRICTION
- See Also:
- Constant Field Values
-
AGGREGATE_RESTRICTION
static final int AGGREGATE_RESTRICTION
- See Also:
- Constant Field Values
-
CONDITIONAL_RESTRICTION
static final int CONDITIONAL_RESTRICTION
- See Also:
- Constant Field Values
-
GROUP_BY_RESTRICTION
static final int GROUP_BY_RESTRICTION
- See Also:
- Constant Field Values
-
CASE_OPERAND_RESTRICTION
static final int CASE_OPERAND_RESTRICTION
- See Also:
- Constant Field Values
-
WHERE_SCOPE
static final java.lang.String WHERE_SCOPE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getParser
Parser getParser()
Get the Parser from this CompilerContext. *- Returns:
- The parser associated with this CompilerContext
-
getOptimizerFactory
OptimizerFactory getOptimizerFactory()
Get the OptimizerFactory from this CompilerContext.- Returns:
- The OptimizerFactory associated with this CompilerContext
-
getTypeCompilerFactory
TypeCompilerFactory getTypeCompilerFactory()
Get the TypeCompilerFactory from this CompilerContext.- Returns:
- The TypeCompilerFactory associated with this CompilerContext
-
getClassFactory
ClassFactory getClassFactory()
Return the class factory to use in this compilation.
-
getJavaFactory
JavaFactory getJavaFactory()
Get the JavaFactory from this CompilerContext.- Returns:
- The JavaFactory associated with this CompilerContext
-
getNextColumnNumber
int getNextColumnNumber()
Get the current next column number (for generated column names) from this CompilerContext.- Returns:
- int The next column number for the current statement.
-
resetContext
void resetContext()
Reset compiler context (as for instance, when we recycle a context for use by another compilation.
-
getNextTableNumber
int getNextTableNumber()
Get the current next table number from this CompilerContext.- Returns:
- int The next table number for the current statement.
-
getNumTables
int getNumTables()
Get the number of tables in the current statement from this CompilerContext.- Returns:
- int The number of tables in the current statement.
-
getNextSubqueryNumber
int getNextSubqueryNumber()
Get the current next subquery number from this CompilerContext.- Returns:
- int The next subquery number for the current statement.
-
getNumSubquerys
int getNumSubquerys()
Get the number of subquerys in the current statement from this CompilerContext.- Returns:
- int The number of subquerys in the current statement.
-
getNextResultSetNumber
int getNextResultSetNumber()
Get the current next ResultSet number from this CompilerContext.- Returns:
- int The next ResultSet number for the current statement.
-
resetNextResultSetNumber
void resetNextResultSetNumber()
Reset the next ResultSet number from this CompilerContext.
-
getNumResultSets
int getNumResultSets()
Get the number of Results in the current statement from this CompilerContext.- Returns:
- The number of ResultSets in the current statement.
-
getUniqueClassName
java.lang.String getUniqueClassName()
Get a unique Class name from this CompilerContext. Ensures it is globally unique for this JVM.- Returns:
- String A unique-enough class name.
-
setCurrentDependent
void setCurrentDependent(Dependent d)
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.- Parameters:
d- The Dependent currently being compiled.
-
getCurrentAuxiliaryProviderList
ProviderList getCurrentAuxiliaryProviderList()
Get the current auxiliary provider list from this CompilerContext.- Returns:
- The current AuxiliaryProviderList.
-
setCurrentAuxiliaryProviderList
void setCurrentAuxiliaryProviderList(ProviderList apl)
Set the current auxiliary provider list for this CompilerContext.- Parameters:
apl- The new current AuxiliaryProviderList.
-
createDependency
void createDependency(Provider p) throws StandardException
Add a dependency for the current dependent.- Parameters:
p- The Provider of the dependency.- Throws:
StandardException- thrown on failure.
-
createDependency
void createDependency(Dependent d, Provider p) throws StandardException
Add a dependency between two objects.- Parameters:
d- The Dependent object.p- The Provider of the dependency.- Throws:
StandardException- thrown on failure.
-
addSavedObject
int addSavedObject(java.lang.Object o)
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))- Parameters:
o- object to add to the pool of saved objects- Returns:
- the entry # for the object
-
getSavedObjects
java.lang.Object[] getSavedObjects()
Get the saved object pool (for putting into the prepared statement). This turns it into its storable form, an array of objects.- Returns:
- the saved object pool.
-
setSavedObjects
void setSavedObjects(java.util.List<java.lang.Object> objs)
Set the saved object pool (for putting into the prepared statement).- Parameters:
objs- The new saved objects- Throws:
java.lang.NullPointerException- ifobjsis null
-
setInUse
void setInUse(boolean inUse)
Set the in use state for the compiler context.- Parameters:
inUse- The new inUse state for the compiler context.
-
getInUse
boolean getInUse()
Return the in use state for the compiler context.- Returns:
- boolean The in use state for the compiler context.
-
firstOnStack
void firstOnStack()
Mark this CompilerContext as the first on the stack, so we can avoid continually popping and pushing a CompilerContext.
-
isFirstOnStack
boolean isFirstOnStack()
Is this the first CompilerContext on the stack?
-
setReliability
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.- Parameters:
reliability- bitmask of types of query fragments to be forbidden see the reliability bitmasks above
-
getReliability
int getReliability()
Return the reliability requirements of this clause. See setReliability() for a definition of clause reliability.- Returns:
- a bitmask of which types of query fragments are to be forbidden
-
getCompilationSchema
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.- Returns:
- the compilation schema descirptor
-
setCompilationSchema
SchemaDescriptor setCompilationSchema(SchemaDescriptor newDefault)
Set the compilation schema descriptor for this compilation context.- Parameters:
newDefault- compilation schema- Returns:
- the previous compilation schema descirptor
-
pushCompilationSchema
void pushCompilationSchema(SchemaDescriptor sd)
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.
- Parameters:
sd- schema to use
-
popCompilationSchema
void popCompilationSchema()
Pop the default schema to use when compiling.
-
getStoreCostController
StoreCostController getStoreCostController(long conglomerateNumber) throws StandardException
Get a StoreCostController for the given conglomerate.- Parameters:
conglomerateNumber- The conglomerate for which to get a StoreCostController.- Returns:
- The appropriate StoreCostController.
- Throws:
StandardException- Thrown on error
-
getSortCostController
SortCostController getSortCostController() throws StandardException
Get a SortCostController.- Throws:
StandardException- Thrown on error
-
setParameterList
void setParameterList(java.util.List<ParameterNode> parameterList)
Set the parameter list.- Parameters:
parameterList- The parameter list.
-
getParameterList
java.util.List<ParameterNode> getParameterList()
Get the parameter list.- Returns:
- The parameter list.
-
setReturnParameterFlag
void setReturnParameterFlag()
If callable statement uses ? = form
-
getReturnParameterFlag
boolean getReturnParameterFlag()
Is the callable statement uses ? for return parameter.- Returns:
- true if ? = call else false
-
getCursorInfo
java.lang.Object getCursorInfo()
Get the cursor info stored in the context.- Returns:
- the cursor info
-
setCursorInfo
void setCursorInfo(java.lang.Object cursorInfo)
Set params- Parameters:
cursorInfo- the cursor info
-
setScanIsolationLevel
void setScanIsolationLevel(int isolationLevel)
Set the isolation level for the scans in this query.- Parameters:
isolationLevel- The isolation level to use.
-
getScanIsolationLevel
int getScanIsolationLevel()
Get the isolation level for the scans in this query.- Returns:
- The isolation level for the scans in this query.
-
getNextEquivalenceClass
int getNextEquivalenceClass()
Get the next equivalence class for equijoin clauses.- Returns:
- The next equivalence class for equijoin clauses.
-
addWarning
void addWarning(java.sql.SQLWarning warning)
Add a compile time warning.
-
getWarnings
java.sql.SQLWarning getWarnings()
Get the chain of compile time warnings.
-
pushCurrentPrivType
void pushCurrentPrivType(int privType)
Sets the current privilege type context and pushes the previous on onto a stack. 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.- Parameters:
privType- One of the privilege types in org.apache.derby.iapi.sql.conn.Authorizer.
-
popCurrentPrivType
void popCurrentPrivType()
-
addRequiredColumnPriv
void addRequiredColumnPriv(ColumnDescriptor column)
Add a column privilege to the list of used column privileges.- Parameters:
column-
-
addRequiredTablePriv
void addRequiredTablePriv(TableDescriptor table)
Add a table or view privilege to the list of used table privileges.- Parameters:
table-
-
addRequiredSchemaPriv
void addRequiredSchemaPriv(java.lang.String schema, java.lang.String aid, int privType)Add a schema privilege to the list of used privileges.- Parameters:
schema- Schema name of the object that is being accessedaid- Requested authorizationId for new schemaprivType- CREATE_SCHEMA_PRIV, MODIFY_SCHEMA_PRIV or DROP_SCHEMA_PRIV
-
addRequiredRoutinePriv
void addRequiredRoutinePriv(AliasDescriptor routine)
Add a routine execute privilege to the list of used routine privileges.- Parameters:
routine-
-
addRequiredUsagePriv
void addRequiredUsagePriv(PrivilegedSQLObject usableObject)
Add a usage privilege to the list of required privileges.- Parameters:
usableObject-
-
addRequiredRolePriv
void addRequiredRolePriv(java.lang.String roleName, int privType)Add a required role privilege to the list of privileges.
-
getRequiredPermissionsList
java.util.List<StatementPermission> getRequiredPermissionsList()
- Returns:
- The list of required privileges.
-
addReferencedSequence
void addReferencedSequence(SequenceDescriptor sd)
Add a sequence descriptor to the list of referenced sequences.
-
isReferenced
boolean isReferenced(SequenceDescriptor sd)
Report whether the given sequence has been referenced already.
-
addPrivilegeFilter
void addPrivilegeFilter(VisitableFilter vf)
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.
-
removePrivilegeFilter
void removePrivilegeFilter(VisitableFilter vf)
Remove a filter for determining which QueryTreeNodes give rise to privilege checks at run time.
-
passesPrivilegeFilters
boolean passesPrivilegeFilters(Visitable visitable) throws StandardException
Return true if a QueryTreeNode passes all of the filters which determine whether the QueryTreeNode gives rise to run time privilege checks.- Throws:
StandardException
-
beginScope
void beginScope(java.lang.String scopeName)
Record that the compiler is entering a named scope. Increment the depth counter for that scope.
-
endScope
void endScope(java.lang.String scopeName)
Record that the compiler is exiting a named scope. Decrement the depth counter for that scope.
-
scopeDepth
int scopeDepth(java.lang.String scopeName)
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.
-
skipTypePrivileges
boolean skipTypePrivileges(boolean skip)
Set whether we should skip adding USAGE privileges for user-defined types. Returns the previous setting of this variable.
-
skippingTypePrivileges
boolean skippingTypePrivileges()
Return whether we are skipping USAGE privileges for user-defined types
-
-