Interface CompilerContext
- All Superinterfaces:
Context
- All Known Implementing Classes:
CompilerContextImpl
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
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final Stringthis is the ID we expect compiler contexts to be stored into a context manager under.static final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intAny SQL we support is legalstatic final intCalling procedures that modify sql data from before triggers is illegal.static final intstatic final intstatic final intstatic final intstatic final intstatic final intStandard SQL is legalstatic final intstatic final intstatic final intstatic final intstatic final String -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a filter for determining which QueryTreeNodes give rise to privilege checks at run time.voidAdd a sequence descriptor to the list of referenced sequences.voidAdd a column privilege to the list of used column privileges.voidaddRequiredRolePriv(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(String schema, String aid, int privType) Add a schema privilege to the list of used privileges.voidAdd 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.intAdd an object to the pool that is created at compile time and used at execution time.voidaddWarning(SQLWarning warning) Add a compile time warning.voidbeginScope(String scopeName) Record that the compiler is entering a named scope.voidAdd a dependency between two objects.voidAdd a dependency for the current dependent.voidRecord that the compiler is exiting a named scope.voidMark this CompilerContext as the first on the stack, so we can avoid continually popping and pushing a CompilerContext.Return the class factory to use in this compilation.Get the compilation schema descriptor for this compilation context.Get the current auxiliary provider list from this CompilerContext.Get the cursor info stored in the context.booleangetInUse()Return the in use state for the compiler context.Get the JavaFactory from this CompilerContext.intGet the current next column number (for generated column names) from this CompilerContext.intGet the next equivalence class for equijoin clauses.intGet the current next ResultSet number from this CompilerContext.intGet the current next subquery number from this CompilerContext.intGet the current next table number from this CompilerContext.intGet the number of Results in the current statement from this CompilerContext.intGet the number of subquerys in the current statement from this CompilerContext.intGet the number of tables in the current statement from this CompilerContext.Get the OptimizerFactory from this CompilerContext.Get the parameter list.Get the Parser from this CompilerContextintReturn the reliability requirements of this clause.booleanIs the callable statement uses ?Object[]Get the saved object pool (for putting into the prepared statement).intGet the isolation level for the scans in this query.Get a SortCostController.getStoreCostController(long conglomerateNumber) Get a StoreCostController for the given conglomerate.Get the TypeCompilerFactory from this CompilerContext.Get a unique Class name from this CompilerContext.Get the chain of compile time warnings.booleanIs this the first CompilerContext on the stack?booleanReport 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.voidPop the default schema to use when compiling.voidvoidPush a default schema to use when compiling.voidpushCurrentPrivType(int privType) Sets the current privilege type context and pushes the previous on onto a stack.voidRemove a filter for determining which QueryTreeNodes give rise to privilege checks at run time.voidReset compiler context (as for instance, when we recycle a context for use by another compilation.voidReset the next ResultSet number from this CompilerContext.intscopeDepth(String scopeName) Get the current depth for the named scope.setCompilationSchema(SchemaDescriptor newDefault) Set the compilation schema descriptor for this compilation context.voidSet the current auxiliary provider list for this CompilerContext.voidSet the current dependent from this CompilerContext.voidsetCursorInfo(Object cursorInfo) Set paramsvoidsetInUse(boolean inUse) Set the in use state for the compiler context.voidsetParameterList(List<ParameterNode> parameterList) Set the parameter list.voidsetReliability(int reliability) Sets which kind of query fragments are NOT allowed.voidIf callable statement uses ?voidsetSavedObjects(List<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.booleanReturn 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 Context
cleanupOnError, getContextManager, getIdName, isLastHandler, popMe, pushMe
-
Field Details
-
CONTEXT_ID
this is the ID we expect compiler contexts to be stored into a context manager under.- See Also:
-
DATETIME_ILLEGAL
static final int DATETIME_ILLEGAL- See Also:
-
CURRENT_CONNECTION_ILLEGAL
static final int CURRENT_CONNECTION_ILLEGAL- See Also:
-
FUNCTION_CALL_ILLEGAL
static final int FUNCTION_CALL_ILLEGAL- See Also:
-
UNNAMED_PARAMETER_ILLEGAL
static final int UNNAMED_PARAMETER_ILLEGAL- See Also:
-
DIAGNOSTICS_ILLEGAL
static final int DIAGNOSTICS_ILLEGAL- See Also:
-
SUBQUERY_ILLEGAL
static final int SUBQUERY_ILLEGAL- See Also:
-
USER_ILLEGAL
static final int USER_ILLEGAL- See Also:
-
COLUMN_REFERENCE_ILLEGAL
static final int COLUMN_REFERENCE_ILLEGAL- See Also:
-
IGNORE_MISSING_CLASSES
static final int IGNORE_MISSING_CLASSES- See Also:
-
SCHEMA_ILLEGAL
static final int SCHEMA_ILLEGAL- See Also:
-
INTERNAL_SQL_ILLEGAL
static final int INTERNAL_SQL_ILLEGAL- See Also:
-
MODIFIES_SQL_DATA_PROCEDURE_ILLEGAL
static final int MODIFIES_SQL_DATA_PROCEDURE_ILLEGALCalling procedures that modify sql data from before triggers is illegal.- See Also:
-
NON_DETERMINISTIC_ILLEGAL
static final int NON_DETERMINISTIC_ILLEGAL- See Also:
-
SQL_IN_ROUTINES_ILLEGAL
static final int SQL_IN_ROUTINES_ILLEGAL- See Also:
-
NEXT_VALUE_FOR_ILLEGAL
static final int NEXT_VALUE_FOR_ILLEGAL- See Also:
-
SQL_LEGAL
static final int SQL_LEGALStandard SQL is legal- See Also:
-
INTERNAL_SQL_LEGAL
static final int INTERNAL_SQL_LEGALAny SQL we support is legal- See Also:
-
CHECK_CONSTRAINT
static final int CHECK_CONSTRAINT- See Also:
-
DEFAULT_RESTRICTION
static final int DEFAULT_RESTRICTION- See Also:
-
GENERATION_CLAUSE_RESTRICTION
static final int GENERATION_CLAUSE_RESTRICTION- See Also:
-
WHERE_CLAUSE_RESTRICTION
static final int WHERE_CLAUSE_RESTRICTION- See Also:
-
HAVING_CLAUSE_RESTRICTION
static final int HAVING_CLAUSE_RESTRICTION- See Also:
-
ON_CLAUSE_RESTRICTION
static final int ON_CLAUSE_RESTRICTION- See Also:
-
AGGREGATE_RESTRICTION
static final int AGGREGATE_RESTRICTION- See Also:
-
CONDITIONAL_RESTRICTION
static final int CONDITIONAL_RESTRICTION- See Also:
-
GROUP_BY_RESTRICTION
static final int GROUP_BY_RESTRICTION- See Also:
-
CASE_OPERAND_RESTRICTION
static final int CASE_OPERAND_RESTRICTION- See Also:
-
WHERE_SCOPE
- See Also:
-
-
Method Details
-
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
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
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
Set the current auxiliary provider list for this CompilerContext.- Parameters:
apl- The new current AuxiliaryProviderList.
-
createDependency
Add a dependency for the current dependent.- Parameters:
p- The Provider of the dependency.- Throws:
StandardException- thrown on failure.
-
createDependency
Add a dependency between two objects.- Parameters:
d- The Dependent object.p- The Provider of the dependency.- Throws:
StandardException- thrown on failure.
-
addSavedObject
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
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
Set the saved object pool (for putting into the prepared statement).- Parameters:
objs- The new saved objects- Throws:
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
Set the compilation schema descriptor for this compilation context.- Parameters:
newDefault- compilation schema- Returns:
- the previous compilation schema descirptor
-
pushCompilationSchema
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
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
Get a SortCostController.- Throws:
StandardException- Thrown on error
-
setParameterList
Set the parameter list.- Parameters:
parameterList- The parameter list.
-
getParameterList
-
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
-
setCursorInfo
-
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
Add a compile time warning. -
getWarnings
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
Add a column privilege to the list of used column privileges.- Parameters:
column-
-
addRequiredTablePriv
Add a table or view privilege to the list of used table privileges.- Parameters:
table-
-
addRequiredSchemaPriv
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
Add a routine execute privilege to the list of used routine privileges.- Parameters:
routine-
-
addRequiredUsagePriv
Add a usage privilege to the list of required privileges.- Parameters:
usableObject-
-
addRequiredRolePriv
Add a required role privilege to the list of privileges.- See Also:
-
getRequiredPermissionsList
List<StatementPermission> getRequiredPermissionsList()- Returns:
- The list of required privileges.
-
addReferencedSequence
Add a sequence descriptor to the list of referenced sequences. -
isReferenced
Report whether the given sequence has been referenced already. -
addPrivilegeFilter
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
Remove a filter for determining which QueryTreeNodes give rise to privilege checks at run time. -
passesPrivilegeFilters
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
Record that the compiler is entering a named scope. Increment the depth counter for that scope. -
endScope
Record that the compiler is exiting a named scope. Decrement the depth counter for that scope. -
scopeDepth
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
-