org.apache.derby.iapi.sql.compile
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
static int AGGREGATE_RESTRICTION
           
static int CHECK_CONSTRAINT
           
static int COLUMN_REFERENCE_ILLEGAL
           
static int CONDITIONAL_RESTRICTION
           
static java.lang.String CONTEXT_ID
          this is the ID we expect compiler contexts to be stored into a context manager under.
static int CURRENT_CONNECTION_ILLEGAL
           
static int DATETIME_ILLEGAL
           
static int DEFAULT_RESTRICTION
           
static int DIAGNOSTICS_ILLEGAL
           
static int FUNCTION_CALL_ILLEGAL
           
static int GENERATION_CLAUSE_RESTRICTION
           
static int GROUP_BY_RESTRICTION
           
static int HAVING_CLAUSE_RESTRICTION
           
static int IGNORE_MISSING_CLASSES
           
static int INTERNAL_SQL_ILLEGAL
           
static int INTERNAL_SQL_LEGAL
          Any SQL we support is legal
static int MODIFIES_SQL_DATA_PROCEDURE_ILLEGAL
          Calling procedures that modify sql data from before triggers is illegal.
static int NEXT_VALUE_FOR_ILLEGAL
           
static int NON_DETERMINISTIC_ILLEGAL
           
static int ON_CLAUSE_RESTRICTION
           
static int SCHEMA_ILLEGAL
           
static int SQL_IN_ROUTINES_ILLEGAL
           
static int SQL_LEGAL
          Standard SQL is legal
static int SUBQUERY_ILLEGAL
           
static int UNNAMED_PARAMETER_ILLEGAL
           
static int USER_ILLEGAL
           
static int WHERE_CLAUSE_RESTRICTION
           
 
Method Summary
 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 of privileges.
 void addRequiredRoutinePriv(AliasDescriptor routine)
          Add a routine execute privilege to the list of used routine privileges.
 void addRequiredSchemaPriv(java.lang.String schema, java.lang.String aid, int privType)
          Add a schema privilege to the list of used 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 o)
          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 createDependency(Dependent d, Provider p)
          Add a dependency between two objects.
 void createDependency(Provider p)
          Add a dependency for the current dependent.
 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.
 NodeFactory getNodeFactory()
          Get the NodeFactory 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.
 java.util.Vector getParameterList()
          Get the parameter list.
 DataTypeDescriptor[] getParameterTypes()
          Get the array of DataTypeDescriptor representing the types of the ?
 Parser getParser()
          Get the Parser from this CompilerContext
 int getReliability()
          Return the reliability requirements of this clause.
 java.util.List 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.
 boolean isFirstOnStack()
          Is this the first CompilerContext on the stack?
 boolean isReferenced(SequenceDescriptor sd)
          Report whether the given sequence has been referenced already.
 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 and pushes the previous on onto a stack.
 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.
 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.Vector 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.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.
 
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
Method Detail

getParser

Parser getParser()
Get the Parser from this CompilerContext. *

Returns:
The parser associated with this CompilerContext

getNodeFactory

NodeFactory getNodeFactory()
Get the NodeFactory from this CompilerContext.

Returns:
The NodeFactory 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))
  <\pre>

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.lang.Object[] objs)
Set the saved object pool (for putting into the prepared statement).

Parameters:
objs - The new saved objects

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.Vector parameterList)
Set the parameter list.

Parameters:
parameterList - The parameter list.

getParameterList

java.util.Vector 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

getParameterTypes

DataTypeDescriptor[] getParameterTypes()
Get the array of DataTypeDescriptor representing the types of the ? parameters.

Returns:
The parameter descriptors

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 accessed
aid - Requested authorizationId for new schema
privType - 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.

See Also:
addRequiredRolePriv(java.lang.String, int)

getRequiredPermissionsList

java.util.List 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.


Built on Thu 2011-03-10 11:54:14+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.