📄 datadictionary.java
字号:
/* Derby - Class org.apache.derby.iapi.sql.dictionary.DataDictionary Copyright 1997, 2004 The Apache Software Foundation or its licensors, as applicable. Licensed 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.dictionary;import org.apache.derby.iapi.services.context.ContextManager;import org.apache.derby.iapi.sql.depend.DependencyManager;import org.apache.derby.iapi.sql.depend.Dependent;import org.apache.derby.iapi.sql.depend.Provider;import org.apache.derby.iapi.sql.PreparedStatement;import org.apache.derby.iapi.types.DataTypeDescriptor;import org.apache.derby.iapi.types.NumberDataValue;import org.apache.derby.iapi.types.DataValueFactory;import org.apache.derby.iapi.types.DataValueDescriptor;import org.apache.derby.iapi.sql.compile.CostEstimate;import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;import org.apache.derby.iapi.sql.execute.ExecutionFactory;import org.apache.derby.iapi.error.StandardException;import org.apache.derby.iapi.store.access.TransactionController;import org.apache.derby.iapi.types.RowLocation;import org.apache.derby.catalog.UUID;import org.apache.derby.iapi.services.uuid.UUIDFactory;import java.util.List;import java.util.Hashtable;import java.util.Properties;import java.util.Vector;/** * The DataDictionary interface is used with the data dictionary to get * descriptors for binding and compilation. Some descriptors (such as table * and column descriptors) are added to and deleted from the data dictionary * by other modules (like the object store). Other descriptors are added and * deleted by the language module itself (e.g. the language module adds and * deletes views, because views are too high-level for modules like the object * store to know about). * * @version 0.1 * @author Jeff Lichtman */public interface DataDictionary{ String MODULE = "org.apache.derby.iapi.sql.dictionary.DataDictionary"; /** Special version indicating the database must be upgraded to or created at the current engine level */ public static final int DD_VERSION_CURRENT = -1; /** Cloudscape 5.0 System Catalog version */ public static final int DD_VERSION_CS_5_0 = 80; /** Cloudscape 5.1 (Arwen) System Catalog version */ public static final int DD_VERSION_CS_5_1 = 90; /** Cloudscape 5.2 (Frodo) System Catalog version */ public static final int DD_VERSION_CS_5_2 = 100; /** Cloudscape 8.1 (Pre-Gandalf) System Catalog version */ public static final int DD_VERSION_CS_8_1 = 110; /** Cloudscape/Derby 10.0 (Gandalf) System Catalog version */ public static final int DD_VERSION_CS_10_0 = 120; /** Derby 10.1 System Catalog version */ public static final int DD_VERSION_DERBY_10_1 = 130; // general info public static final String DATABASE_ID = "derby.databaseID"; // version ids /** * DataDictionaryVersion property indicates the updgrade level of the system catalogs. * Stored as a database property. Set to an instance of DD_Version with * the major number one of the DataDictionary.DD_* values. */ public static final String CORE_DATA_DICTIONARY_VERSION = "DataDictionaryVersion"; /** * CreateDataDictionaryVersion property indicates the level of the system catalogs, * at the time of database creation. * Stored as a database property. Set to an instance of DD_Version. */ public static final String CREATE_DATA_DICTIONARY_VERSION = "CreateDataDictionaryVersion"; /** * derby.softDataDictionaryVersion property indicates the soft upgrade level of the system catalogs. * Soft upgrade will sometime make minor changes to the system catalogs that can be safely consumed by * earlier versions, such as correcting values. * Stored as a database property. Set to an instance of DD_Version. */ public static final String SOFT_DATA_DICTIONARY_VERSION = "derby.softDataDictionaryVersion"; public static final String PROPERTY_CONGLOMERATE_VERSION = "PropertyConglomerateVersion"; /* ** CORE TABLES */ /* NOTE - SYSCONGLOMERATES must be first, since that table must exist before * any other conglomerates can be created/added to the system. */ public static final int SYSCONGLOMERATES_CATALOG_NUM = 0; public static final int SYSTABLES_CATALOG_NUM = 1; public static final int SYSCOLUMNS_CATALOG_NUM = 2; public static final int SYSSCHEMAS_CATALOG_NUM = 3; /** * Catalog numbers for non core system catalogs. */ public static final int SYSCONSTRAINTS_CATALOG_NUM = 4; public static final int SYSKEYS_CATALOG_NUM = 5; public static final int SYSDEPENDS_CATALOG_NUM = 6; public static final int SYSALIASES_CATALOG_NUM = 7; public static final int SYSVIEWS_CATALOG_NUM = 8; public static final int SYSCHECKS_CATALOG_NUM = 9; public static final int SYSFOREIGNKEYS_CATALOG_NUM = 10; public static final int SYSSTATEMENTS_CATALOG_NUM = 11; public static final int SYSFILES_CATALOG_NUM = 12; public static final int SYSTRIGGERS_CATALOG_NUM = 13; public static final int SYSSTATISTICS_CATALOG_NUM = 14; public static final int SYSDUMMY1_CATALOG_NUM = 15; /* static finals for constraints * (Here because they are needed by parser, compilation and execution.) */ public static final int NOTNULL_CONSTRAINT = 1; public static final int PRIMARYKEY_CONSTRAINT = 2; public static final int UNIQUE_CONSTRAINT = 3; public static final int CHECK_CONSTRAINT = 4; public static final int DROP_CONSTRAINT = 5; public static final int FOREIGNKEY_CONSTRAINT = 6; /** Modes returned from startReading() */ public static final int COMPILE_ONLY_MODE = 0; public static final int DDL_MODE = 1; /** * Push a data dictionary context onto the * current context manager. * * @param nested true iff this is a nested data dictionary context. */ DataDictionaryContext pushDataDictionaryContext(ContextManager cm, boolean nested); /** * Clear all of the DataDictionary caches. * * @exception StandardException Standard Cloudscape error policy */ public void clearCaches() throws StandardException; /** * Inform this DataDictionary that we are about to start reading it. This * means using the various get methods in the DataDictionary. * Generally, this is done during query compilation. * * @param lcc The LanguageConnectionContext to use. * * @return The mode that the reader will use, to be passed to doneReading() * Either COMPILE_ONLY_MODE or DDL_MODE. * * @exception StandardException Thrown on error */ public int startReading(LanguageConnectionContext lcc) throws StandardException; /** * Inform this DataDictionary that we have finished reading it. This * typically happens at the end of compilation. * * @param mode The mode that was returned by startReading(). * @param lcc The LanguageConnectionContext to use. * * @exception StandardException Thrown on error */ public void doneReading(int mode, LanguageConnectionContext lcc) throws StandardException; /** * Inform this DataDictionary that we are about to start writing to it. * This means using the various add and drop methods in the DataDictionary. * Generally, this is done during execution of DDL. * * @param lcc The LanguageConnectionContext to use. * * @exception StandardException Thrown on error */ public void startWriting(LanguageConnectionContext lcc) throws StandardException; /** * Inform this DataDictionary that the transaction in which writes have * been done (or may have been done) has been committed or rolled back. * * @exception StandardException Thrown on error */ public void transactionFinished() throws StandardException; /** * Get the ExecutionFactory associated with this database. * * @return The ExecutionFactory */ public ExecutionFactory getExecutionFactory(); /** * Get the DataValueFactory associated with this database. * * @return The ExecutionFactory */ public DataValueFactory getDataValueFactory(); /** * Get a DataDescriptorGenerator, through which we can create * objects to be stored in the DataDictionary. * * @return A DataDescriptorGenerator * */ public DataDescriptorGenerator getDataDescriptorGenerator(); /** * Get the tabinfo of a system catalog. Paw through the tabinfo arrays looking for the tabinfo * corresponding to this table name. * * RESOLVE: This does not bother to fault in the TabInfo. It assumes it already * has been faulted in. This seems odd. * * @param tableName name of table to get the TabInfo for. * * @return tabinfo corresponding to tablename * * @exception StandardException Thrown on error */ public TabInfo getTabInfo( String tableName ) throws StandardException; /** * Get the descriptor for the named schema. Schema descriptors include authorization ids and schema ids. * SQL92 allows a schema to specify a default character set - we will * not support this. Will check default schema for a match * before scanning a system table. * * @param schemaName The name of the schema we're interested in. Must not be null. * @param tc TransactionController * * @param raiseError whether an exception should be thrown if the schema does not exist. * * @return The descriptor for the schema. Can be null (not found) if raiseError is false. * * @exception StandardException Thrown on error */ public SchemaDescriptor getSchemaDescriptor(String schemaName, TransactionController tc, boolean raiseError) throws StandardException; /** * Get the descriptor for the named schema. If the schemaId * parameter is NULL, it gets the descriptor for the current (default) * schema. Schema descriptors include authorization ids and schema ids. * SQL92 allows a schema to specify a default character set - we will * not support this. * * @param schemaId The id of the schema we're interested in. * If the name is NULL, get the descriptor for the * current schema. * * @param tc The transaction controller to us when scanning * SYSSCHEMAS * * @return The descriptor for the schema. * * @exception StandardException Thrown on failure */ public SchemaDescriptor getSchemaDescriptor(UUID schemaId, TransactionController tc) throws StandardException; /** * Get the descriptor for the system schema. Schema descriptors include * authorization ids and schema ids. * * SQL92 allows a schema to specify a default character set - we will * not support this. * * @return The descriptor for the schema. * * @exception StandardException Thrown on failure */ public SchemaDescriptor getSystemSchemaDescriptor( ) throws StandardException; /** * Get the descriptor for the SYSIBM schema. Schema descriptors include * authorization ids and schema ids. * * SQL92 allows a schema to specify a default character set - we will * not support this. * * @return The descriptor for the schema. * * @exception StandardException Thrown on failure */ public SchemaDescriptor getSysIBMSchemaDescriptor( ) throws StandardException; /** * Get the descriptor for the SYSCS_DIAG schema. Schema descriptors * include authorization ids and schema ids. * * SQL92 allows a schema to specify a default character set - we will * not support this. * * @return The descriptor for the schema. * * @exception StandardException Thrown on failure */ public SchemaDescriptor getSystemDiagSchemaDescriptor( ) throws StandardException; /** * Get the descriptor for the declared global temporary table schema which is always named "SESSION". * * SQL92 allows a schema to specify a default character set - we will * not support this. * * @return The descriptor for the schema. * * @exception StandardException Thrown on failure */ public SchemaDescriptor getDeclaredGlobalTemporaryTablesSchemaDescriptor() throws StandardException; /** * Determine whether a string is the name of the system schema. * * @param name * @return true or false * * @exception StandardException Thrown on failure */ public boolean isSystemSchemaName( String name) throws StandardException; /** * Drop the descriptor for a schema, given the schema's name * * @param schemaName The name of the schema to drop * @param tc Transaction Controller * * @exception StandardException Thrown on failure */ public void dropSchemaDescriptor(String schemaName, TransactionController tc) throws StandardException; /** * Indicate whether there is anything in the * particular schema. Checks for tables in the * the schema, on the assumption that there cannot * be any other objects in a schema w/o a table. * * @param schema descriptor * * @return true/false * * @exception StandardException on error */ public boolean isSchemaEmpty(SchemaDescriptor sd) throws StandardException; /** * Get the descriptor for the named table within the given schema.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -