📄 compilercontextimpl.java
字号:
/** @see CompilerContext#firstOnStack */ public void firstOnStack() { firstOnStack = true; } /** @see CompilerContext#isFirstOnStack */ public boolean isFirstOnStack() { return firstOnStack; } /** * Set the in use state for the compiler context. * * @param inUse The new inUse state for the compiler context. * * @return Nothing. * */ public void setInUse(boolean inUse) { this.inUse = inUse; /* ** Close the StoreCostControllers associated with this CompilerContext ** when the context is no longer in use. */ if ( ! inUse) { closeStoreCostControllers(); closeSortCostControllers(); } } /** * Return the in use state for the compiler context. * * @return boolean The in use state for the compiler context. */ public boolean getInUse() { return inUse; } /** * 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. * * @param reliability bitmask of types of query fragments to be forbidden * see the reliability bitmasks in CompilerContext.java * */ public void setReliability(int reliability) { this.reliability = reliability; } /** * Return the reliability requirements of this clause. See setReliability() * for a definition of clause reliability. * * @return a bitmask of which types of query fragments are to be forbidden */ public int getReliability() { return reliability; } /** * @see CompilerContext#getStoreCostController * * @exception StandardException Thrown on error */ public StoreCostController getStoreCostController(long conglomerateNumber, LanguageConnectionContext lcc) throws StandardException { /* ** Try to find the given conglomerate number in the array of ** conglom ids. */ for (int i = 0; i < storeCostConglomIds.size(); i++) { Long conglomId = (Long) storeCostConglomIds.elementAt(i); if (conglomId.longValue() == conglomerateNumber) return (StoreCostController) storeCostControllers.elementAt(i); } /* ** Not found, so get a StoreCostController from the store. */ StoreCostController retval = lcc.getTransactionCompile().openStoreCost(conglomerateNumber); /* Put it in the array */ storeCostControllers.insertElementAt(retval, storeCostControllers.size()); /* Put the conglomerate number in its array */ storeCostConglomIds.insertElementAt( new Long(conglomerateNumber), storeCostConglomIds.size()); return retval; } /** * */ private void closeStoreCostControllers() { for (int i = 0; i < storeCostControllers.size(); i++) { StoreCostController scc = (StoreCostController) storeCostControllers.elementAt(i); try { scc.close(); } catch (StandardException se) { } } storeCostControllers.removeAllElements(); storeCostConglomIds.removeAllElements(); } /** * @see CompilerContext#getSortCostController * * @exception StandardException Thrown on error */ public SortCostController getSortCostController() throws StandardException { /* ** Re-use a single SortCostController for each compilation */ if (sortCostController == null) { /* ** Get a StoreCostController from the store. */ LanguageConnectionContext lcc; /* Find the LanguageConnectionContext */ lcc = (LanguageConnectionContext) getContextManager().getContext(LanguageConnectionContext.CONTEXT_ID); sortCostController = lcc.getTransactionCompile().openSortCostController((Properties) null); } return sortCostController; } /** * * @exception StandardException Thrown on error */ private void closeSortCostControllers() { if (sortCostController != null) { sortCostController.close(); sortCostController = null; } } /** * 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. * * @return the compilation schema descirptor */ public SchemaDescriptor getCompilationSchema() { return compilationSchema; } /** * Set the compilation schema descriptor for this compilation context. * * @param the compilation schema * * @return the previous compilation schema descirptor */ public SchemaDescriptor setCompilationSchema(SchemaDescriptor newDefault) { SchemaDescriptor tmpSchema = compilationSchema; compilationSchema = newDefault; return tmpSchema; } /** * @see CompilerContext#setParameterList */ public void setParameterList(Vector parameterList) { this.parameterList = parameterList; /* Don't create param descriptors array if there are no params */ int numberOfParameters = (parameterList == null) ? 0 : parameterList.size(); if (numberOfParameters > 0) { parameterDescriptors = new DataTypeDescriptor[numberOfParameters]; } } /** * @see CompilerContext#getParameterList */ public Vector getParameterList() { return parameterList; } /** * @see CompilerContext#setReturnParameterFlag */ public void setReturnParameterFlag() { returnParameterFlag = true; } /** * @see CompilerContext#getReturnParameterFlag */ public boolean getReturnParameterFlag() { return returnParameterFlag; } /** * @see CompilerContext#getParameterTypes */ public DataTypeDescriptor[] getParameterTypes() { return parameterDescriptors; } /** * @see CompilerContext#getNextParameterNumber */ public int getNextParameterNumber() { if (SanityManager.DEBUG) { SanityManager.ASSERT(parameterList != null, "parameterList is expected to be non-null"); } // Parameter #s are 0-based return parameterList.size(); } /** * @see CompilerContext#setScanIsolationLevel */ public void setScanIsolationLevel(int isolationLevel) { scanIsolationLevel = isolationLevel; } /** * @see CompilerContext#getScanIsolationLevel */ public int getScanIsolationLevel() { return scanIsolationLevel; } /** * @see CompilerContext#setEntryIsolationLevel */ public void setEntryIsolationLevel(int isolationLevel) { this.entryIsolationLevel = isolationLevel; } /** * @see CompilerContext#getScanIsolationLevel */ public int getEntryIsolationLevel() { return entryIsolationLevel; } /** * @see CompilerContext#getTypeCompilerFactory */ public TypeCompilerFactory getTypeCompilerFactory() { return typeCompilerFactory; } /** Add a compile time warning. */ public void addWarning(SQLWarning warning) { if (warnings == null) warnings = warning; else warnings.setNextWarning(warning); } /** Get the chain of compile time warnings. */ public SQLWarning getWarnings() { return warnings; } ///////////////////////////////////////////////////////////////////////////////////// // // class interface // // this constructor is called with the parser // to be saved when the context // is created (when the first statement comes in, likely). // ///////////////////////////////////////////////////////////////////////////////////// public CompilerContextImpl(ContextManager cm, LanguageConnectionFactory lcf, TypeCompilerFactory typeCompilerFactory ) { super(cm, CompilerContext.CONTEXT_ID); this.parser = lcf.newParser(this); this.lcf = lcf; this.typeCompilerFactory = typeCompilerFactory; // the prefix for classes in this connection classPrefix = "ac"+lcf.getUUIDFactory().createUUID().toString().replace('-','x'); } /* ** Context state must be reset in restContext() */ private final Parser parser; private LanguageConnectionFactory lcf; private TypeCompilerFactory typeCompilerFactory; private Dependent currentDependent; private DependencyManager dmgr; private boolean firstOnStack; private boolean inUse; private int reliability = CompilerContext.SQL_LEGAL; private int nextColumnNumber = 1; private int nextTableNumber; private int nextSubqueryNumber; private int nextResultSetNumber; private int entryIsolationLevel; private int scanIsolationLevel; private int nextEquivalenceClass = -1; private long nextClassName; private Vector savedObjects; private String classPrefix; private ParameterValueSet params; private SchemaDescriptor compilationSchema; private ProviderList currentAPL; private boolean returnParameterFlag; private Vector storeCostControllers = new Vector(); private Vector storeCostConglomIds = new Vector(); private SortCostController sortCostController; private Vector parameterList; /* Type descriptors for the ? parameters */ private DataTypeDescriptor[] parameterDescriptors; private Object cursorInfo; private SQLWarning warnings;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -