/*
Derby - Class org.apache.derby.iapi.sql.compile.CompilerContext
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to you under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package org.apache.derby.iapi.sql.compile;
import java.sql.SQLWarning;
import java.util.List;
import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.iapi.services.compiler.JavaFactory;
import org.apache.derby.iapi.services.context.Context;
import org.apache.derby.iapi.services.loader.ClassFactory;
import org.apache.derby.iapi.sql.depend.Dependent;
import org.apache.derby.iapi.sql.depend.Provider;
import org.apache.derby.iapi.sql.depend.ProviderList;
import org.apache.derby.iapi.sql.dictionary.AliasDescriptor;
import org.apache.derby.iapi.sql.dictionary.ColumnDescriptor;
import org.apache.derby.iapi.sql.dictionary.PrivilegedSQLObject;
import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
import org.apache.derby.iapi.sql.dictionary.SequenceDescriptor;
import org.apache.derby.iapi.sql.dictionary.StatementPermission;
import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
import org.apache.derby.iapi.store.access.SortCostController;
import org.apache.derby.iapi.store.access.StoreCostController;
import org.apache.derby.impl.sql.compile.ParameterNode;
/**
* 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
*/
public interface CompilerContext extends Context
{
/////////////////////////////////////////////////////////////////////////////////////
//
// CONSTANTS
//
/////////////////////////////////////////////////////////////////////////////////////
/**
* this is the ID we expect compiler contexts
* to be stored into a context manager under.
*/
String CONTEXT_ID = "CompilerContext";
// bit masks for query fragments which are potentially unreliable. these are used
// by setReliability() and checkReliability().
public static final int DATETIME_ILLEGAL = 0x00000001;
// NOTE: getCurrentConnection() is currently legal everywhere
public static final int CURRENT_CONNECTION_ILLEGAL = 0x00000002;
public static final int FUNCTION_CALL_ILLEGAL = 0x00000004;
public static final int UNNAMED_PARAMETER_ILLEGAL = 0x00000008;
public static final int DIAGNOSTICS_ILLEGAL = 0x00000010;
public static final int SUBQUERY_ILLEGAL = 0x00000020;
public static final int USER_ILLEGAL = 0x00000040;
public static final int COLUMN_REFERENCE_ILLEGAL = 0x00000080;
public static final int IGNORE_MISSING_CLASSES = 0x00000100;
public static final int SCHEMA_ILLEGAL = 0x00000200;
public static final int INTERNAL_SQL_ILLEGAL = 0x00000400;
/**
* Calling procedures that modify sql data from before triggers is illegal.
*
*/
public static final int MODIFIES_SQL_DATA_PROCEDURE_ILLEGAL = 0x00000800;
public static final int NON_DETERMINISTIC_ILLEGAL = 0x00001000;
public static final int SQL_IN_ROUTINES_ILLEGAL = 0x00002000;
public static final int NEXT_VALUE_FOR_ILLEGAL = 0x00004000;
/** Standard SQL is legal */
public static final int SQL_LEGAL = (INTERNAL_SQL_ILLEGAL);
/** Any SQL we support is legal */
public static final int INTERNAL_SQL_LEGAL = 0;
public static final int CHECK_CONSTRAINT = (
DATETIME_ILLEGAL |
UNNAMED_PARAMETER_ILLEGAL |
DIAGNOSTICS_ILLEGAL |
SUBQUERY_ILLEGAL |
USER_ILLEGAL |
SCHEMA_ILLEGAL |
INTERNAL_SQL_ILLEGAL |
NEXT_VALUE_FOR_ILLEGAL
);
public static final int DEFAULT_RESTRICTION = (
SUBQUERY_ILLEGAL |
UNNAMED_PARAMETER_ILLEGAL |
COLUMN_REFERENCE_ILLEGAL |
INTERNAL_SQL_ILLEGAL
);
public static final int GENERATION_CLAUSE_RESTRICTION = (
CHECK_CONSTRAINT |
NON_DETERMINISTIC_ILLEGAL |
SQL_IN_ROUTINES_ILLEGAL |
NEXT_VALUE_FOR_ILLEGAL
);
public static final int WHERE_CLAUSE_RESTRICTION = NEXT_VALUE_FOR_ILLEGAL;
public static final int HAVING_CLAUSE_RESTRICTION = NEXT_VALUE_FOR_ILLEGAL;
public static final int ON_CLAUSE_RESTRICTION = NEXT_VALUE_FOR_ILLEGAL;
public static final int AGGREGATE_RESTRICTION = NEXT_VALUE_FOR_ILLEGAL;
public static final int CONDITIONAL_RESTRICTION = NEXT_VALUE_FOR_ILLEGAL;
public static final int GROUP_BY_RESTRICTION = NEXT_VALUE_FOR_ILLEGAL;
public static final int CASE_OPERAND_RESTRICTION =
CONDITIONAL_RESTRICTION | NON_DETERMINISTIC_ILLEGAL |
MODIFIES_SQL_DATA_PROCEDURE_ILLEGAL;
public static final String WHERE_SCOPE = "whereScope";
/////////////////////////////////////////////////////////////////////////////////////
//
// BEHAVIOR
//
/////////////////////////////////////////////////////////////////////////////////////
/**
* Get the Parser from this CompilerContext.
* *
* @return The parser associated with this CompilerContext
*
*/
Parser getParser();
/**
* Get the OptimizerFactory from this CompilerContext.
*
* @return The OptimizerFactory associated with this CompilerContext
*
*/
OptimizerFactory getOptimizerFactory();
/**
* Get the TypeCompilerFactory from this CompilerContext.
*
* @return The TypeCompilerFactory associated with this CompilerContext
*
*/
TypeCompilerFactory getTypeCompilerFactory();
/**
Return the class factory to use in this compilation.
*/
ClassFactory getClassFactory();
/**
* Get the JavaFactory from this CompilerContext.
*
* @return The JavaFactory associated with this CompilerContext
*
*/
JavaFactory getJavaFactory();
/**
* Get the current next column number (for generated column names)
* from this CompilerContext.
*
* @return int The next column number for the current statement.
*
*/
int getNextColumnNumber();
/**
* Reset compiler context (as for instance, when we recycle a context for
* use by another compilation.
*/
void resetContext();
/**
* Get the current next table number from this CompilerContext.
*
* @return int The next table number for the current statement.
*
*/
int getNextTableNumber();
/**
* Get the number of tables in the current statement from this CompilerContext.
*
* @return int The number of tables in the current statement.
*
*/
int getNumTables();
/**
* Get the current next subquery number from this CompilerContext.
*
* @return int The next subquery number for the current statement.
*
*/
int getNextSubqueryNumber();
/**
* Get the number of subquerys in the current statement from this CompilerContext.
*
* @return int The number of subquerys in the current statement.
*
*/
int getNumSubquerys();
/**
* Get the current next ResultSet number from this CompilerContext.
*
* @return int The next ResultSet number for the current statement.
*
*/
int getNextResultSetNumber();
/**
* Reset the next ResultSet number from this CompilerContext.
*/
void resetNextResultSetNumber();
/**
* Get the number of Results in the current statement from this CompilerContext.
*
* @return The number of ResultSets in the current statement.
*
*/
int getNumResultSets();
/**
* Get a unique Class name from this CompilerContext.
* Ensures it is globally unique for this JVM.
*
* @return String A unique-enough class name.
*
*/
String getUniqueClassName();
/**
* 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.
*
* @param d The Dependent currently being compiled.
*
*/
void setCurrentDependent(Dependent d);
/**
* Get the current auxiliary provider list from this CompilerContext.
*
* @return The current AuxiliaryProviderList.
*
*/
ProviderList getCurrentAuxiliaryProviderList();
/**
* Set the current auxiliary provider list for this CompilerContext.
*
* @param apl The new current AuxiliaryProviderList.
*
*/
void setCurrentAuxiliaryProviderList(ProviderList apl);
/**
* Add a dependency for the current dependent.
*
* @param p The Provider of the dependency.
* @exception StandardException thrown on failure.
*
*/
void createDependency(Provider p) throws StandardException;
/**
* Add a dependency between two objects.
*
* @param d The Dependent object.
* @param p The Provider of the dependency.
* @exception StandardException thrown on failure.
*
*/
void createDependency(Dependent d, Provider p) throws StandardException;
/**
* 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>
*
* @param o object to add to the pool of saved objects
* @return the entry # for the object
*/
int addSavedObject(Object o);
/**
* Get the saved object pool (for putting into the prepared statement).
* This turns it into its storable form, an array of objects.
*
* @return the saved object pool.
*/
Object[] getSavedObjects();
/**
* Set the saved object pool (for putting into the prepared statement).
*
* @param objs The new saved objects
* @throws NullPointerException if {@code objs} is null
*/
void setSavedObjects(List
Ads help maintain this website.