--- /dev/null
+/*\r
+\r
+ Derby - Class org.apache.derby.iapi.sql.compile.CompilerContext\r
+\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to you under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.iapi.sql.compile;\r
+\r
+import org.apache.derby.iapi.services.context.Context;\r
+import org.apache.derby.iapi.services.compiler.JavaFactory;\r
+import org.apache.derby.iapi.services.loader.ClassFactory;\r
+\r
+import org.apache.derby.iapi.error.StandardException;\r
+\r
+import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;\r
+\r
+import org.apache.derby.iapi.sql.ParameterValueSet;\r
+\r
+import org.apache.derby.iapi.sql.dictionary.AliasDescriptor;\r
+import org.apache.derby.iapi.sql.dictionary.ColumnDescriptor;\r
+import org.apache.derby.iapi.sql.dictionary.TableDescriptor;\r
+import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;\r
+\r
+import org.apache.derby.iapi.sql.depend.Dependent;\r
+import org.apache.derby.iapi.sql.depend.Provider;\r
+import org.apache.derby.iapi.sql.depend.ProviderList;\r
+\r
+import org.apache.derby.iapi.sql.compile.TypeCompilerFactory;\r
+\r
+import org.apache.derby.iapi.types.DataTypeDescriptor;\r
+\r
+import org.apache.derby.iapi.store.access.StoreCostController;\r
+import org.apache.derby.iapi.store.access.SortCostController;\r
+\r
+import java.util.List;\r
+import java.util.Vector;\r
+import java.sql.SQLWarning;\r
+\r
+/**\r
+ * CompilerContext stores the parser and type id factory to be used by\r
+ * the compiler. Stack compiler contexts when a new, local parser is needed\r
+ * (if calling the compiler recursively from within the compiler,\r
+ * for example).\r
+ * CompilerContext objects are private to a LanguageConnectionContext.\r
+ *\r
+ *\r
+ * History:\r
+ * 5/22/97 Moved getExternalInterfaceFactory() to LanguageConnectionContext\r
+ * because it had to be used at execution. - Jeff\r
+ */\r
+public interface CompilerContext extends Context\r
+{\r
+ /////////////////////////////////////////////////////////////////////////////////////\r
+ //\r
+ // CONSTANTS\r
+ //\r
+ /////////////////////////////////////////////////////////////////////////////////////\r
+\r
+ /**\r
+ * this is the ID we expect compiler contexts\r
+ * to be stored into a context manager under.\r
+ */\r
+ String CONTEXT_ID = "CompilerContext";\r
+\r
+ // bit masks for query fragments which are potentially unreliable. these are used\r
+ // by setReliability() and checkReliability().\r
+\r
+ public static final int DATETIME_ILLEGAL = 0x00000001; \r
+ // NOTE: getCurrentConnection() is currently legal everywhere\r
+ public static final int CURRENT_CONNECTION_ILLEGAL = 0x00000002; \r
+ public static final int FUNCTION_CALL_ILLEGAL = 0x00000004; \r
+ public static final int UNNAMED_PARAMETER_ILLEGAL = 0x00000008; \r
+ public static final int DIAGNOSTICS_ILLEGAL = 0x00000010; \r
+ public static final int SUBQUERY_ILLEGAL = 0x00000020; \r
+ public static final int USER_ILLEGAL = 0x00000040; \r
+ public static final int COLUMN_REFERENCE_ILLEGAL = 0x00000080;\r
+ public static final int IGNORE_MISSING_CLASSES = 0x00000100;\r
+ public static final int SCHEMA_ILLEGAL = 0x00000200;\r
+ public static final int INTERNAL_SQL_ILLEGAL = 0x00000400;\r
+ \r
+ /**\r
+ * Calling procedures that modify sql data from before triggers is illegal. \r
+ * \r
+ */\r
+ public static final int MODIFIES_SQL_DATA_PROCEDURE_ILLEGAL = 0x00000800;\r
+\r
+ /** Standard SQL is legal */\r
+ public static final int SQL_LEGAL = (INTERNAL_SQL_ILLEGAL);\r
+\r
+ /** Any SQL we support is legal */\r
+ public static final int INTERNAL_SQL_LEGAL = 0;\r
+\r
+ public static final int CHECK_CONSTRAINT = (\r
+ DATETIME_ILLEGAL |\r
+ UNNAMED_PARAMETER_ILLEGAL |\r
+ DIAGNOSTICS_ILLEGAL |\r
+ SUBQUERY_ILLEGAL |\r
+ USER_ILLEGAL |\r
+ SCHEMA_ILLEGAL |\r
+ INTERNAL_SQL_ILLEGAL\r
+ );\r
+\r
+ public static final int DEFAULT_RESTRICTION = (\r
+ SUBQUERY_ILLEGAL |\r
+ UNNAMED_PARAMETER_ILLEGAL |\r
+ COLUMN_REFERENCE_ILLEGAL |\r
+ INTERNAL_SQL_ILLEGAL\r
+ );\r
+\r
+\r
+ /////////////////////////////////////////////////////////////////////////////////////\r
+ //\r
+ // BEHAVIOR\r
+ //\r
+ /////////////////////////////////////////////////////////////////////////////////////\r
+\r
+ /**\r
+ * Get the Parser from this CompilerContext.\r
+ * *\r
+ * @return The parser associated with this CompilerContext\r
+ *\r
+ */\r
+\r
+ Parser getParser();\r
+\r
+ /**\r
+ * Get the NodeFactory from this CompilerContext.\r
+ *\r
+ * @return The NodeFactory associated with this CompilerContext\r
+ *\r
+ */\r
+\r
+ NodeFactory getNodeFactory();\r
+\r
+ /**\r
+ * Get the TypeCompilerFactory from this CompilerContext.\r
+ *\r
+ * @return The TypeCompilerFactory associated with this CompilerContext\r
+ *\r
+ */\r
+ TypeCompilerFactory getTypeCompilerFactory();\r
+\r
+ /**\r
+ Return the class factory to use in this compilation.\r
+ */\r
+ ClassFactory getClassFactory();\r
+\r
+ /**\r
+ * Get the JavaFactory from this CompilerContext.\r
+ *\r
+ * @return The JavaFactory associated with this CompilerContext\r
+ *\r
+ */\r
+\r
+ JavaFactory getJavaFactory();\r
+\r
+ /**\r
+ * Get the current next column number (for generated column names)\r
+ * from this CompilerContext.\r
+ *\r
+ * @return int The next column number for the current statement.\r
+ *\r
+ */\r
+\r
+ int getNextColumnNumber();\r
+\r
+ /**\r
+ * Reset compiler context (as for instance, when we recycle a context for\r
+ * use by another compilation.\r
+ */\r
+ void resetContext();\r
+\r
+ /**\r
+ * Get the current next table number from this CompilerContext.\r
+ *\r
+ * @return int The next table number for the current statement.\r
+ *\r
+ */\r
+\r
+ int getNextTableNumber();\r
+\r
+ /**\r
+ * Get the number of tables in the current statement from this CompilerContext.\r
+ *\r
+ * @return int The number of tables in the current statement.\r
+ *\r
+ */\r
+\r
+ int getNumTables();\r
+\r
+ /**\r
+ * Get the current next subquery number from this CompilerContext.\r
+ *\r
+ * @return int The next subquery number for the current statement.\r
+ *\r
+ */\r
+\r
+ int getNextSubqueryNumber();\r
+\r
+ /**\r
+ * Get the number of subquerys in the current statement from this CompilerContext.\r
+ *\r
+ * @return int The number of subquerys in the current statement.\r
+ *\r
+ */\r
+\r
+ int getNumSubquerys();\r
+\r
+ /**\r
+ * Get the current next ResultSet number from this CompilerContext.\r
+ *\r
+ * @return int The next ResultSet number for the current statement.\r
+ *\r
+ */\r
+\r
+ int getNextResultSetNumber();\r
+\r
+ /**\r
+ * Reset the next ResultSet number from this CompilerContext.\r
+ */\r
+\r
+ void resetNextResultSetNumber();\r
+\r
+ /**\r
+ * Get the number of Results in the current statement from this CompilerContext.\r
+ *\r
+ * @return The number of ResultSets in the current statement.\r
+ *\r
+ */\r
+\r
+ int getNumResultSets();\r
+\r
+ /**\r
+ * Get a unique Class name from this CompilerContext.\r
+ * Ensures it is globally unique for this JVM.\r
+ *\r
+ * @return String A unique-enough class name.\r
+ *\r
+ */\r
+\r
+ String getUniqueClassName();\r
+\r
+ /**\r
+ * Set the current dependent from this CompilerContext.\r
+ * This should be called at the start of a compile to\r
+ * register who has the dependencies needed for the compilation.\r
+ *\r
+ * @param d The Dependent currently being compiled.\r
+ *\r
+ */\r
+\r
+ void setCurrentDependent(Dependent d);\r
+\r
+ /**\r
+ * Get the current auxiliary provider list from this CompilerContext.\r
+ *\r
+ * @return The current AuxiliaryProviderList.\r
+ *\r
+ */\r
+\r
+ ProviderList getCurrentAuxiliaryProviderList();\r
+\r
+ /**\r
+ * Set the current auxiliary provider list for this CompilerContext.\r
+ *\r
+ * @param apl The new current AuxiliaryProviderList.\r
+ *\r
+ */\r
+\r
+ void setCurrentAuxiliaryProviderList(ProviderList apl);\r
+\r
+ /**\r
+ * Add a dependency for the current dependent.\r
+ *\r
+ * @param p The Provider of the dependency.\r
+ * @exception StandardException thrown on failure.\r
+ *\r
+ */\r
+ void createDependency(Provider p) throws StandardException;\r
+\r
+ /**\r
+ * Add a dependency between two objects.\r
+ *\r
+ * @param d The Dependent object.\r
+ * @param p The Provider of the dependency.\r
+ * @exception StandardException thrown on failure.\r
+ *\r
+ */\r
+ public void createDependency(Dependent d, Provider p) throws StandardException;\r
+\r
+ /**\r
+ * Add an object to the pool that is created at compile time\r
+ * and used at execution time. Use the integer to reference it\r
+ * in execution constructs. Execution code will have to generate:\r
+ * <pre>\r
+ * (#objectType) (this.getPreparedStatement().getSavedObject(#int))\r
+ * <\pre>\r
+ *\r
+ * @param o object to add to the pool of saved objects\r
+ * @return the entry # for the object\r
+ */\r
+ int addSavedObject(Object o);\r
+\r
+ /**\r
+ * Get the saved object pool (for putting into the prepared statement).\r
+ * This turns it into its storable form, an array of objects.\r
+ *\r
+ * @return the saved object pool.\r
+ */\r
+ Object[] getSavedObjects(); \r
+\r
+ /**\r
+ * Set the saved object pool (for putting into the prepared statement).\r
+ *\r
+ * @param objs The new saved objects\r
+ */\r
+ public void setSavedObjects(Object[] objs); \r
+\r
+ /**\r
+ * Set the in use state for the compiler context.\r
+ *\r
+ * @param inUse The new inUse state for the compiler context.\r
+ */\r
+ public void setInUse(boolean inUse);\r
+\r
+ /**\r
+ * Return the in use state for the compiler context.\r
+ *\r
+ * @return boolean The in use state for the compiler context.\r
+ */\r
+ public boolean getInUse();\r
+\r
+ /**\r
+ * Mark this CompilerContext as the first on the stack, so we can avoid\r
+ * continually popping and pushing a CompilerContext.\r
+ */\r
+ public void firstOnStack();\r
+\r
+ /**\r
+ * Is this the first CompilerContext on the stack?\r
+ */\r
+ public boolean isFirstOnStack();\r
+\r
+ /**\r
+ * Sets which kind of query fragments are NOT allowed. Basically,\r
+ * these are fragments which return unstable results. CHECK CONSTRAINTS\r
+ * and CREATE PUBLICATION want to forbid certain kinds of fragments.\r
+ *\r
+ * @param reliability bitmask of types of query fragments to be forbidden\r
+ * see the reliability bitmasks above\r
+ *\r
+ */\r
+ public void setReliability(int reliability);\r
+\r
+ /**\r
+ * Return the reliability requirements of this clause. See setReliability()\r
+ * for a definition of clause reliability.\r
+ *\r
+ * @return a bitmask of which types of query fragments are to be forbidden\r
+ */\r
+ public int getReliability();\r
+\r
+ /**\r
+ * Get the compilation schema descriptor for this compilation context.\r
+ Will be null if no default schema lookups have occured. Ie.\r
+ the statement is independent of the current schema.\r
+ * \r
+ * @return the compilation schema descirptor\r
+ */\r
+ public SchemaDescriptor getCompilationSchema();\r
+\r
+ /**\r
+ * Set the compilation schema descriptor for this compilation context.\r
+ *\r
+ * @param newDefault compilation schema\r
+ * \r
+ * @return the previous compilation schema descirptor\r
+ */\r
+ public SchemaDescriptor setCompilationSchema(SchemaDescriptor newDefault);\r
+\r
+ /**\r
+ * Get a StoreCostController for the given conglomerate.\r
+ *\r
+ * @param conglomerateNumber The conglomerate for which to get a\r
+ * StoreCostController.\r
+ *\r
+ * @return The appropriate StoreCostController.\r
+ *\r
+ * @exception StandardException Thrown on error\r
+ */\r
+ public StoreCostController getStoreCostController(long conglomerateNumber)\r
+ throws StandardException;\r
+\r
+ /**\r
+ * Get a SortCostController.\r
+ *\r
+ * @exception StandardException Thrown on error\r
+ */\r
+ public SortCostController getSortCostController() throws StandardException;\r
+\r
+ /**\r
+ * Set the parameter list.\r
+ *\r
+ * @param parameterList The parameter list.\r
+ */\r
+ public void setParameterList(Vector parameterList);\r
+\r
+ /**\r
+ * Get the parameter list.\r
+ *\r
+ * @return The parameter list.\r
+ */\r
+ public Vector getParameterList();\r
+\r
+ /**\r
+ * If callable statement uses ? = form\r
+ */\r
+ public void setReturnParameterFlag();\r
+\r
+ /**\r
+ * Is the callable statement uses ? for return parameter.\r
+ *\r
+ * @return true if ? = call else false\r
+ */\r
+ public boolean getReturnParameterFlag();\r
+\r
+ /**\r
+ * Get the array of DataTypeDescriptor representing the types of\r
+ * the ? parameters.\r
+ *\r
+ * @return The parameter descriptors\r
+ */\r
+\r
+ public DataTypeDescriptor[] getParameterTypes();\r
+\r
+ /**\r
+ * Get the cursor info stored in the context.\r
+ *\r
+ * @return the cursor info\r
+ */\r
+ public Object getCursorInfo();\r
+ \r
+ /**\r
+ * Set params\r
+ *\r
+ * @param cursorInfo the cursor info\r
+ */\r
+ public void setCursorInfo(Object cursorInfo);\r
+\r
+ /**\r
+ * Set the isolation level for the scans in this query.\r
+ *\r
+ * @param isolationLevel The isolation level to use.\r
+ */\r
+ public void setScanIsolationLevel(int isolationLevel);\r
+\r
+ /**\r
+ * Get the isolation level for the scans in this query.\r
+ *\r
+ * @return The isolation level for the scans in this query.\r
+ */\r
+ public int getScanIsolationLevel();\r
+\r
+ /**\r
+ * Set the isolation level on entry to this CC so that it can be restored on exit.\r
+ *\r
+ * @param isolationLevel The isolation level on entry.\r
+ */\r
+ public void setEntryIsolationLevel(int isolationLevel);\r
+\r
+ /**\r
+ * Get the entry isolation level from this CC.\r
+ *\r
+ * @return The entry isolation level.\r
+ */\r
+ public int getEntryIsolationLevel();\r
+\r
+ /**\r
+ * Get the next equivalence class for equijoin clauses.\r
+ *\r
+ * @return The next equivalence class for equijoin clauses.\r
+ */\r
+ public int getNextEquivalenceClass();\r
+\r
+ /**\r
+ Add a compile time warning.\r
+ */\r
+ public void addWarning(SQLWarning warning);\r
+\r
+ /**\r
+ Get the chain of compile time warnings.\r
+ */\r
+ public SQLWarning getWarnings();\r
+\r
+ /**\r
+ * Sets the current privilege type context and pushes the previous on onto a stack.\r
+ * Column and table nodes do not know how they are\r
+ * being used. Higher level nodes in the query tree do not know what is being\r
+ * referenced. Keeping the context allows the two to come together.\r
+ *\r
+ * @param privType One of the privilege types in \r
+ * org.apache.derby.iapi.sql.conn.Authorizer.\r
+ */\r
+ public void pushCurrentPrivType( int privType);\r
+ \r
+ public void popCurrentPrivType();\r
+ \r
+ /**\r
+ * Add a column privilege to the list of used column privileges.\r
+ *\r
+ * @param column\r
+ */\r
+ public void addRequiredColumnPriv( ColumnDescriptor column);\r
+\r
+ /**\r
+ * Add a table or view privilege to the list of used table privileges.\r
+ *\r
+ * @param table\r
+ */\r
+ public void addRequiredTablePriv( TableDescriptor table);\r
+\r
+ /**\r
+ * Add a schema privilege to the list of used privileges.\r
+ *\r
+ * @param schema Schema name of the object that is being accessed\r
+ * @param aid Requested authorizationId for new schema\r
+ * @param privType CREATE_SCHEMA_PRIV, MODIFY_SCHEMA_PRIV or DROP_SCHEMA_PRIV\r
+ */\r
+ public void addRequiredSchemaPriv(String schema, String aid, int privType);\r
+\r
+ /**\r
+ * Add a routine execute privilege to the list of used routine privileges.\r
+ *\r
+ * @param routine\r
+ */\r
+ public void addRequiredRoutinePriv( AliasDescriptor routine);\r
+\r
+ /**\r
+ * @return The list of required privileges.\r
+ */\r
+ public List getRequiredPermissionsList();\r
+}\r