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
    • 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 - if objs is 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
      • 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 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 -
      • 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