org.apache.derby.impl.sql.catalog
Class DataDictionaryImpl

java.lang.Object
  extended byorg.apache.derby.impl.sql.catalog.DataDictionaryImpl
All Implemented Interfaces:
CacheableFactory, DataDictionary, ModuleControl, ModuleSupportable, java.security.PrivilegedAction

public class DataDictionaryImpl
extends java.lang.Object
implements DataDictionary, CacheableFactory, ModuleControl, ModuleSupportable, java.security.PrivilegedAction

This abstract class contains the common code for the "regular" and limited data dictionaries. The limited configuration puts an upper limit on the number of tables a user is allowed to create. This class provides the entire implementation of DataDictionary, and ModuleControl, except for the stop() method, which is to be provided by a non-abstract super-class. The reason for putting the stop() method in the super-class is to prevent someone from inadvertently changing this to a non-abstract class. This class is shipped with both the limited and non-limited configurations, and we don't want anyone to be able to cheat by booting this class instead of booting the super-class.


Field Summary
protected  AccessFactory af
           
protected  boolean booting
           
private  TransactionController bootingTC
           
(package private)  boolean builtinSchemasAreFromLCC
           
(package private)  ShExLockable cacheCoordinator
           
(package private)  int cacheMode
           
private  java.util.GregorianCalendar calendarForLastSystemSQLName
           
private static java.lang.String CFG_SYSCOLUMNS_ID
           
private static java.lang.String CFG_SYSCOLUMNS_INDEX1_ID
           
private static java.lang.String CFG_SYSCOLUMNS_INDEX2_ID
           
private static java.lang.String CFG_SYSCONGLOMERATES_ID
           
private static java.lang.String CFG_SYSCONGLOMERATES_INDEX1_ID
           
private static java.lang.String CFG_SYSCONGLOMERATES_INDEX2_ID
           
private static java.lang.String CFG_SYSCONGLOMERATES_INDEX3_ID
           
private static java.lang.String CFG_SYSSCHEMAS_ID
           
private static java.lang.String CFG_SYSSCHEMAS_INDEX1_ID
           
private static java.lang.String CFG_SYSSCHEMAS_INDEX2_ID
           
private static java.lang.String CFG_SYSTABLES_ID
           
private static java.lang.String CFG_SYSTABLES_INDEX1_ID
           
private static java.lang.String CFG_SYSTABLES_INDEX2_ID
           
protected  boolean convertIdToLower
           
private  TabInfo[] coreInfo
           
 DataDescriptorGenerator dataDescriptorGenerator
           
(package private)  int ddlUsers
           
protected  SchemaDescriptor declaredGlobalTemporaryTablesSchemaDesc
           
private  java.lang.String declaredGlobalTemporaryTablesSchemaName
           
private  DD_Version dictionaryVersion
          Dictionary version of the on-disk database
protected  DependencyManager dmgr
           
protected  DataValueFactory dvf
           
(package private)  int engineType
           
private  ExecutionFactory exFactory
           
 LockFactory lockFactory
           
(package private)  CacheManager nameTdCache
           
private  TabInfo[] noncoreInfo
           
private static java.lang.String[] nonCoreNames
           
private static int NUM_CORE
           
private static int NUM_NONCORE
           
(package private)  CacheManager OIDTdCache
           
(package private)  int readersInDDLMode
           
 boolean readOnlyUpgrade
          True if the database is read only and requires some form of upgrade, that makes the stored prepared statements invalid.
private  DD_Version softwareVersion
          Dictionary version of the currently running engine
private  java.util.Hashtable spsIdHash
           
private  CacheManager spsNameCache
           
private  java.lang.String spsSet
           
(package private)  java.util.Properties startupParameters
           
(package private)  int stmtCacheSize
           
private static int SYSCOLUMNS_CORE_NUM
           
private static int SYSCONGLOMERATES_CORE_NUM
           
protected  SchemaDescriptor sysIBMSchemaDesc
           
private  java.lang.String sysIBMSchemaName
           
private static int SYSSCHEMAS_CORE_NUM
           
private static int SYSTABLES_CORE_NUM
           
protected  SchemaDescriptor systemDiagSchemaDesc
           
private  java.lang.String systemDiagSchemaName
           
protected  SchemaDescriptor systemSchemaDesc
           
private  java.lang.String systemSchemaName
           
private static java.lang.String[] systemSchemaNames
          List of all "system" schemas This list should contain all schema's used by the system and are created when the database is created.
private  int systemSQLNameNumber
           
protected  SchemaDescriptor systemUtilSchemaDesc
           
private  java.lang.String systemUtilSchemaName
           
(package private)  int tdCacheSize
           
private  long timeForLastSystemSQLName
           
protected  UUIDFactory uuidFactory
           
 
Fields inherited from interface org.apache.derby.iapi.sql.dictionary.DataDictionary
CHECK_CONSTRAINT, COMPILE_ONLY_MODE, CORE_DATA_DICTIONARY_VERSION, CREATE_DATA_DICTIONARY_VERSION, DATABASE_ID, DD_VERSION_CS_10_0, DD_VERSION_CS_5_0, DD_VERSION_CS_5_1, DD_VERSION_CS_5_2, DD_VERSION_CS_8_1, DD_VERSION_CURRENT, DD_VERSION_DERBY_10_1, DDL_MODE, DROP_CONSTRAINT, FOREIGNKEY_CONSTRAINT, MODULE, NOTNULL_CONSTRAINT, PRIMARYKEY_CONSTRAINT, PROPERTY_CONGLOMERATE_VERSION, SOFT_DATA_DICTIONARY_VERSION, SYSALIASES_CATALOG_NUM, SYSCHECKS_CATALOG_NUM, SYSCOLUMNS_CATALOG_NUM, SYSCONGLOMERATES_CATALOG_NUM, SYSCONSTRAINTS_CATALOG_NUM, SYSDEPENDS_CATALOG_NUM, SYSDUMMY1_CATALOG_NUM, SYSFILES_CATALOG_NUM, SYSFOREIGNKEYS_CATALOG_NUM, SYSKEYS_CATALOG_NUM, SYSSCHEMAS_CATALOG_NUM, SYSSTATEMENTS_CATALOG_NUM, SYSSTATISTICS_CATALOG_NUM, SYSTABLES_CATALOG_NUM, SYSTRIGGERS_CATALOG_NUM, SYSVIEWS_CATALOG_NUM, UNIQUE_CONSTRAINT
 
Constructor Summary
DataDictionaryImpl()
           
 
Method Summary
 boolean activeConstraint(ConstraintDescriptor constraint)
          Reports whether an individual constraint must be enforced.
 void addConstraintDescriptor(ConstraintDescriptor descriptor, TransactionController tc)
          Adds the given ConstraintDescriptor to the data dictionary, associated with the given table and constraint type.
 void addDescriptor(TupleDescriptor td, TupleDescriptor parent, int catalogNumber, boolean duplicatesAllowed, TransactionController tc)
          Adds a descriptor to a system catalog identified by the catalogNumber.
 void addDescriptorArray(TupleDescriptor[] td, TupleDescriptor parent, int catalogNumber, boolean allowDuplicates, TransactionController tc)
          array version of addDescriptor.
private  void addDescriptorNow(TupleDescriptor td, TupleDescriptor parent, int catalogNumber, boolean duplicatesAllowed, TransactionController tc, boolean wait)
           
 void addSPSDescriptor(SPSDescriptor descriptor, TransactionController tc, boolean wait)
          Adds the given SPSDescriptor to the data dictionary, associated with the given table and constraint type.
private  void addSPSParams(SPSDescriptor spsd, TransactionController tc, boolean wait)
          Add a column in SYS.SYSCOLUMNS for each parameter in the parameter list.
private  void addSubKeyConstraint(KeyConstraintDescriptor descriptor, TransactionController tc)
          Add the matching row to syskeys when adding a unique or primary key constraint
(package private)  void addSYSCOLUMNSIndex2Property(TransactionController tc, long index2ConglomerateNumber)
           
private  SchemaDescriptor addSystemSchema(java.lang.String schema_name, java.lang.String schema_uuid, TransactionController tc)
          Add a system schema to the database.
private  void addSystemTableToDictionary(TabInfo ti, SchemaDescriptor sd, TransactionController tc, DataDescriptorGenerator ddg)
          Add the required entries to the data dictionary for a System table.
 void addTableDescriptorToOtherCache(TableDescriptor td, Cacheable c)
          Add a table descriptor to the "other" cache.
 void boot(boolean create, java.util.Properties startParams)
          Start-up method for this instance of the data dictionary.
private  ConglomerateDescriptor bootstrapOneIndex(SchemaDescriptor sd, TransactionController tc, DataDescriptorGenerator ddg, TabInfo ti, int indexNumber, long heapConglomerateNumber)
           
private  void bootStrapSystemIndexes(SchemaDescriptor sd, TransactionController tc, DataDescriptorGenerator ddg, TabInfo ti)
          Infrastructure work for indexes on catalogs.
 boolean canSupport(java.util.Properties startParams)
          Currently, all this routine does is check to see if the Replication property has been turned on for this database.
 boolean checkVersion(int requiredMajorVersion, java.lang.String feature)
          Check to see if a database has been upgraded to the required level in order to use a language feature.
 void clearCaches()
          Clear all of the DataDictionary caches.
private  void clearNoncoreTable(int nonCoreNum)
           
(package private)  void clearSPSPlans()
          Mark all SPS plans in the data dictionary invalid.
 RowLocation[] computeAutoincRowLocations(TransactionController tc, TableDescriptor td)
          returns an array of RowLocations corresponding to the autoincrement columns in the table.
private  RowLocation computeRowLocation(TransactionController tc, TableDescriptor td, java.lang.String columnName)
          Computes the RowLocation in SYSCOLUMNS for a particular autoincrement column.
(package private)  void create_10_1_system_procedures(TransactionController tc, UUID sysUtilUUID)
          Create system procedures added in version 10.1.
private  void create_SYSCS_procedures(TransactionController tc)
          Create system procedures Used to add the system procedures to the database when it is created.
protected  void create_SYSIBM_procedures(TransactionController tc)
          Create system procedures in SYSIBM Used to add the system procedures to the database when it is created.
private  long createConglomerate(java.lang.String name, TransactionController tc, ExecRow rowTemplate, java.util.Properties properties)
          Create a conglomerate for a system table
protected  void createDictionaryTables(java.util.Properties params, TransactionController tc, DataDescriptorGenerator ddg)
          Create all the required dictionary tables.
private  void createSPSSet(TransactionController tc, boolean net, UUID schemaID)
          Create a set of stored prepared statements from a properties file.
private  void createSystemProcedureOrFunction(java.lang.String routine_name, UUID schema_uuid, java.lang.String[] arg_names, TypeDescriptor[] arg_types, int num_out_param, int num_result_sets, short routine_sql_control, TypeDescriptor return_type, TransactionController tc)
          Generic create procedure routine.
(package private)  void createSystemSps(TransactionController tc)
          Create system built-in metadata stored prepared statements.
private  void debugGenerateInfo(java.lang.StringBuffer strbuf, TransactionController tc, ConglomerateController heapCC, TabInfo ti, int indexId)
           
 void doneReading(int mode, LanguageConnectionContext lcc)
          Inform this DataDictionary that we have finished reading it.
 void dropAliasDescriptor(AliasDescriptor ad, TransactionController tc)
          Drop a AliasDescriptor from the DataDictionary
 void dropAllColumnDescriptors(UUID tableID, TransactionController tc)
          Drops all column descriptors from the given table.
 void dropAllConglomerateDescriptors(TableDescriptor td, TransactionController tc)
          Drops all conglomerates associated with a table.
 void dropAllConstraintDescriptors(TableDescriptor table, TransactionController tc)
          Drops all ConstraintDescriptors from the data dictionary that are associated with the given table,
 void dropColumnDescriptor(UUID tableID, java.lang.String columnName, TransactionController tc)
          Given a column name and a table ID, drops the column descriptor from the table.
private  void dropColumnDescriptorCore(TransactionController tc, ExecIndexRow keyRow)
          Delete the appropriate rows from syscolumns when dropping 1 or more columns.
 void dropConglomerateDescriptor(ConglomerateDescriptor conglomerate, TransactionController tc)
          Drops a conglomerate descriptor
 void dropConstraintDescriptor(TableDescriptor table, ConstraintDescriptor descriptor, TransactionController tc)
          Drops the given ConstraintDescriptor that is associated with the given table and constraint type from the data dictionary.
 void dropDependentsStoredDependencies(UUID dependentsUUID, TransactionController tc)
          Remove all of the stored dependencies for a given dependent's ID from the data dictionary.
 void dropFileInfoDescriptor(FileInfoDescriptor fid)
          Drop a FileDescriptor from the datadictionary.
 void dropSchemaDescriptor(java.lang.String schemaName, TransactionController tc)
          Drop the descriptor for a schema, given the schema's name
 void dropSPSDescriptor(SPSDescriptor descriptor, TransactionController tc)
          Drops the given SPSDescriptor.
 void dropSPSDescriptor(UUID uuid, TransactionController tc)
          Drops the given SPSDescriptor.
 void dropStatisticsDescriptors(UUID tableUUID, UUID referenceUUID, TransactionController tc)
          Drops all statistics descriptors for a given table/index column combination.
 void dropStoredDependency(DependencyDescriptor dd, TransactionController tc)
          Drop a single dependency from the data dictionary.
private  void dropSubCheckConstraint(UUID constraintId, TransactionController tc)
          Drop the matching row from syschecks when dropping a check constraint.
private  void dropSubKeyConstraint(ConstraintDescriptor constraint, TransactionController tc)
          Drop the matching row from syskeys when dropping a primary key or unique constraint.
 void dropTableDescriptor(TableDescriptor td, SchemaDescriptor schema, TransactionController tc)
          Drop the table descriptor.
 void dropTriggerDescriptor(TriggerDescriptor descriptor, TransactionController tc)
          Drops the given TriggerDescriptor.
 void dropViewDescriptor(ViewDescriptor vd, TransactionController tc)
          Drops the view descriptor from the data dictionary.
private  StandardException duplicateDescriptorException(TupleDescriptor tuple, TupleDescriptor parent)
           
 void faultInTabInfo(TabInfo ti)
          Finishes building a TabInfo if it hasn't already been faulted in.
private  TableDescriptor finishTableDescriptor(TableDescriptor td)
          Finish filling in the TableDescriptor.
 ConstraintDescriptorList getActiveConstraintDescriptors(ConstraintDescriptorList cdl)
          Convert a constraint descriptor list into a list of active constraints, that is, constraints which must be enforced.
 AliasDescriptor getAliasDescriptor(java.lang.String schemaId, java.lang.String aliasName, char nameSpace)
          Get a AliasDescriptor by alias name and name space.
 AliasDescriptor getAliasDescriptor(UUID uuid)
          Get a AliasDescriptor given its UUID.
private  ConstraintDescriptorList getAllConstraintDescriptors()
          Get every constraint in this database.
 java.util.List getAllDependencyDescriptorsList()
          Build and return an List with DependencyDescriptors for all of the stored dependencies.
 java.util.List getAllSPSDescriptors()
          Get every statement in this database.
private  GenericDescriptorList getAllTriggerDescriptors()
          Get every trigger in this database.
private  long getBootParameter(java.util.Properties startParams, java.lang.String key, boolean required)
           
private  void getBuiltinSchemaNames()
           
private  void getBuiltinSchemas()
           
 int getCacheMode()
          Returns the cache mode of the data dictionary.
 ColumnDescriptor getColumnDescriptorByDefaultId(UUID uuid)
          Get a ColumnDescriptor given its Default ID.
private  void getColumnDescriptorsScan(TableDescriptor td)
          Populate the ColumnDescriptorList for the specified TableDescriptor.
private  void getColumnDescriptorsScan(UUID uuid, ColumnDescriptorList cdl, TupleDescriptor td)
          Populate the ColumnDescriptorList for the specified TableDescriptor.
 ConglomerateDescriptor getConglomerateDescriptor(long conglomerateNumber)
          Get a ConglomerateDescriptor given its conglomerate number.
 ConglomerateDescriptor getConglomerateDescriptor(java.lang.String indexName, SchemaDescriptor sd, boolean forUpdate)
          Gets a conglomerate descriptor for the named index in the given schema, getting an exclusive row lock on the matching row in sys.sysconglomerates (for DDL concurrency) if requested.
 ConglomerateDescriptor getConglomerateDescriptor(UUID uuid)
          Get a ConglomerateDescriptor given its UUID.
 ConglomerateDescriptor[] getConglomerateDescriptors(long conglomerateNumber)
          Get an array of conglomerate descriptors for the given conglomerate number.
 ConglomerateDescriptor[] getConglomerateDescriptors(UUID uuid)
          Get an array of ConglomerateDescriptors given the UUID.
private  void getConglomerateDescriptorsScan(TableDescriptor td)
          Populate the ConglomerateDescriptorList for the specified TableDescriptor by scanning sysconglomerates.
 ConstraintDescriptor getConstraintDescriptor(java.lang.String constraintName, UUID schemaID)
          Get a ConstraintDescriptor given its name and schema ID.
 ConstraintDescriptor getConstraintDescriptor(TableDescriptor td, UUID uuid)
          Get the constraint descriptor given a table and the UUID String of the backing index.
 ConstraintDescriptor getConstraintDescriptor(UUID uuid)
          Get a ConstraintDescriptor given its UUID.
 ConstraintDescriptor getConstraintDescriptorById(TableDescriptor td, UUID uuid)
          Get the constraint descriptor given a table and the UUID String of the constraint
 ConstraintDescriptor getConstraintDescriptorByName(TableDescriptor td, SchemaDescriptor sd, java.lang.String constraintName, boolean forUpdate)
          Get the constraint descriptor given a TableDescriptor and the constraint name.
 ConstraintDescriptorList getConstraintDescriptors(TableDescriptor td)
          Load up the constraint descriptor list for this table descriptor and return it.
private  void getConstraintDescriptorsScan(TableDescriptor td, boolean forUpdate)
          Populate the ConstraintDescriptorList for the specified TableDescriptor.
protected  TupleDescriptor getConstraintDescriptorViaHeap(ScanQualifier[][] scanQualifiers, TabInfo ti, TupleDescriptor parentTupleDescriptor, java.util.List list)
          Return a (single or list of) catalog row descriptor(s) from SYSCONSTRAINTS through a heap scan
protected  ConstraintDescriptor getConstraintDescriptorViaIndex(int indexId, ExecIndexRow keyRow, TabInfo ti, TableDescriptor td, ConstraintDescriptorList dList, boolean forUpdate)
          Return a (single or list of) ConstraintDescriptor(s) from SYSCONSTRAINTS where the access is from the index to the heap.
 java.util.List getConstraints(UUID uuid, int indexId, int columnNum)
          Return an List which of the relevant column matching the indexed criteria.
 TableDescriptor getConstraintTableDescriptor(UUID constraintId)
          Return a table descriptor corresponding to the TABLEID field in SYSCONSTRAINTS where CONSTRAINTID matches the constraintId passsed in.
 TabInfo getCoreCatalog(int coreNum)
          Get core catalog info.
 DataDescriptorGenerator getDataDescriptorGenerator()
          Get a DataDescriptorGenerator, through which we can create objects to be stored in the DataDictionary.
 DataValueFactory getDataValueFactory()
          Get a DataValueFactory, through which we can create data value objects.
 SchemaDescriptor getDeclaredGlobalTemporaryTablesSchemaDescriptor()
          Get the descriptor for the declared global temporary table schema which is always named "SESSION".
 DependencyManager getDependencyManager()
          returns the dependencymanager associated with this datadictionary.
 java.util.List getDependentsDescriptorList(java.lang.String dependentID)
          Gets a list of the dependency descriptors for the given dependent's id.
protected  TupleDescriptor getDescriptorViaHeap(ScanQualifier[][] scanQualifiers, TabInfo ti, TupleDescriptor parentTupleDescriptor, java.util.List list)
          Return a (single or list of) catalog row descriptor(s) from a system table where the access a heap scan
private  TupleDescriptor getDescriptorViaIndex(int indexId, ExecIndexRow keyRow, ScanQualifier[][] scanQualifiers, TabInfo ti, TupleDescriptor parentTupleDescriptor, java.util.List list, boolean forUpdate)
          Return a (single or list of) catalog row descriptor(s) from a system table where the access is from the index to the heap.
 int getEngineType()
           
 ExecutionFactory getExecutionFactory()
          Get ExecutionFactory associated with this database.
 FileInfoDescriptor getFileInfoDescriptor(SchemaDescriptor sd, java.lang.String name)
          Get a FileInfoDescriptor given its SQL name and schema name.
 FileInfoDescriptor getFileInfoDescriptor(UUID id)
          Get a FileInfoDescriptor given its id.
private  FileInfoDescriptor getFileInfoDescriptorIndex1Scan(UUID schemaId, java.lang.String name)
          Scan sysfiles_index1 (schemaid,name) for a match.
private  FileInfoDescriptor getFileInfoDescriptorIndex2Scan(UUID id)
          Scan sysfiles_index2 (id) for a match.
 ConstraintDescriptorList getForeignKeys(UUID constraintId)
          Return a list of foreign keys constraints referencing this constraint.
static ExecIndexRow getIndexRowFromHeapRow(IndexRowGenerator irg, RowLocation rl, ExecRow heapRow)
          Get an index row based on a row from the heap.
private static LanguageConnectionContext getLCC()
           
private  TabInfo getNonCoreTI(int catalogNumber)
          Get a TabInfo for a non-core table.
protected  TabInfo getNonCoreTIByNumber(int catalogNumber)
          returns the tabinfo for a non core system catalog.
 java.util.List getProvidersDescriptorList(java.lang.String providerID)
          Gets a list of the dependency descriptors for the given provider's id.
private  java.util.Properties getQueryDescriptions(boolean net)
           
 java.util.List getRoutineList(java.lang.String schemaID, java.lang.String routineName, char nameSpace)
          Get the list of routines matching the schema and routine name.
 RowLocation getRowLocationTemplate(LanguageConnectionContext lcc, TableDescriptor td)
           
 SchemaDescriptor getSchemaDescriptor(java.lang.String schemaName, TransactionController tc, boolean raiseError)
          Get the descriptor for the named schema.
 SchemaDescriptor getSchemaDescriptor(UUID schemaId, TransactionController tc)
          Get the descriptor for the named schema.
 NumberDataValue getSetAutoincrementValue(RowLocation rl, TransactionController tc, boolean doUpdate, NumberDataValue newValue, boolean wait)
          getSetAutoincrementValue fetches the autoincrement value from SYSCOLUMNS given a row location.
 SPSDescriptor getSPSDescriptor(java.lang.String stmtName, SchemaDescriptor sd)
          Get a SPSDescriptor given its name.
 SPSDescriptor getSPSDescriptor(UUID uuid)
          Get a SPSDescriptor given its UUID.
private  SPSDescriptor getSPSDescriptorIndex1Scan(java.lang.String stmtName, java.lang.String schemaUUID)
          Scan sysschemas_index1 (stmtname, schemaid) for a match.
private  SPSDescriptor getSPSDescriptorIndex2Scan(java.lang.String stmtUUID)
          Scan sysstatements_index2 (stmtid) for a match.
 DataTypeDescriptor[] getSPSParams(SPSDescriptor spsd, java.util.Vector defaults)
          Get all the parameter descriptors for an SPS.
 java.util.List getStatisticsDescriptors(TableDescriptor td)
          get all the statistiscs descriptors for a given table.
private  SubCheckConstraintDescriptor getSubCheckConstraint(UUID constraintId)
          Get a SubCheckConstraintDescriptor from syschecks for the specified constraint id.
 SubKeyConstraintDescriptor getSubKeyConstraint(UUID constraintId, int type)
          Get a SubKeyConstraintDescriptor from syskeys or sysforeignkeys for the specified constraint id.
 long getSYSCOLUMNSHeapConglomerateNumber()
          Get the heap conglomerate number for SYS.SYSCOLUMNS.
 SchemaDescriptor getSysIBMSchemaDescriptor()
          Get the descriptor for the SYSIBM schema.
 SchemaDescriptor getSystemDiagSchemaDescriptor()
          Get the descriptor for the SYSCS_DIAG system schema.
 SchemaDescriptor getSystemSchemaDescriptor()
          Get the descriptor for the system schema.
 java.lang.String getSystemSQLName()
          Returns a unique system generated name of the form SQLyymmddhhmmssxxn yy - year, mm - month, dd - day of month, hh - hour, mm - minute, ss - second, xx - the first 2 digits of millisec because we don't have enough space to keep the exact millisec value, n - number between 0-9 The number at the end is to handle more than one system generated name request came at the same time.
 SchemaDescriptor getSystemUtilSchemaDescriptor()
          Get the descriptor for the SYSCS_UTIL system schema.
 TabInfo getTabInfo(java.lang.String tableName)
          Get the tabinfo of a system catalog.
 TableDescriptor getTableDescriptor(java.lang.String tableName, SchemaDescriptor schema)
          Get the descriptor for the named table within the given schema.
 TableDescriptor getTableDescriptor(UUID tableID)
          Get the descriptor for the table with the given UUID.
private  TableDescriptor getTableDescriptorIndex1Scan(java.lang.String tableName, java.lang.String schemaUUID)
          Scan systables_index1 (tablename, schemaid) for a match.
private  TableDescriptor getTableDescriptorIndex2Scan(java.lang.String tableUUID)
          Scan systables_index2 (tableid) for a match.
 TransactionController getTransactionCompile()
          Get the TransactionController to use, when not passed in as a parameter.
 TransactionController getTransactionExecute()
          Get the TransactionController to use, when not passed in as a parameter.
 TriggerDescriptor getTriggerDescriptor(java.lang.String name, SchemaDescriptor sd)
          Get the stored prepared statement descriptor given a sps name.
 TriggerDescriptor getTriggerDescriptor(UUID uuid)
          Get a TriggerDescriptor given its UUID.
 GenericDescriptorList getTriggerDescriptors(TableDescriptor td)
          Load up the trigger descriptor list for this table descriptor and return it.
private  void getTriggerDescriptorsScan(TableDescriptor td, boolean forUpdate)
          Populate the GenericDescriptorList for the specified TableDescriptor.
 SPSDescriptor getUncachedSPSDescriptor(TableKey stmtKey)
          This method can get called from the DataDictionary cache.
protected  SPSDescriptor getUncachedSPSDescriptor(UUID stmtId)
          This method can get called from the DataDictionary cache.
(package private)  TableDescriptor getUncachedTableDescriptor(TableKey tableKey)
          This method can get called from the DataDictionary cache.
protected  TableDescriptor getUncachedTableDescriptor(UUID tableID)
          This method can get called from the DataDictionary cache.
 UUIDFactory getUUIDFactory()
          Get the UUID Factory.
private  UUID getUUIDForCoreTable(java.lang.String tableName, java.lang.String schemaUUID, TransactionController tc)
          Get the UUID for the specified system table.
 DataValueDescriptor getValueAsDVD(UUID uuid)
          Converts a UUID to an DataValueDescriptor.
 ViewDescriptor getViewDescriptor(TableDescriptor td)
          Gets the viewDescriptor for the view given the TableDescriptor.
 ViewDescriptor getViewDescriptor(UUID uuid)
          Gets the viewDescriptor for the view with the given UUID.
private  ViewDescriptor getViewDescriptorScan(TableDescriptor tdi)
          Get the information for the view from sys.sysviews.
 java.util.Hashtable hashAllConglomerateDescriptorsByNumber(TransactionController tc)
          Get all of the ConglomerateDescriptors in the database and hash them by conglomerate number.
 java.util.Hashtable hashAllTableDescriptorsByTableId(TransactionController tc)
          Get all of the TableDescriptors in the database and hash them by TableId This is useful as a performance optimization for the locking VTIs.
 void initializeCatalogInfo()
          Initialize catalog information.
private  void initializeCoreInfo()
          Initialized the core info array.
private  void initializeNoncoreInfo()
          Initialized the noncore info array.
 void initSystemIndexVariables(DataDescriptorGenerator ddg, TabInfo ti, int indexNumber)
           
protected  void initSystemIndexVariables(TabInfo ti)
           
 void invalidateAllSPSPlans()
          Invalidate all the stored plans in SYS.SYSSTATEMENTS.
 boolean isSchemaEmpty(SchemaDescriptor sd)
          Indicate whether there is anything in the particular schema.
protected  boolean isSchemaReferenced(TransactionController tc, TabInfo ti, int indexId, int indexCol, DataValueDescriptor schemaIdOrderable)
          Is the schema id referenced by the system table in question?
 boolean isSystemSchemaName(java.lang.String name)
          Determine whether a string is the name of the system schema.
 void loadCatalogs(DataDescriptorGenerator ddg, TabInfo[] catalogArray)
          Initialize indices for an array of catalogs
protected  void loadDictionaryTables(TransactionController tc, DataDescriptorGenerator ddg, java.util.Properties startParams)
          Initialize system catalogs.
private  SchemaDescriptor locateSchemaRow(java.lang.String schemaName, TransactionController tc)
          Get the target schema by searching for a matching row in SYSSCHEMAS by schema name.
private  SchemaDescriptor locateSchemaRow(UUID schemaId, TransactionController tc)
          Get the target schema by searching for a matching row in SYSSCHEMAS by schemaId.
 void makeCatalog(TabInfo ti, SchemaDescriptor sd, TransactionController tc)
          The dirty work of creating a catalog.
private  ColumnDescriptor makeColumnDescriptor(SystemColumn column, TableDescriptor td)
          Converts a SystemColumn to a ColumnDescriptor.
 Cacheable newCacheable(CacheManager cm)
           
private  SchemaDescriptor newDeclaredGlobalTemporaryTablesSchemaDesc(java.lang.String name)
           
private static java.util.List newSList()
           
private  SchemaDescriptor newSystemSchemaDesc(java.lang.String name, java.lang.String uuid)
           
protected  void populateSYSDUMMY1(TransactionController tc)
          Populate SYSDUMMY1 table with a single row.
 DataDictionaryContext pushDataDictionaryContext(ContextManager contextManager, boolean nested)
          Push a data dictionary context onto the current context manager.
 java.lang.Object run()
           
 void setAutoincrementValue(TransactionController tc, UUID tableUUID, java.lang.String columnName, long aiValue, boolean incrementNeeded)
          sets a new value in SYSCOLUMNS for a particular autoincrement column.
private  void setCacheMode(int newMode)
           
protected  void setDependencyManager()
          sets the dependencymanager associated with this dd. subclasses can override this to install their own funky dependency manager.
(package private)  void spsCacheEntryAdded(SPSDescriptor spsd)
          Add an entry to the hashtables for lookup from the cache.
(package private)  void spsCacheEntryRemoved(SPSDescriptor spsd)
           
 int startReading(LanguageConnectionContext lcc)
          Inform this DataDictionary that we are about to start reading it.
 void startWriting(LanguageConnectionContext lcc)
          Inform this DataDictionary that we are about to start writing to it.
 void stop()
          Stop this module.
 void transactionFinished()
          Inform this DataDictionary that the transaction in which writes have been done (or may have been done) has been committed or rolled back.
private static java.lang.String twoDigits(int val)
           
private  void updateColumnDescriptor(ColumnDescriptor cd, UUID formerUUID, java.lang.String formerName, int[] colsToSet, TransactionController tc, boolean wait)
          Update the column descriptor in question.
 void updateConglomerateDescriptor(ConglomerateDescriptor[] cds, long conglomerateNumber, TransactionController tc)
          Update the conglomerateNumber for an array of ConglomerateDescriptors.
 void updateConglomerateDescriptor(ConglomerateDescriptor cd, long conglomerateNumber, TransactionController tc)
          Update the conglomerateNumber for a ConglomerateDescriptor.
 void updateConstraintDescriptor(ConstraintDescriptor cd, UUID formerUUID, int[] colsToSet, TransactionController tc)
          Update the constraint descriptor in question.
 void updateLockGranularity(TableDescriptor td, SchemaDescriptor schema, char lockGranularity, TransactionController tc)
          Update the lockGranularity for the specified table.
 void updateSPS(SPSDescriptor spsd, TransactionController tc, boolean recompile, boolean updateParamDescriptors, boolean wait, boolean firstCompilation)
          Updates SYS.SYSSTATEMENTS with the info from the SPSD.
 void updateTriggerDescriptor(TriggerDescriptor triggerd, UUID formerUUID, int[] colsToSet, TransactionController tc)
          Update the trigger descriptor in question.
 void upgrade_addColumns(CatalogRowFactory rowFactory, int[] newColumnIDs, TransactionController tc)
          Upgrade an existing catalog by adding columns.
 void upgrade_addInvisibleColumns(CatalogRowFactory rowFactory, int[] newColumnIDs, TransactionController tc)
          Add invisible columns to an existing system catalog
(package private)  void upgrade_initSystemTableCols(TransactionController tc, boolean isCoreTable, int tableNum, FormatableBitSet columnsToUpdateSet, DataValueDescriptor[] replaceRow)
          Initialize noncore columns to fixed values
 long upgrade_makeOneIndex(TransactionController tc, TabInfo ti, int indexNumber, long heapConglomerateNumber)
          Code to add an index to a catalog during upgrade.
 void upgrade_setNullability(CatalogRowFactory rowFactory, int columnNumber, boolean nullability, TransactionController tc)
          Upgrade an existing catalog by setting the nullability
protected  void upgradeMakeCatalog(TransactionController tc, int catalogNumber)
          called by the upgrade code (dd_xena etc) to add a new system catalog.
private  void widenConglomerate(ExecRow templateRow, int[] newColumnIDs, long conglomID, TransactionController tc)
          Adds columns to the conglomerate underlying a system table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CFG_SYSTABLES_ID

private static final java.lang.String CFG_SYSTABLES_ID
See Also:
Constant Field Values

CFG_SYSTABLES_INDEX1_ID

private static final java.lang.String CFG_SYSTABLES_INDEX1_ID
See Also:
Constant Field Values

CFG_SYSTABLES_INDEX2_ID

private static final java.lang.String CFG_SYSTABLES_INDEX2_ID
See Also:
Constant Field Values

CFG_SYSCOLUMNS_ID

private static final java.lang.String CFG_SYSCOLUMNS_ID
See Also:
Constant Field Values

CFG_SYSCOLUMNS_INDEX1_ID

private static final java.lang.String CFG_SYSCOLUMNS_INDEX1_ID
See Also:
Constant Field Values

CFG_SYSCOLUMNS_INDEX2_ID

private static final java.lang.String CFG_SYSCOLUMNS_INDEX2_ID
See Also:
Constant Field Values

CFG_SYSCONGLOMERATES_ID

private static final java.lang.String CFG_SYSCONGLOMERATES_ID
See Also:
Constant Field Values

CFG_SYSCONGLOMERATES_INDEX1_ID

private static final java.lang.String CFG_SYSCONGLOMERATES_INDEX1_ID
See Also:
Constant Field Values

CFG_SYSCONGLOMERATES_INDEX2_ID

private static final java.lang.String CFG_SYSCONGLOMERATES_INDEX2_ID
See Also:
Constant Field Values

CFG_SYSCONGLOMERATES_INDEX3_ID

private static final java.lang.String CFG_SYSCONGLOMERATES_INDEX3_ID
See Also:
Constant Field Values

CFG_SYSSCHEMAS_ID

private static final java.lang.String CFG_SYSSCHEMAS_ID
See Also:
Constant Field Values

CFG_SYSSCHEMAS_INDEX1_ID

private static final java.lang.String CFG_SYSSCHEMAS_INDEX1_ID
See Also:
Constant Field Values

CFG_SYSSCHEMAS_INDEX2_ID

private static final java.lang.String CFG_SYSSCHEMAS_INDEX2_ID
See Also:
Constant Field Values

SYSCONGLOMERATES_CORE_NUM

private static final int SYSCONGLOMERATES_CORE_NUM
See Also:
Constant Field Values

SYSTABLES_CORE_NUM

private static final int SYSTABLES_CORE_NUM
See Also:
Constant Field Values

SYSCOLUMNS_CORE_NUM

private static final int SYSCOLUMNS_CORE_NUM
See Also:
Constant Field Values

SYSSCHEMAS_CORE_NUM

private static final int SYSSCHEMAS_CORE_NUM
See Also:
Constant Field Values

NUM_CORE

private static final int NUM_CORE
See Also:
Constant Field Values

coreInfo

private TabInfo[] coreInfo

systemSchemaDesc

protected SchemaDescriptor systemSchemaDesc

sysIBMSchemaDesc

protected SchemaDescriptor sysIBMSchemaDesc

declaredGlobalTemporaryTablesSchemaDesc

protected SchemaDescriptor declaredGlobalTemporaryTablesSchemaDesc

systemDiagSchemaDesc

protected SchemaDescriptor systemDiagSchemaDesc

systemUtilSchemaDesc

protected SchemaDescriptor systemUtilSchemaDesc

systemSchemaName

private java.lang.String systemSchemaName

systemDiagSchemaName

private java.lang.String systemDiagSchemaName

systemUtilSchemaName

private java.lang.String systemUtilSchemaName

sysIBMSchemaName

private java.lang.String sysIBMSchemaName

declaredGlobalTemporaryTablesSchemaName

private java.lang.String declaredGlobalTemporaryTablesSchemaName

builtinSchemasAreFromLCC

boolean builtinSchemasAreFromLCC

convertIdToLower

protected boolean convertIdToLower

NUM_NONCORE

private static final int NUM_NONCORE
See Also:
Constant Field Values

nonCoreNames

private static final java.lang.String[] nonCoreNames

systemSchemaNames

private static final java.lang.String[] systemSchemaNames
List of all "system" schemas

This list should contain all schema's used by the system and are created when the database is created. Users should not be able to create or drop these schema's and should not be able to create or drop objects in these schema's. This list is used by code that needs to check if a particular schema is a "system" schema.


dictionaryVersion

private DD_Version dictionaryVersion
Dictionary version of the on-disk database


softwareVersion

private DD_Version softwareVersion
Dictionary version of the currently running engine


noncoreInfo

private TabInfo[] noncoreInfo

dataDescriptorGenerator

public DataDescriptorGenerator dataDescriptorGenerator

dvf

protected DataValueFactory dvf

af

protected AccessFactory af

exFactory

private ExecutionFactory exFactory

uuidFactory

protected UUIDFactory uuidFactory

startupParameters

java.util.Properties startupParameters

engineType

int engineType

booting

protected boolean booting

bootingTC

private TransactionController bootingTC

dmgr

protected DependencyManager dmgr

OIDTdCache

CacheManager OIDTdCache

nameTdCache

CacheManager nameTdCache

spsNameCache

private CacheManager spsNameCache

spsIdHash

private java.util.Hashtable spsIdHash

tdCacheSize

int tdCacheSize

stmtCacheSize

int stmtCacheSize

cacheCoordinator

ShExLockable cacheCoordinator

lockFactory

public LockFactory lockFactory

cacheMode

volatile int cacheMode

ddlUsers

volatile int ddlUsers

readersInDDLMode

volatile int readersInDDLMode

readOnlyUpgrade

public boolean readOnlyUpgrade
True if the database is read only and requires some form of upgrade, that makes the stored prepared statements invalid. With this case the engine is running at a different version to the underlying stored database. This can happen in 5.1 if the database is read only and a different point release (later than 5.1.25?) to the one that created it, has been booted. (Beetle 5170).

In 5.2 and newer this will be the case if the engine booting the database is newer than the engine that created it.


systemSQLNameNumber

private int systemSQLNameNumber

calendarForLastSystemSQLName

private java.util.GregorianCalendar calendarForLastSystemSQLName

timeForLastSystemSQLName

private long timeForLastSystemSQLName

spsSet

private java.lang.String spsSet
Constructor Detail

DataDictionaryImpl

public DataDictionaryImpl()
Method Detail

canSupport

public boolean canSupport(java.util.Properties startParams)
Currently, all this routine does is check to see if the Replication property has been turned on for this database. If so, then this is not the NodeFactory that's wanted--so we return false. The NodeFactory that is wanted is our child class "RepNodeFactory".

Specified by:
canSupport in interface ModuleSupportable
Returns:
true if this database does not want Replication false otherwise

boot

public void boot(boolean create,
                 java.util.Properties startParams)
          throws StandardException
Start-up method for this instance of the data dictionary.

Specified by:
boot in interface ModuleControl
Parameters:
startParams - The start-up parameters
Returns:
Nothing
Throws:
StandardException - Thrown if the module fails to start
See Also:
Monitor, ModuleFactory

setDependencyManager

protected void setDependencyManager()
sets the dependencymanager associated with this dd. subclasses can override this to install their own funky dependency manager.


getDependencyManager

public DependencyManager getDependencyManager()
returns the dependencymanager associated with this datadictionary.

Specified by:
getDependencyManager in interface DataDictionary
See Also:
DataDictionary.getDependencyManager()

stop

public void stop()
Stop this module. In this case, nothing needs to be done.

Specified by:
stop in interface ModuleControl
Returns:
Nothing
See Also:
Monitor, ModuleFactory

newCacheable

public Cacheable newCacheable(CacheManager cm)
Specified by:
newCacheable in interface CacheableFactory

startReading

public int startReading(LanguageConnectionContext lcc)
                 throws StandardException
Description copied from interface: DataDictionary
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.

Specified by:
startReading in interface DataDictionary
Parameters:
lcc - The LanguageConnectionContext to use.
Returns:
The mode that the reader will use, to be passed to doneReading() Either COMPILE_ONLY_MODE or DDL_MODE.
Throws:
StandardException - Thrown on error
See Also:
DataDictionary.startReading(org.apache.derby.iapi.sql.conn.LanguageConnectionContext)

doneReading

public void doneReading(int mode,
                        LanguageConnectionContext lcc)
                 throws StandardException
Description copied from interface: DataDictionary
Inform this DataDictionary that we have finished reading it. This typically happens at the end of compilation.

Specified by:
doneReading in interface DataDictionary
Parameters:
mode - The mode that was returned by startReading().
lcc - The LanguageConnectionContext to use.
Throws:
StandardException - Thrown on error

startWriting

public void startWriting(LanguageConnectionContext lcc)
                  throws StandardException
Description copied from interface: DataDictionary
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.

Specified by:
startWriting in interface DataDictionary
Parameters:
lcc - The LanguageConnectionContext to use.
Throws:
StandardException - Thrown on error

transactionFinished

public void transactionFinished()
                         throws StandardException
Description copied from interface: DataDictionary
Inform this DataDictionary that the transaction in which writes have been done (or may have been done) has been committed or rolled back.

Specified by:
transactionFinished in interface DataDictionary
Throws:
StandardException - Thrown on error

getCacheMode

public int getCacheMode()
Description copied from interface: DataDictionary
Returns the cache mode of the data dictionary.

Specified by:
getCacheMode in interface DataDictionary

setCacheMode

private void setCacheMode(int newMode)

getDataDescriptorGenerator

public DataDescriptorGenerator getDataDescriptorGenerator()
Get a DataDescriptorGenerator, through which we can create objects to be stored in the DataDictionary.

Specified by:
getDataDescriptorGenerator in interface DataDictionary
Returns:
A DataDescriptorGenerator

getDataValueFactory

public DataValueFactory getDataValueFactory()
Get a DataValueFactory, through which we can create data value objects.

Specified by:
getDataValueFactory in interface DataDictionary
Returns:
A DataValueFactory

getExecutionFactory

public ExecutionFactory getExecutionFactory()
Get ExecutionFactory associated with this database.

Specified by:
getExecutionFactory in interface DataDictionary
Returns:
The ExecutionFactory

pushDataDictionaryContext

public DataDictionaryContext pushDataDictionaryContext(ContextManager contextManager,
                                                       boolean nested)
Description copied from interface: DataDictionary
Push a data dictionary context onto the current context manager.

Specified by:
pushDataDictionaryContext in interface DataDictionary
Parameters:
nested - true iff this is a nested data dictionary context.
See Also:
DataDictionary.pushDataDictionaryContext(org.apache.derby.iapi.services.context.ContextManager, boolean)

getBuiltinSchemaNames

private void getBuiltinSchemaNames()
                            throws StandardException
Throws:
StandardException

getBuiltinSchemas

private void getBuiltinSchemas()
                        throws StandardException
Throws:
StandardException

getSystemSchemaDescriptor

public SchemaDescriptor getSystemSchemaDescriptor()
                                           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.

Specified by:
getSystemSchemaDescriptor in interface DataDictionary
Returns:
The descriptor for the schema.
Throws:
StandardException - Thrown on failure

getSystemUtilSchemaDescriptor

public SchemaDescriptor getSystemUtilSchemaDescriptor()
                                               throws StandardException
Get the descriptor for the SYSCS_UTIL 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.

Returns:
The descriptor for the schema.
Throws:
StandardException - Thrown on failure

getSystemDiagSchemaDescriptor

public SchemaDescriptor getSystemDiagSchemaDescriptor()
                                               throws StandardException
Get the descriptor for the SYSCS_DIAG 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.

Specified by:
getSystemDiagSchemaDescriptor in interface DataDictionary
Returns:
The descriptor for the schema.
Throws:
StandardException - Thrown on failure

getSysIBMSchemaDescriptor

public SchemaDescriptor getSysIBMSchemaDescriptor()
                                           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.

Specified by:
getSysIBMSchemaDescriptor in interface DataDictionary
Returns:
The descriptor for the schema.
Throws:
StandardException - Thrown on failure

getDeclaredGlobalTemporaryTablesSchemaDescriptor

public SchemaDescriptor getDeclaredGlobalTemporaryTablesSchemaDescriptor()
                                                                  throws StandardException
Get the descriptor for the declared global temporary table schema which is always named "SESSION".

Specified by:
getDeclaredGlobalTemporaryTablesSchemaDescriptor in interface DataDictionary
Returns:
The descriptor for the schema.
Throws:
StandardException - Thrown on failure

isSystemSchemaName

public boolean isSystemSchemaName(java.lang.String name)
                           throws StandardException
Determine whether a string is the name of the system schema.

Specified by:
isSystemSchemaName in interface DataDictionary
Parameters:
name -
Returns:
true or false
Throws:
StandardException - Thrown on failure

getSchemaDescriptor

public SchemaDescriptor getSchemaDescriptor(java.lang.String schemaName,
                                            TransactionController tc,
                                            boolean raiseError)
                                     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.

Specified by:
getSchemaDescriptor in interface DataDictionary
Parameters:
schemaName - The name of the schema we're interested in. Must not be null.
tc - TransactionController
raiseError - whether an exception should be thrown if the schema does not exist.
Returns:
The descriptor for the schema. Can be null (not found) if raiseError is false.
Throws:
StandardException - Thrown on error

locateSchemaRow

private SchemaDescriptor locateSchemaRow(UUID schemaId,
                                         TransactionController tc)
                                  throws StandardException
Get the target schema by searching for a matching row in SYSSCHEMAS by schemaId. Read only scan.

Parameters:
schemaId - The id of the schema we're interested in. If non-null, overrides schemaName
tc - TransactionController. If null, one is gotten off of the language connection context.
Returns:
The row for the schema
Throws:
StandardException - Thrown on error

locateSchemaRow

private SchemaDescriptor locateSchemaRow(java.lang.String schemaName,
                                         TransactionController tc)
                                  throws StandardException
Get the target schema by searching for a matching row in SYSSCHEMAS by schema name. Read only scan.

Parameters:
schemaName - The name of the schema we're interested in. If schemaId is null, used to qual.
tc - TransactionController. If null, one is gotten off of the language connection context.
Returns:
The row for the schema
Throws:
StandardException - Thrown on error

getSchemaDescriptor

public SchemaDescriptor getSchemaDescriptor(UUID schemaId,
                                            TransactionController tc)
                                     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. Will check default schema for a match before scanning a system table.

Specified by:
getSchemaDescriptor in interface DataDictionary
Parameters:
schemaId - The id of the schema we're interested in. If the name is NULL, get the descriptor for the current schema.
tc - TransactionController
Returns:
The descriptor for the schema. Warning: <\I> may return NULL if schemaName is non-NULL and doesn't exist in SYSSCHEMAS
Throws:
StandardException - Thrown on error

addDescriptor

public void addDescriptor(TupleDescriptor td,
                          TupleDescriptor parent,
                          int catalogNumber,
                          boolean duplicatesAllowed,
                          TransactionController tc)
                   throws StandardException
Description copied from interface: DataDictionary
Adds a descriptor to a system catalog identified by the catalogNumber.

Specified by:
addDescriptor in interface DataDictionary
Parameters:
td - descriptor to insert.
parent - parent descriptor; e.g for a column parent is the tabledescriptor to which the descriptor is beign inserted. for most other objects it is the schema descriptor.
catalogNumber - a value which identifies the catalog into which the descriptor should be inserted. It is the users responsibility to ensure that the catalogNumber is consistent with the tuple being inserted.
duplicatesAllowed - whether an exception should be thrown if the insert results in a duplicate; if this parameter is FALSE then one of the following exception will be thrown; LANG_OBJECT_ALREADY_EXISTS (if parent is null) or LANG_OBJECT_ALREADY_EXISTS_IN_OBJECT (if parent is not null). The error message is created by getting the name and type of the tuple and parent.
tc - the transaction controller to use to do all of this.
Throws:
StandardException
See Also:
DataDictionary.addDescriptor(org.apache.derby.iapi.sql.dictionary.TupleDescriptor, org.apache.derby.iapi.sql.dictionary.TupleDescriptor, int, boolean, org.apache.derby.iapi.store.access.TransactionController)

addDescriptorNow

private void addDescriptorNow(TupleDescriptor td,
                              TupleDescriptor parent,
                              int catalogNumber,
                              boolean duplicatesAllowed,
                              TransactionController tc,
                              boolean wait)
                       throws StandardException
Throws:
StandardException

duplicateDescriptorException

private StandardException duplicateDescriptorException(TupleDescriptor tuple,
                                                       TupleDescriptor parent)

addDescriptorArray

public void addDescriptorArray(TupleDescriptor[] td,
                               TupleDescriptor parent,
                               int catalogNumber,
                               boolean allowDuplicates,
                               TransactionController tc)
                        throws StandardException
array version of addDescriptor.

Specified by:
addDescriptorArray in interface DataDictionary
Throws:
StandardException
See Also:
DataDictionary.addDescriptor(org.apache.derby.iapi.sql.dictionary.TupleDescriptor, org.apache.derby.iapi.sql.dictionary.TupleDescriptor, int, boolean, org.apache.derby.iapi.store.access.TransactionController)

dropSchemaDescriptor

public void dropSchemaDescriptor(java.lang.String schemaName,
                                 TransactionController tc)
                          throws StandardException
Drop the descriptor for a schema, given the schema's name

Specified by:
dropSchemaDescriptor in interface DataDictionary
Parameters:
schemaName - The name of the schema to drop
tc - TransactionController for the transaction
Returns:
Nothing
Throws:
StandardException - Thrown on error

getTableDescriptor

public TableDescriptor getTableDescriptor(java.lang.String tableName,
                                          SchemaDescriptor schema)
                                   throws StandardException
Get the descriptor for the named table within the given schema. If the schema parameter is NULL, it looks for the table in the current (default) schema. Table descriptors include object ids, object types (table, view, etc.)

Specified by:
getTableDescriptor in interface DataDictionary
Parameters:
tableName - The name of the table to get the descriptor for
schema - The descriptor for the schema the table lives in. If null, use the system schema.
Returns:
The descriptor for the table, null if table does not exist.
Throws:
StandardException - Thrown on failure

getTableDescriptorIndex1Scan

private TableDescriptor getTableDescriptorIndex1Scan(java.lang.String tableName,
                                                     java.lang.String schemaUUID)
                                              throws StandardException
Scan systables_index1 (tablename, schemaid) for a match.

Returns:
TableDescriptor The matching descriptor, if any.
Throws:
StandardException - Thrown on failure

getUncachedTableDescriptor

TableDescriptor getUncachedTableDescriptor(TableKey tableKey)
                                     throws StandardException
This method can get called from the DataDictionary cache.

Parameters:
tableKey - The TableKey of the table
Returns:
The descriptor for the table, null if the table does not exist.
Throws:
StandardException - Thrown on failure

getTableDescriptor

public TableDescriptor getTableDescriptor(UUID tableID)
                                   throws StandardException
Get the descriptor for the table with the given UUID. NOTE: I'm assuming that the object store will define an UUID for persistent objects. I'm also assuming that UUIDs are unique across schemas, and that the object store will be able to do efficient lookups across schemas (i.e. that no schema descriptor parameter is needed).

Specified by:
getTableDescriptor in interface DataDictionary
Parameters:
tableID - The UUID of the table to get the descriptor for
Returns:
The descriptor for the table, null if the table does not exist.
Throws:
StandardException - Thrown on failure

getUncachedTableDescriptor

protected TableDescriptor getUncachedTableDescriptor(UUID tableID)
                                              throws StandardException
This method can get called from the DataDictionary cache.

Parameters:
tableID - The UUID of the table to get the descriptor for
Returns:
The descriptor for the table, null if the table does not exist.
Throws:
StandardException - Thrown on failure

getTableDescriptorIndex2Scan

private TableDescriptor getTableDescriptorIndex2Scan(java.lang.String tableUUID)
                                              throws StandardException
Scan systables_index2 (tableid) for a match.

Returns:
TableDescriptor The matching descriptor, if any.
Throws:
StandardException - Thrown on failure

finishTableDescriptor

private TableDescriptor finishTableDescriptor(TableDescriptor td)
                                       throws StandardException
Finish filling in the TableDescriptor. (Build the various lists that hang off the TD.)

Parameters:
td - The TableDescriptor.
Returns:
The completed TableDescriptor.
Throws:
StandardException - Thrown on failure

isSchemaEmpty

public boolean isSchemaEmpty(SchemaDescriptor sd)
                      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.

Specified by:
isSchemaEmpty in interface DataDictionary
Returns:
true/false
Throws:
StandardException - on error

isSchemaReferenced

protected boolean isSchemaReferenced(TransactionController tc,
                                     TabInfo ti,
                                     int indexId,
                                     int indexCol,
                                     DataValueDescriptor schemaIdOrderable)
                              throws StandardException
Is the schema id referenced by the system table in question? Currently assumes that the schema id is in an index. NOTE: could be generalized a bit, and possibly used elsewhere...

Parameters:
tc - transaction controller
ti - table info for the system table
indexId - index id
indexCol - 1 based index column
schemaIdOrderable - the schemaid in a char orderable
Returns:
true if there is a reference to this schema
Throws:
StandardException - on error

dropTableDescriptor

public void dropTableDescriptor(TableDescriptor td,
                                SchemaDescriptor schema,
                                TransactionController tc)
                         throws StandardException
Drop the table descriptor.

Specified by:
dropTableDescriptor in interface DataDictionary
Parameters:
schema - A descriptor for the schema the table is a part of. If this parameter is NULL, then the table is part of the current (default) schema
tc - TransactionController for the transaction
Returns:
Nothing
Throws:
StandardException - Thrown on error

updateLockGranularity

public void updateLockGranularity(TableDescriptor td,
                                  SchemaDescriptor schema,
                                  char lockGranularity,
                                  TransactionController tc)
                           throws StandardException
Update the lockGranularity for the specified table.

Specified by:
updateLockGranularity in interface DataDictionary
Parameters:
td - The TableDescriptor for the table
schema - The SchemaDescriptor for the table
lockGranularity - The new lockGranularity
tc - The TransactionController to use.
Returns:
Nothing.
Throws:
StandardException - Thrown on error

getColumnDescriptorByDefaultId

public ColumnDescriptor getColumnDescriptorByDefaultId(UUID uuid)
                                                throws StandardException
Get a ColumnDescriptor given its Default ID.

Specified by:
getColumnDescriptorByDefaultId in interface DataDictionary
Parameters:
uuid - The UUID of the default
Returns:
The ColumnDescriptor for the column.
Throws:
StandardException - Thrown on failure

getColumnDescriptorsScan

private void getColumnDescriptorsScan(TableDescriptor td)
                               throws StandardException
Populate the ColumnDescriptorList for the specified TableDescriptor. MT synchronization: it is assumed that the caller has synchronized on the CDL in the given TD.

Parameters:
td - The TableDescriptor.
Returns:
Nothing.
Throws:
StandardException - Thrown on failure

getColumnDescriptorsScan

private void getColumnDescriptorsScan(UUID uuid,
                                      ColumnDescriptorList cdl,
                                      TupleDescriptor td)
                               throws StandardException
Populate the ColumnDescriptorList for the specified TableDescriptor. MT synchronization: it is assumed that the caller has synchronized on the CDL in the given TD.

Parameters:
uuid - The referencing UUID
td - The parent tuple descriptor
Returns:
Nothing.
Throws:
StandardException - Thrown on failure

dropColumnDescriptor

public void dropColumnDescriptor(UUID tableID,
                                 java.lang.String columnName,
                                 TransactionController tc)
                          throws StandardException
Given a column name and a table ID, drops the column descriptor from the table.

Specified by:
dropColumnDescriptor in interface DataDictionary
Parameters:
tableID - The UUID of the table to drop the column from
columnName - The name of the column to drop
tc - TransactionController for the transaction
Returns:
Nothing
Throws:
StandardException - Thrown on error

dropAllColumnDescriptors

public void dropAllColumnDescriptors(UUID tableID,
                                     TransactionController tc)
                              throws StandardException
Drops all column descriptors from the given table. Useful for DROP TABLE.

Specified by:
dropAllColumnDescriptors in interface DataDictionary
Parameters:
tableID - The UUID of the table from which to drop all the column descriptors
tc - TransactionController for the transaction
Returns:
Nothing
Throws:
StandardException - Thrown on error

dropColumnDescriptorCore

private void dropColumnDescriptorCore(TransactionController tc,
                                      ExecIndexRow keyRow)
                               throws StandardException
Delete the appropriate rows from syscolumns when dropping 1 or more columns.

Parameters:
tc - The TransactionController
keyRow - Start/stop position.
Returns:
Nothing.
Throws:
StandardException - Thrown on failure

updateColumnDescriptor

private void updateColumnDescriptor(ColumnDescriptor cd,
                                    UUID formerUUID,
                                    java.lang.String formerName,
                                    int[] colsToSet,
                                    TransactionController tc,
                                    boolean wait)
                             throws StandardException
Update the column descriptor in question. Updates every row in the base conglomerate.

Parameters:
cd - The ColumnDescriptor
formerUUID - The UUID for this column in SYSCOLUMNS, may differ from what is in cd if this is the column that is being set.
formerName - The name for this column in SYSCOLUMNS may differ from what is in cd if this is the column that is being set.
colsToSet - Array of ints of columns to be modified, 1 based. May be null (all cols).
tc - The TransactionController to use
wait - If true, then the caller wants to wait for locks. False will be when we using a nested user xaction - we want to timeout right away if the parent holds the lock. (bug 4821)
Returns:
Nothing.
Throws:
StandardException - Thrown on failure

getViewDescriptor

public ViewDescriptor getViewDescriptor(UUID uuid)
                                 throws StandardException
Gets the viewDescriptor for the view with the given UUID.

Specified by:
getViewDescriptor in interface DataDictionary
Parameters:
uuid - The UUID for the view
Returns:
A descriptor for the view
Throws:
StandardException - Thrown on error

getViewDescriptor

public ViewDescriptor getViewDescriptor(TableDescriptor td)
                                 throws StandardException
Gets the viewDescriptor for the view given the TableDescriptor.

Specified by:
getViewDescriptor in interface DataDictionary
Parameters:
td - The TableDescriptor for the view.
Returns:
A descriptor for the view
Throws:
StandardException - Thrown on error

getViewDescriptorScan

private ViewDescriptor getViewDescriptorScan(TableDescriptor tdi)
                                      throws StandardException
Get the information for the view from sys.sysviews.

Parameters:
tdi - The TableDescriptor for the view.
Returns:
ViewDescriptor The ViewDescriptor for the view.
Throws:
StandardException - Thrown on error

dropViewDescriptor

public void dropViewDescriptor(ViewDescriptor vd,
                               TransactionController tc)
                        throws StandardException
Drops the view descriptor from the data dictionary.

Specified by:
dropViewDescriptor in interface DataDictionary
Parameters:
vd - A descriptor for the view to be dropped
tc - TransactionController to use
Returns:
Nothing
Throws:
StandardException - Thrown on error

getFileInfoDescriptorIndex2Scan

private FileInfoDescriptor getFileInfoDescriptorIndex2Scan(UUID id)
                                                    throws StandardException
Scan sysfiles_index2 (id) for a match.

Returns:
TableDescriptor The matching descriptor, or null.
Throws:
StandardException - Thrown on failure

getFileInfoDescriptor

public FileInfoDescriptor getFileInfoDescriptor(UUID id)
                                         throws StandardException
Description copied from interface: DataDictionary
Get a FileInfoDescriptor given its id.

Specified by:
getFileInfoDescriptor in interface DataDictionary
Parameters:
id - The descriptor's id.
Throws:
StandardException - Thrown on failure
See Also:
DataDictionary.getFileInfoDescriptor(org.apache.derby.catalog.UUID)

getFileInfoDescriptorIndex1Scan

private FileInfoDescriptor getFileInfoDescriptorIndex1Scan(UUID schemaId,
                                                           java.lang.String name)
                                                    throws StandardException
Scan sysfiles_index1 (schemaid,name) for a match.

Returns:
The matching descriptor or null.
Throws:
StandardException - Thrown on failure

getFileInfoDescriptor

public FileInfoDescriptor getFileInfoDescriptor(SchemaDescriptor sd,
                                                java.lang.String name)
                                         throws StandardException
Description copied from interface: DataDictionary
Get a FileInfoDescriptor given its SQL name and schema name.

Specified by:
getFileInfoDescriptor in interface DataDictionary
Parameters:
sd - the schema that holds the FileInfoDescriptor.
Throws:
StandardException - Thrown on failure
See Also:
DataDictionary.getFileInfoDescriptor(org.apache.derby.catalog.UUID)

dropFileInfoDescriptor

public void dropFileInfoDescriptor(FileInfoDescriptor fid)
                            throws StandardException
Description copied from interface: DataDictionary
Drop a FileDescriptor from the datadictionary.

Specified by:
dropFileInfoDescriptor in interface DataDictionary
Throws:
StandardException - Thrown on error
See Also:
DataDictionary.dropFileInfoDescriptor(org.apache.derby.iapi.sql.dictionary.FileInfoDescriptor)

getSPSDescriptor

public SPSDescriptor getSPSDescriptor(UUID uuid)
                               throws StandardException
Get a SPSDescriptor given its UUID.

Specified by:
getSPSDescriptor in interface DataDictionary
Parameters:
uuid - The UUID
Returns:
The SPSDescriptor for the constraint.
Throws:
StandardException - Thrown on failure

spsCacheEntryAdded

void spsCacheEntryAdded(SPSDescriptor spsd)
Add an entry to the hashtables for lookup from the cache.


spsCacheEntryRemoved

void spsCacheEntryRemoved(SPSDescriptor spsd)

getUncachedSPSDescriptor

public SPSDescriptor getUncachedSPSDescriptor(TableKey stmtKey)
                                       throws StandardException
This method can get called from the DataDictionary cache.

Parameters:
stmtKey - The TableKey of the sps
Returns:
The descriptor for the sps, null if the sps does not exist.
Throws:
StandardException - Thrown on failure

getUncachedSPSDescriptor

protected SPSDescriptor getUncachedSPSDescriptor(UUID stmtId)
                                          throws StandardException
This method can get called from the DataDictionary cache.

Parameters:
stmtId - The UUID of the stmt to get the descriptor for
Returns:
The descriptor for the stmt, null if the table does not exist.
Throws:
StandardException - Thrown on failure

getSPSDescriptorIndex2Scan

private SPSDescriptor getSPSDescriptorIndex2Scan(java.lang.String stmtUUID)
                                          throws StandardException
Scan sysstatements_index2 (stmtid) for a match. Note that we do not do a lookup of parameter info.

Returns:
SPSDescriptor The matching descriptor, if any.
Throws:
StandardException - Thrown on failure

getSPSDescriptor

public SPSDescriptor getSPSDescriptor(java.lang.String stmtName,
                                      SchemaDescriptor sd)
                               throws StandardException
Get a SPSDescriptor given its name. Currently no cacheing. With caching we need to be very careful about invalidation. No caching means invalidations block on existing SPSD instances (since they were read in

Specified by:
getSPSDescriptor in interface DataDictionary
Parameters:
stmtName - the statement name
sd - The SchemaDescriptor
Returns:
The SPSDescriptor for the constraint.
Throws:
StandardException - Thrown on failure

getSPSDescriptorIndex1Scan

private SPSDescriptor getSPSDescriptorIndex1Scan(java.lang.String stmtName,
                                                 java.lang.String schemaUUID)
                                          throws StandardException
Scan sysschemas_index1 (stmtname, schemaid) for a match.

Returns:
SPSDescriptor The matching descriptor, if any.
Throws:
StandardException - Thrown on failure

addSPSDescriptor

public void addSPSDescriptor(SPSDescriptor descriptor,
                             TransactionController tc,
                             boolean wait)
                      throws StandardException
Adds the given SPSDescriptor to the data dictionary, associated with the given table and constraint type.

Specified by:
addSPSDescriptor in interface DataDictionary
Parameters:
descriptor - The descriptor to add
tc - The transaction controller
wait - To wait for lock or not
Returns:
Nothing
Throws:
StandardException - Thrown on error

addSPSParams

private void addSPSParams(SPSDescriptor spsd,
                          TransactionController tc,
                          boolean wait)
                   throws StandardException
Add a column in SYS.SYSCOLUMNS for each parameter in the parameter list.

Throws:
StandardException

getSPSParams

public DataTypeDescriptor[] getSPSParams(SPSDescriptor spsd,
                                         java.util.Vector defaults)
                                  throws StandardException
Get all the parameter descriptors for an SPS. Look up the params in SYSCOLUMNS and turn them into parameter descriptors.

Specified by:
getSPSParams in interface DataDictionary
Parameters:
spsd - sps descriptor
defaults - vector for storing column defaults
Returns:
array of data type descriptors
Throws:
StandardException - Thrown on error

updateSPS

public void updateSPS(SPSDescriptor spsd,
                      TransactionController tc,
                      boolean recompile,
                      boolean updateParamDescriptors,
                      boolean wait,
                      boolean firstCompilation)
               throws StandardException
Updates SYS.SYSSTATEMENTS with the info from the SPSD.

Specified by:
updateSPS in interface DataDictionary
Parameters:
tc - The transaction controller
updateParamDescriptors - If true, will update the parameter descriptors in SYS.SYSCOLUMNS.
wait - If true, then the caller wants to wait for locks. False will be
firstCompilation - true, if Statement is getting compiled for first time and SPS was created with NOCOMPILE option. when we using a nested user xaction - we want to timeout right away if the parent holds the lock. (bug 4821)
recompile - whether to recompile or invalidate
Returns:
Nothing
Throws:
StandardException - Thrown on error

invalidateAllSPSPlans

public void invalidateAllSPSPlans()
                           throws StandardException
Description copied from interface: DataDictionary
Invalidate all the stored plans in SYS.SYSSTATEMENTS.

Specified by:
invalidateAllSPSPlans in interface DataDictionary
Throws:
StandardException - Thrown on error
See Also:
DataDictionary.invalidateAllSPSPlans()

clearSPSPlans

void clearSPSPlans()
             throws StandardException
Mark all SPS plans in the data dictionary invalid. This does not invalidate cached plans. This function is for use by the boot-up code.

Throws:
StandardException - Thrown on error

dropSPSDescriptor

public void dropSPSDescriptor(SPSDescriptor descriptor,
                              TransactionController tc)
                       throws StandardException
Drops the given SPSDescriptor.

Specified by:
dropSPSDescriptor in interface DataDictionary
Parameters:
descriptor - The descriptor to drop
tc - The TransactionController.
Throws:
StandardException - Thrown on failure

dropSPSDescriptor

public void dropSPSDescriptor(UUID uuid,
                              TransactionController tc)
                       throws StandardException
Drops the given SPSDescriptor.

Specified by:
dropSPSDescriptor in interface DataDictionary
Parameters:
uuid - the statement uuid
tc - The TransactionController.
Throws:
StandardException - Thrown on failure

getAllSPSDescriptors

public java.util.List getAllSPSDescriptors()
                                    throws StandardException
Get every statement in this database. Return the SPSDescriptors in an list.

Specified by:
getAllSPSDescriptors in interface DataDictionary
Returns:
the list of descriptors
Throws:
StandardException - Thrown on failure

getAllConstraintDescriptors

private ConstraintDescriptorList getAllConstraintDescriptors()
                                                      throws StandardException
Get every constraint in this database. Note that this list of ConstraintDescriptors is not going to be the same objects that are typically cached off of the table descriptors, so this will most likely instantiate some duplicate objects.

Returns:
the list of descriptors
Throws:
StandardException - Thrown on failure

getAllTriggerDescriptors

private GenericDescriptorList getAllTriggerDescriptors()
                                                throws StandardException
Get every trigger in this database. Note that this list of TriggerDescriptors is not going to be the same objects that are typically cached off of the table descriptors, so this will most likely instantiate some duplicate objects.

Returns:
the list of descriptors
Throws:
StandardException - Thrown on failure

getTriggerDescriptor

public TriggerDescriptor getTriggerDescriptor(UUID uuid)
                                       throws StandardException
Get a TriggerDescriptor given its UUID.

Specified by:
getTriggerDescriptor in interface DataDictionary
Parameters:
uuid - The UUID
Returns:
The TriggerDescriptor for the constraint.
Throws:
StandardException - Thrown on failure

getTriggerDescriptor

public TriggerDescriptor getTriggerDescriptor(java.lang.String name,
                                              SchemaDescriptor sd)
                                       throws StandardException
Get the stored prepared statement descriptor given a sps name.

Specified by:
getTriggerDescriptor in interface DataDictionary
Parameters:
name - The sps name.
sd - The schema descriptor.
Returns:
The TriggerDescriptor for the constraint.
Throws:
StandardException - Thrown on failure

getTriggerDescriptors

public GenericDescriptorList getTriggerDescriptors(TableDescriptor td)
                                            throws StandardException
Load up the trigger descriptor list for this table descriptor and return it. If the descriptor list is already loaded up, it is retuned without further ado.

Specified by:
getTriggerDescriptors in interface DataDictionary
Returns:
The ConstraintDescriptorList for the table
Throws:
StandardException - Thrown on failure

getTriggerDescriptorsScan

private void getTriggerDescriptorsScan(TableDescriptor td,
                                       boolean forUpdate)
                                throws StandardException
Populate the GenericDescriptorList for the specified TableDescriptor. MT synchronization: it is assumed that the caller has synchronized on the CDL in the given TD.

Parameters:
td - The TableDescriptor.
forUpdate - Whether or not to open scan for update
Returns:
Nothing.
Throws:
StandardException - Thrown on failure

dropTriggerDescriptor

public void dropTriggerDescriptor(TriggerDescriptor descriptor,
                                  TransactionController tc)
                           throws StandardException
Drops the given TriggerDescriptor. WARNING: does not drop its SPSes!!!

Specified by:
dropTriggerDescriptor in interface DataDictionary
Parameters:
descriptor - The descriptor to drop
tc - The TransactionController.
Throws:
StandardException - Thrown on failure

updateTriggerDescriptor

public void updateTriggerDescriptor(TriggerDescriptor triggerd,
                                    UUID formerUUID,
                                    int[] colsToSet,
                                    TransactionController tc)
                             throws StandardException
Update the trigger descriptor in question. Updates every row in the base conglomerate that matches the uuid.

Specified by:
updateTriggerDescriptor in interface DataDictionary
Parameters:
triggerd - The Trigger descriptor
formerUUID - The UUID for this column in SYSTRIGGERS, may differ from what is in triggerd if this is the column that is being set.
colsToSet - Array of ints of columns to be modified, 1 based. May be null (all cols).
tc - The TransactionController to use
Returns:
Nothing.
Throws:
StandardException - Thrown on failure

getConstraintDescriptor

public ConstraintDescriptor getConstraintDescriptor(UUID uuid)
                                             throws StandardException
Get a ConstraintDescriptor given its UUID. Please use getConstraintDescriptorById() is you have the constraints table descriptor, it is much faster.

Specified by:
getConstraintDescriptor in interface DataDictionary
Parameters:
uuid - The UUID
Returns:
The ConstraintDescriptor for the constraint.
Throws:
StandardException - Thrown on failure

getConstraintDescriptor

public ConstraintDescriptor getConstraintDescriptor(java.lang.String constraintName,
                                                    UUID schemaID)
                                             throws StandardException
Get a ConstraintDescriptor given its name and schema ID. Please use getConstraintDescriptorByName() if you have the constraint's table descriptor, it is much faster.

Specified by:
getConstraintDescriptor in interface DataDictionary
Parameters:
constraintName - Constraint name.
schemaID - The schema UUID
Returns:
The ConstraintDescriptor for the constraint.
Throws:
StandardException - Thrown on failure

getStatisticsDescriptors

public java.util.List getStatisticsDescriptors(TableDescriptor td)
                                        throws StandardException
get all the statistiscs descriptors for a given table.

Specified by:
getStatisticsDescriptors in interface DataDictionary
Parameters:
td - Table Descriptor for which I need statistics
Throws:
StandardException

getConstraintDescriptors

public ConstraintDescriptorList getConstraintDescriptors(TableDescriptor td)
                                                  throws StandardException
Load up the constraint descriptor list for this table descriptor and return it. If the descriptor list is already loaded up, it is retuned without further ado. If no table descriptor is passed in, then all constraint descriptors are retrieved. Note that in this case, the constraint descriptor objects may be duplicates of constraint descriptors that are hung off of the table descriptor cache.

Specified by:
getConstraintDescriptors in interface DataDictionary
Returns:
The ConstraintDescriptorList for the table
Throws:
StandardException - Thrown on failure

getActiveConstraintDescriptors

public ConstraintDescriptorList getActiveConstraintDescriptors(ConstraintDescriptorList cdl)
                                                        throws StandardException
Convert a constraint descriptor list into a list of active constraints, that is, constraints which must be enforced. For the Core product, these are just the constraints on the original list. However, during REFRESH we may have deferred some constraints until statement end. This method returns the corresponding list of constraints which AREN'T deferred.

Specified by:
getActiveConstraintDescriptors in interface DataDictionary
Parameters:
cdl - The constraint descriptor list to wrap with an Active constraint descriptor list.
Returns:
The corresponding Active ConstraintDescriptorList
Throws:
StandardException - Thrown on failure

activeConstraint

public boolean activeConstraint(ConstraintDescriptor constraint)
                         throws StandardException
Reports whether an individual constraint must be enforced. For the Core product, this routine always returns true. However, during REFRESH we may have deferred some constraints until statement end. This method returns false if the constraint deferred

Specified by:
activeConstraint in interface DataDictionary
Parameters:
constraint - the constraint to check
Returns:
The corresponding Active ConstraintDescriptorList
Throws:
StandardException - Thrown on failure

getConstraintDescriptor

public ConstraintDescriptor getConstraintDescriptor(TableDescriptor td,
                                                    UUID uuid)
                                             throws StandardException
Get the constraint descriptor given a table and the UUID String of the backing index.

Specified by:
getConstraintDescriptor in interface DataDictionary
Parameters:
uuid - the UUID for the backing index.
Returns:
The ConstraintDescriptor for the constraint.
Throws:
StandardException - Thrown on failure

getConstraintDescriptorById

public ConstraintDescriptor getConstraintDescriptorById(TableDescriptor td,
                                                        UUID uuid)
                                                 throws StandardException
Get the constraint descriptor given a table and the UUID String of the constraint

Specified by:
getConstraintDescriptorById in interface DataDictionary
Parameters:
uuid - The UUID for the constraint
Returns:
The ConstraintDescriptor for the constraint.
Throws:
StandardException - Thrown on failure

getConstraintDescriptorByName

public ConstraintDescriptor getConstraintDescriptorByName(TableDescriptor td,
                                                          SchemaDescriptor sd,
                                                          java.lang.String constraintName,
                                                          boolean forUpdate)
                                                   throws StandardException
Get the constraint descriptor given a TableDescriptor and the constraint name.

Specified by:
getConstraintDescriptorByName in interface DataDictionary
Parameters:
sd - The schema descriptor for the constraint
constraintName - The constraint name.
forUpdate - Whether or not access is for update
Returns:
The ConstraintDescriptor for the constraint.
Throws:
StandardException - Thrown on failure

getConstraintDescriptorsScan

private void getConstraintDescriptorsScan(TableDescriptor td,
                                          boolean forUpdate)
                                   throws StandardException
Populate the ConstraintDescriptorList for the specified TableDescriptor. MT synchronization: it is assumed that the caller has synchronized on the CDL in the given TD.

Parameters:
td - The TableDescriptor.
forUpdate - Whether or not to open scan for update
Returns:
Nothing.
Throws:
StandardException - Thrown on failure

getConstraintDescriptorViaIndex

protected ConstraintDescriptor getConstraintDescriptorViaIndex(int indexId,
                                                               ExecIndexRow keyRow,
                                                               TabInfo ti,
                                                               TableDescriptor td,
                                                               ConstraintDescriptorList dList,
                                                               boolean forUpdate)
                                                        throws StandardException
Return a (single or list of) ConstraintDescriptor(s) from SYSCONSTRAINTS where the access is from the index to the heap.

Parameters:
indexId - The id of the index (0 to # of indexes on table) to use
keyRow - The supplied ExecIndexRow for search
ti - The TabInfo to use
td - The TableDescriptor, if supplied.
dList - The list to build, if supplied. If null, then caller expects a single descriptor
forUpdate - Whether or not to open scan for update
Returns:
The last matching descriptor
Throws:
StandardException - Thrown on error

getConstraintDescriptorViaHeap

protected TupleDescriptor getConstraintDescriptorViaHeap(ScanQualifier[][] scanQualifiers,
                                                         TabInfo ti,
                                                         TupleDescriptor parentTupleDescriptor,
                                                         java.util.List list)
                                                  throws StandardException
Return a (single or list of) catalog row descriptor(s) from SYSCONSTRAINTS through a heap scan

Parameters:
scanQualifiers - qualifiers
ti - The TabInfo to use
parentTupleDescriptor - The parentDescriptor, if applicable.
Returns:
The last matching descriptor
Throws:
StandardException - Thrown on error

getConstraintTableDescriptor

public TableDescriptor getConstraintTableDescriptor(UUID constraintId)
                                             throws StandardException
Return a table descriptor corresponding to the TABLEID field in SYSCONSTRAINTS where CONSTRAINTID matches the constraintId passsed in.

Specified by:
getConstraintTableDescriptor in interface DataDictionary
Parameters:
constraintId - The id of the constraint
Returns:
the corresponding table descriptor
Throws:
StandardException - Thrown on error

getForeignKeys

public ConstraintDescriptorList getForeignKeys(UUID constraintId)
                                        throws StandardException
Return a list of foreign keys constraints referencing this constraint. Returns both enabled and disabled foreign keys.

Specified by:
getForeignKeys in interface DataDictionary
Parameters:
constraintId - The id of the referenced constraint
Returns:
list of constraints, empty of there are none
Throws:
StandardException - Thrown on error

getConstraints

public java.util.List getConstraints(UUID uuid,
                                     int indexId,
                                     int columnNum)
                              throws StandardException
Return an List which of the relevant column matching the indexed criteria. If nothing matches, returns an empty List (never returns null).

Parameters:
indexId - The index id in SYS.SYSCONSTRAINTS
columnNum - The column to retrieve
Returns:
a list of UUIDs in an List.
Throws:
StandardException - Thrown on error

addConstraintDescriptor

public void addConstraintDescriptor(ConstraintDescriptor descriptor,
                                    TransactionController tc)
                             throws StandardException
Adds the given ConstraintDescriptor to the data dictionary, associated with the given table and constraint type.

Specified by:
addConstraintDescriptor in interface DataDictionary
Parameters:
descriptor - The descriptor to add
tc - The transaction controller
Returns:
Nothing
Throws:
StandardException - Thrown on error

updateConstraintDescriptor

public void updateConstraintDescriptor(ConstraintDescriptor cd,
                                       UUID formerUUID,
                                       int[] colsToSet,
                                       TransactionController tc)
                                throws StandardException
Update the constraint descriptor in question. Updates every row in the base conglomerate.

Specified by:
updateConstraintDescriptor in interface DataDictionary
Parameters:
cd - The Constraintescriptor
formerUUID - The UUID for this column in SYSCONSTRAINTS, may differ from what is in cd if this is the column that is being set.
colsToSet - Array of ints of columns to be modified, 1 based. May be null (all cols).
tc - The TransactionController to use
Returns:
Nothing.
Throws:
StandardException - Thrown on failure

dropConstraintDescriptor

public void dropConstraintDescriptor(TableDescriptor table,
                                     ConstraintDescriptor descriptor,
                                     TransactionController tc)
                              throws StandardException
Drops the given ConstraintDescriptor that is associated with the given table and constraint type from the data dictionary.

Specified by:
dropConstraintDescriptor in interface DataDictionary
Parameters:
table - The table from which to drop the constraint descriptor
descriptor - The descriptor to drop
tc - The TransactionController
Returns:
Nothing
Throws:
StandardException - Thrown on error

dropAllConstraintDescriptors

public void dropAllConstraintDescriptors(TableDescriptor table,
                                         TransactionController tc)
                                  throws StandardException
Drops all ConstraintDescriptors from the data dictionary that are associated with the given table,

Specified by:
dropAllConstraintDescriptors in interface DataDictionary
Parameters:
table - The table from which to drop all constraint descriptors
tc - The TransactionController
Returns:
Nothing
Throws:
StandardException - Thrown on error

getSubKeyConstraint

public SubKeyConstraintDescriptor getSubKeyConstraint(UUID constraintId,
                                                      int type)
                                               throws StandardException
Get a SubKeyConstraintDescriptor from syskeys or sysforeignkeys for the specified constraint id. For primary foreign and and unique key constraints.

Specified by:
getSubKeyConstraint in interface DataDictionary
Parameters:
constraintId - The UUID for the constraint.
type - The type of the constraint (e.g. DataDictionary.FOREIGNKEY_CONSTRAINT)
Returns:
SubKeyConstraintDescriptor The Sub descriptor for the constraint.
Throws:
StandardException - Thrown on failure

addSubKeyConstraint

private void addSubKeyConstraint(KeyConstraintDescriptor descriptor,
                                 TransactionController tc)
                          throws StandardException
Add the matching row to syskeys when adding a unique or primary key constraint

Parameters:
descriptor - The KeyConstraintDescriptor for the constraint.
tc - The TransactionController
Returns:
Nothing.
Throws:
StandardException - Thrown on failure

dropSubKeyConstraint

private void dropSubKeyConstraint(ConstraintDescriptor constraint,
                                  TransactionController tc)
                           throws StandardException
Drop the matching row from syskeys when dropping a primary key or unique constraint.

Parameters:
constraint - the constraint
tc - The TransactionController
Returns:
Nothing.
Throws:
StandardException - Thrown on failure

getSubCheckConstraint

private SubCheckConstraintDescriptor getSubCheckConstraint(UUID constraintId)
                                                    throws StandardException
Get a SubCheckConstraintDescriptor from syschecks for the specified constraint id. (Useful for check constraints.)

Parameters:
constraintId - The UUID for the constraint.
Returns:
SubCheckConstraintDescriptor The Sub descriptor for the constraint.
Throws:
StandardException - Thrown on failure

dropSubCheckConstraint

private void dropSubCheckConstraint(UUID constraintId,
                                    TransactionController tc)
                             throws StandardException
Drop the matching row from syschecks when dropping a check constraint.

Parameters:
constraintId - The constraint id.
tc - The TransactionController
Returns:
Nothing.
Throws:
StandardException - Thrown on failure

hashAllConglomerateDescriptorsByNumber

public java.util.Hashtable hashAllConglomerateDescriptorsByNumber(TransactionController tc)
                                                           throws StandardException
Get all of the ConglomerateDescriptors in the database and hash them by conglomerate number. This is useful as a performance optimization for the locking VTIs. NOTE: This method will scan SYS.SYSCONGLOMERATES at READ UNCOMMITTED.

Specified by:
hashAllConglomerateDescriptorsByNumber in interface DataDictionary
Parameters:
tc - TransactionController for the transaction
Returns:
A Hashtable with all of the ConglomerateDescriptors in the database hashed by conglomerate number.
Throws:
StandardException - Thrown on failure

hashAllTableDescriptorsByTableId

public java.util.Hashtable hashAllTableDescriptorsByTableId(TransactionController tc)
                                                     throws StandardException
Get all of the TableDescriptors in the database and hash them by TableId This is useful as a performance optimization for the locking VTIs. NOTE: This method will scan SYS.SYSTABLES at READ UNCOMMITTED.

Specified by:
hashAllTableDescriptorsByTableId in interface DataDictionary
Parameters:
tc - TransactionController for the transaction
Returns:
A Hashtable with all of the Table descriptors in the database hashed by TableId
Throws:
StandardException - Thrown on failure

getConglomerateDescriptor

public ConglomerateDescriptor getConglomerateDescriptor(UUID uuid)
                                                 throws StandardException
Get a ConglomerateDescriptor given its UUID. If it is an index conglomerate shared by at least another duplicate index, this returns one of the ConglomerateDescriptors for those indexes.

Specified by:
getConglomerateDescriptor in interface DataDictionary
Parameters:
uuid - The UUID
Returns:
A ConglomerateDescriptor for the conglomerate.
Throws:
StandardException - Thrown on failure

getConglomerateDescriptors

public ConglomerateDescriptor[] getConglomerateDescriptors(UUID uuid)
                                                    throws StandardException
Get an array of ConglomerateDescriptors given the UUID. If it is a heap conglomerate or an index conglomerate not shared by a duplicate index, the size of the return array is 1.

Specified by:
getConglomerateDescriptors in interface DataDictionary
Parameters:
uuid - The UUID
Returns:
An array of ConglomerateDescriptors for the conglomerate. returns size 0 array if no such conglomerate.
Throws:
StandardException - Thrown on failure

getConglomerateDescriptor

public ConglomerateDescriptor getConglomerateDescriptor(long conglomerateNumber)
                                                 throws StandardException
Get a ConglomerateDescriptor given its conglomerate number. If it is an index conglomerate shared by at least another duplicate index, this returns one of the ConglomerateDescriptors for those indexes.

Specified by:
getConglomerateDescriptor in interface DataDictionary
Parameters:
conglomerateNumber - The conglomerate number.
Returns:
A ConglomerateDescriptor for the conglomerate. Returns NULL if no such conglomerate.
Throws:
StandardException - Thrown on failure

getConglomerateDescriptors

public ConglomerateDescriptor[] getConglomerateDescriptors(long conglomerateNumber)
                                                    throws StandardException
Get an array of conglomerate descriptors for the given conglomerate number. If it is a heap conglomerate or an index conglomerate not shared by a duplicate index, the size of the return array is 1.

Specified by:
getConglomerateDescriptors in interface DataDictionary
Parameters:
conglomerateNumber - The number for the conglomerate we're interested in
Returns:
An array of ConglomerateDescriptors that share the requested conglomerate. Returns size 0 array if no such conglomerate.
Throws:
StandardException - Thrown on failure

getConglomerateDescriptorsScan

private void getConglomerateDescriptorsScan(TableDescriptor td)
                                     throws StandardException
Populate the ConglomerateDescriptorList for the specified TableDescriptor by scanning sysconglomerates. MT synchronization: it is assumed that the caller has synchronized on the CDL in the given TD.

Parameters:
td - The TableDescriptor.
Returns:
Nothing.
Throws:
StandardException - Thrown on failure

getConglomerateDescriptor

public ConglomerateDescriptor getConglomerateDescriptor(java.lang.String indexName,
                                                        SchemaDescriptor sd,
                                                        boolean forUpdate)
                                                 throws StandardException
Gets a conglomerate descriptor for the named index in the given schema, getting an exclusive row lock on the matching row in sys.sysconglomerates (for DDL concurrency) if requested.

Specified by:
getConglomerateDescriptor in interface DataDictionary
Parameters:
indexName - The name of the index we're looking for
sd - The schema descriptor
forUpdate - Whether or not to get an exclusive row lock on the row in sys.sysconglomerates.
Returns:
A ConglomerateDescriptor describing the requested conglomerate. Returns NULL if no such conglomerate.
Throws:
StandardException - Thrown on failure

dropConglomerateDescriptor

public void dropConglomerateDescriptor(ConglomerateDescriptor conglomerate,
                                       TransactionController tc)
                                throws StandardException
Drops a conglomerate descriptor

Specified by:
dropConglomerateDescriptor in interface DataDictionary
Parameters:
conglomerate - The ConglomerateDescriptor for the conglomerate
tc - TransactionController for the transaction
Returns:
Nothing.
Throws:
StandardException - Thrown on failure

dropAllConglomerateDescriptors

public void dropAllConglomerateDescriptors(TableDescriptor td,
                                           TransactionController tc)
                                    throws StandardException
Drops all conglomerates associated with a table.

Specified by:
dropAllConglomerateDescriptors in interface DataDictionary
Parameters:
td - The TableDescriptor of the table
tc - TransactionController for the transaction
Returns:
Nothing.
Throws:
StandardException - Thrown on failure

updateConglomerateDescriptor

public void updateConglomerateDescriptor(ConglomerateDescriptor cd,
                                         long conglomerateNumber,
                                         TransactionController tc)
                                  throws StandardException
Update the conglomerateNumber for a ConglomerateDescriptor. This is useful, in 1.3, when doing a bulkInsert into an empty table where we insert into a new conglomerate. (This will go away in 1.4.)

Specified by:
updateConglomerateDescriptor in interface DataDictionary
Parameters:
cd - The ConglomerateDescriptor
conglomerateNumber - The new conglomerate number
tc - The TransactionController to use
Returns:
Nothing.
Throws:
StandardException - Thrown on failure

updateConglomerateDescriptor

public void updateConglomerateDescriptor(ConglomerateDescriptor[] cds,
                                         long conglomerateNumber,
                                         TransactionController tc)
                                  throws StandardException
Update the conglomerateNumber for an array of ConglomerateDescriptors. In case of more than one ConglomerateDescriptor, they are for duplicate indexes sharing one conglomerate. This is useful, in 1.3, when doing a bulkInsert into an empty table where we insert into a new conglomerate. (This will go away in 1.4.)

Specified by:
updateConglomerateDescriptor in interface DataDictionary
Parameters:
cds - The array of ConglomerateDescriptors
conglomerateNumber - The new conglomerate number
tc - The TransactionController to use
Returns:
Nothing.
Throws:
StandardException - Thrown on failure

getDependentsDescriptorList

public java.util.List getDependentsDescriptorList(java.lang.String dependentID)
                                           throws StandardException
Gets a list of the dependency descriptors for the given dependent's id.

Specified by:
getDependentsDescriptorList in interface DataDictionary
Parameters:
dependentID - The ID of the dependent we're interested in
Returns:
List Returns a list of DependencyDescriptors. Returns an empty List if no stored dependencies for the dependent's ID.
Throws:
StandardException - Thrown on failure

getProvidersDescriptorList

public java.util.List getProvidersDescriptorList(java.lang.String providerID)
                                          throws StandardException
Gets a list of the dependency descriptors for the given provider's id.

Specified by:
getProvidersDescriptorList in interface DataDictionary
Returns:
List Returns a list of DependencyDescriptors. Returns an empty List if no stored dependencies for the provider's ID.
Throws:
StandardException - Thrown on failure

getAllDependencyDescriptorsList

public java.util.List getAllDependencyDescriptorsList()
                                               throws StandardException
Build and return an List with DependencyDescriptors for all of the stored dependencies. This is useful for consistency checking.

Specified by:
getAllDependencyDescriptorsList in interface DataDictionary
Returns:
List List of all DependencyDescriptors.
Throws:
StandardException - Thrown on failure

dropStoredDependency

public void dropStoredDependency(DependencyDescriptor dd,
                                 TransactionController tc)
                          throws StandardException
Drop a single dependency from the data dictionary.

Specified by:
dropStoredDependency in interface DataDictionary
Parameters:
dd - The DependencyDescriptor.
tc - TransactionController for the transaction
Returns:
Nothing.
Throws:
StandardException - Thrown on failure

dropDependentsStoredDependencies

public void dropDependentsStoredDependencies(UUID dependentsUUID,
                                             TransactionController tc)
                                      throws StandardException
Remove all of the stored dependencies for a given dependent's ID from the data dictionary.

Specified by:
dropDependentsStoredDependencies in interface DataDictionary
Parameters:
dependentsUUID - Dependent's uuid
tc - TransactionController for the transaction
Returns:
Nothing.
Throws:
StandardException - Thrown on failure

getUUIDFactory

public UUIDFactory getUUIDFactory()
Get the UUID Factory. (No need to make the UUIDFactory a module.)

Specified by:
getUUIDFactory in interface DataDictionary
Returns:
UUIDFactory The UUID Factory for this DataDictionary.

getAliasDescriptor

public AliasDescriptor getAliasDescriptor(UUID uuid)
                                   throws StandardException
Get a AliasDescriptor given its UUID.

Specified by:
getAliasDescriptor in interface DataDictionary
Parameters:
uuid - The UUID
Returns:
The AliasDescriptor for the alias.
Throws:
StandardException - Thrown on failure

getAliasDescriptor

public AliasDescriptor getAliasDescriptor(java.lang.String schemaId,
                                          java.lang.String aliasName,
                                          char nameSpace)
                                   throws StandardException
Get a AliasDescriptor by alias name and name space. NOTE: caller responsible for handling no match.

Specified by:
getAliasDescriptor in interface DataDictionary
Parameters:
schemaId - schema identifier
aliasName - The alias name.
nameSpace - The alias type.
Returns:
AliasDescriptor AliasDescriptor for the alias name and name space
Throws:
StandardException - Thrown on failure

getRoutineList

public java.util.List getRoutineList(java.lang.String schemaID,
                                     java.lang.String routineName,
                                     char nameSpace)
                              throws StandardException
Get the list of routines matching the schema and routine name. While we only support a single alias for a given name,namespace just return a list of zero or one item.

Specified by:
getRoutineList in interface DataDictionary
Throws:
StandardException

dropAliasDescriptor

public void dropAliasDescriptor(AliasDescriptor ad,
                                TransactionController tc)
                         throws StandardException
Drop a AliasDescriptor from the DataDictionary

Specified by:
dropAliasDescriptor in interface DataDictionary
Parameters:
ad - The AliasDescriptor to drop
tc - The TransactionController
Returns:
Nothing.
Throws:
StandardException - Thrown on failure

loadDictionaryTables

protected void loadDictionaryTables(TransactionController tc,
                                    DataDescriptorGenerator ddg,
                                    java.util.Properties startParams)
                             throws StandardException
Initialize system catalogs. This is where we perform upgrade. It is our pious hope that we won't ever have to upgrade the core catalogs, other than to add fields inside Formatable columns in these catalogs. If we do have to upgrade the core catalogs, then we may need to move the loadCatalog calls into the upgrade machinery. It's do-able, just not pretty.

Parameters:
tc - TransactionController
ddg - DataDescriptorGenerator
Throws:
StandardException - Thrown on error

loadCatalogs

public void loadCatalogs(DataDescriptorGenerator ddg,
                         TabInfo[] catalogArray)
                  throws StandardException
Initialize indices for an array of catalogs

Parameters:
ddg - DataDescriptorGenerator
Throws:
StandardException - Thrown on error

createDictionaryTables

protected void createDictionaryTables(java.util.Properties params,
                                      TransactionController tc,
                                      DataDescriptorGenerator ddg)
                               throws StandardException
Create all the required dictionary tables. Any classes that extend this class and need to create new tables shoudl override this method, and then call this method as the first action in the new method, e.g.
                protected Configuration createDictionaryTables(Configuration cfg, TransactionController tc,
                                DataDescriptorGenerator ddg)
                                throws StandardException
                {
                        super.createDictionaryTables(params, tc, ddg);

                        ...
                }
                

Throws:
StandardException - Standard Cloudscape error policy

addSystemSchema

private SchemaDescriptor addSystemSchema(java.lang.String schema_name,
                                         java.lang.String schema_uuid,
                                         TransactionController tc)
                                  throws StandardException
Add a system schema to the database.

Parameters:
schema_name - name of the schema to add.
Throws:
StandardException - Standard exception policy.

upgradeMakeCatalog

protected void upgradeMakeCatalog(TransactionController tc,
                                  int catalogNumber)
                           throws StandardException
called by the upgrade code (dd_xena etc) to add a new system catalog.

Parameters:
tc - TransactionController to use.
catalogNumber - catalogNumber
Throws:
StandardException

makeCatalog

public void makeCatalog(TabInfo ti,
                        SchemaDescriptor sd,
                        TransactionController tc)
                 throws StandardException
The dirty work of creating a catalog.

Parameters:
ti - TabInfo describing catalog to create.
sd - Schema to create catalogs in.
tc - Transaction context.
Throws:
StandardException - Standard Cloudscape error policy

upgrade_setNullability

public void upgrade_setNullability(CatalogRowFactory rowFactory,
                                   int columnNumber,
                                   boolean nullability,
                                   TransactionController tc)
                            throws StandardException
Upgrade an existing catalog by setting the nullability

Parameters:
columnNumber - The column to change
nullability - true if nullable
tc - Transaction controller
Throws:
StandardException - Standard Cloudscape error policy

upgrade_addColumns

public void upgrade_addColumns(CatalogRowFactory rowFactory,
                               int[] newColumnIDs,
                               TransactionController tc)
                        throws StandardException
Upgrade an existing catalog by adding columns.

Parameters:
rowFactory - Associated with this catalog.
newColumnIDs - Array of 1-based column ids.
tc - Transaction controller
Throws:
StandardException - Standard Cloudscape error policy

upgrade_addInvisibleColumns

public void upgrade_addInvisibleColumns(CatalogRowFactory rowFactory,
                                        int[] newColumnIDs,
                                        TransactionController tc)
                                 throws StandardException
Add invisible columns to an existing system catalog

Parameters:
rowFactory - Associated with this catalog.
newColumnIDs - Array of 1-based column ids.
tc - Transaction controller
Throws:
StandardException - Standard Cloudscape error policy

widenConglomerate

private void widenConglomerate(ExecRow templateRow,
                               int[] newColumnIDs,
                               long conglomID,
                               TransactionController tc)
                        throws StandardException
Adds columns to the conglomerate underlying a system table.

Parameters:
templateRow - Ultimate shape of base row of table
newColumnIDs - Array of 1-based column ids
conglomID - heap id
tc - Transaction controller
Throws:
StandardException - Standard Cloudscape error policy

upgrade_makeOneIndex

public long upgrade_makeOneIndex(TransactionController tc,
                                 TabInfo ti,
                                 int indexNumber,
                                 long heapConglomerateNumber)
                          throws StandardException
Code to add an index to a catalog during upgrade.

Parameters:
tc - transaction controller
ti - information on the catalog that's having a new index added
indexNumber - 0-based index number
heapConglomerateNumber - what it is
Returns:
The conglomerate number of the new index.
Throws:
StandardException - Thrown on failure

getUUIDForCoreTable

private UUID getUUIDForCoreTable(java.lang.String tableName,
                                 java.lang.String schemaUUID,
                                 TransactionController tc)
                          throws StandardException
Get the UUID for the specified system table. Prior to Plato, system tables did not have canonical UUIDs, so we need to scan systables to get the UUID when we are updating the core tables.

Parameters:
tableName - Name of the table
schemaUUID - UUID of schema
tc - TransactionController to user
Returns:
UUID The UUID of the core table.
Throws:
StandardException - Thrown on failure

upgrade_initSystemTableCols

void upgrade_initSystemTableCols(TransactionController tc,
                                 boolean isCoreTable,
                                 int tableNum,
                                 FormatableBitSet columnsToUpdateSet,
                                 DataValueDescriptor[] replaceRow)
                           throws StandardException
Initialize noncore columns to fixed values

Parameters:
tc - The TransactionController for the transaction to do the upgrade in.
isCoreTable - true if it is a core table
tableNum - the noncore table number
columnsToUpdateSet - a bit set of columns to update. ZERO BASED
replaceRow - an object array of Orderables for the new values
Throws:
StandardException - Thrown on error

bootStrapSystemIndexes

private void bootStrapSystemIndexes(SchemaDescriptor sd,
                                    TransactionController tc,
                                    DataDescriptorGenerator ddg,
                                    TabInfo ti)
                             throws StandardException
Infrastructure work for indexes on catalogs.

Throws:
StandardException - Standard Cloudscape error policy

computeAutoincRowLocations

public RowLocation[] computeAutoincRowLocations(TransactionController tc,
                                                TableDescriptor td)
                                         throws StandardException
Description copied from interface: DataDictionary
returns an array of RowLocations corresponding to the autoincrement columns in the table. The RowLocation points to the row in SYSCOLUMNS for this particular ai column. The array has as many elements as there are columns in the table. If a column is not an ai column, the entry is NULL.

Specified by:
computeAutoincRowLocations in interface DataDictionary
Parameters:
tc - TransactionControler to use to compute the row location.
td - TableDescriptor
Returns:
array of row locations, null if table has no autoinc columns.
Throws:
StandardException
See Also:
DataDictionary.computeAutoincRowLocations(org.apache.derby.iapi.store.access.TransactionController, org.apache.derby.iapi.sql.dictionary.TableDescriptor)

getSetAutoincrementValue

public NumberDataValue getSetAutoincrementValue(RowLocation rl,
                                                TransactionController tc,
                                                boolean doUpdate,
                                                NumberDataValue newValue,
                                                boolean wait)
                                         throws StandardException
Description copied from interface: DataDictionary
getSetAutoincrementValue fetches the autoincrement value from SYSCOLUMNS given a row location. If doUpdate is true it updates the autoincrement column with the new value. the value returned by this routine is the new value and *NOT* the value in the system catalogs.

Specified by:
getSetAutoincrementValue in interface DataDictionary
Parameters:
rl - RowLocation of the entry in SYSCOLUMNS.
tc - TransactionController to use.
doUpdate - Write the new value to disk if TRUE.
newValue - A NumberDataValue to use to return incremented value. If null, then the caller simply wants the current value fromd disk.
wait - If true, then the caller wants to wait for locks. When using a nested user xaction we want to timeout right away if the parent holds the lock.
Throws:
StandardException
See Also:
DataDictionary.getSetAutoincrementValue(org.apache.derby.iapi.types.RowLocation, org.apache.derby.iapi.store.access.TransactionController, boolean, org.apache.derby.iapi.types.NumberDataValue, boolean)

bootstrapOneIndex

private ConglomerateDescriptor bootstrapOneIndex(SchemaDescriptor sd,
                                                 TransactionController tc,
                                                 DataDescriptorGenerator ddg,
                                                 TabInfo ti,
                                                 int indexNumber,
                                                 long heapConglomerateNumber)
                                          throws StandardException
Throws:
StandardException

initSystemIndexVariables

public void initSystemIndexVariables(DataDescriptorGenerator ddg,
                                     TabInfo ti,
                                     int indexNumber)
                              throws StandardException
Throws:
StandardException

populateSYSDUMMY1

protected void populateSYSDUMMY1(TransactionController tc)
                          throws StandardException
Populate SYSDUMMY1 table with a single row.

Throws:
StandardException - Standard Cloudscape error policy

clearCaches

public void clearCaches()
                 throws StandardException
Clear all of the DataDictionary caches.

Specified by:
clearCaches in interface DataDictionary
Returns:
Nothing.
Throws:
StandardException - Standard Cloudscape error policy

addSystemTableToDictionary

private void addSystemTableToDictionary(TabInfo ti,
                                        SchemaDescriptor sd,
                                        TransactionController tc,
                                        DataDescriptorGenerator ddg)
                                 throws StandardException
Add the required entries to the data dictionary for a System table.

Throws:
StandardException

makeColumnDescriptor

private ColumnDescriptor makeColumnDescriptor(SystemColumn column,
                                              TableDescriptor td)
                                       throws StandardException
Converts a SystemColumn to a ColumnDescriptor.

Parameters:
column - a SystemColumn
td - descriptor for table that column lives in
Returns:
a ColumnDes*criptor
Throws:
StandardException - Standard Cloudscape error policy

createConglomerate

private long createConglomerate(java.lang.String name,
                                TransactionController tc,
                                ExecRow rowTemplate,
                                java.util.Properties properties)
                         throws StandardException
Create a conglomerate for a system table

Parameters:
name - Name of new catalog.
tc - Transaction context.
rowTemplate - Template for rows for the new table
properties - Properties for createConglomerate
Returns:
Conglomerate id.
Throws:
StandardException - Standard Cloudscape error policy.

getValueAsDVD

public DataValueDescriptor getValueAsDVD(UUID uuid)
                                  throws StandardException
Converts a UUID to an DataValueDescriptor.

Returns:
the UUID converted to an DataValueDescriptor
Throws:
StandardException - Thrown on error

initializeCatalogInfo

public void initializeCatalogInfo()
                           throws StandardException
Initialize catalog information. This method is overridden by children.

Throws:
StandardException - Thrown on error

initializeCoreInfo

private void initializeCoreInfo()
                         throws StandardException
Initialized the core info array.

Throws:
StandardException

initializeNoncoreInfo

private void initializeNoncoreInfo()
                            throws StandardException
Initialized the noncore info array.

Throws:
StandardException

getTabInfo

public TabInfo getTabInfo(java.lang.String tableName)
                   throws StandardException
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.

Specified by:
getTabInfo in interface DataDictionary
Parameters:
tableName - name of table to get the TabInfo for.
Returns:
tabinfo corresponding to tablename
Throws:
StandardException - Thrown on error

getTransactionCompile

public TransactionController getTransactionCompile()
                                            throws StandardException
Get the TransactionController to use, when not passed in as a parameter. (This hides logic about whether or not we're at boot time in a single place. NOTE: There's no LCC at boot time.) NOTE: All methods in the DD should call this method.

Returns:
TransactionController The TC to use.
Throws:
StandardException - Thrown on error

getTransactionExecute

public TransactionController getTransactionExecute()
                                            throws StandardException
Get the TransactionController to use, when not passed in as a parameter. (This hides logic about whether or not we're at boot time in a single place. NOTE: There's no LCC at boot time.) NOTE: All methods in the DD should call this method.

Returns:
TransactionController The TC to use.
Throws:
StandardException - Thrown on error

getDescriptorViaIndex

private final TupleDescriptor getDescriptorViaIndex(int indexId,
                                                    ExecIndexRow keyRow,
                                                    ScanQualifier[][] scanQualifiers,
                                                    TabInfo ti,
                                                    TupleDescriptor parentTupleDescriptor,
                                                    java.util.List list,
                                                    boolean forUpdate)
                                             throws StandardException
Return a (single or list of) catalog row descriptor(s) from a system table where the access is from the index to the heap.

Parameters:
indexId - The id of the index (0 to # of indexes on table) to use
keyRow - The supplied ExecIndexRow for search
ti - The TabInfo to use
parentTupleDescriptor - The parentDescriptor, if applicable.
forUpdate - Whether or not to open the index for update.
Returns:
The last matching descriptor
Throws:
StandardException - Thrown on error

debugGenerateInfo

private void debugGenerateInfo(java.lang.StringBuffer strbuf,
                               TransactionController tc,
                               ConglomerateController heapCC,
                               TabInfo ti,
                               int indexId)

getDescriptorViaHeap

protected TupleDescriptor getDescriptorViaHeap(ScanQualifier[][] scanQualifiers,
                                               TabInfo ti,
                                               TupleDescriptor parentTupleDescriptor,
                                               java.util.List list)
                                        throws StandardException
Return a (single or list of) catalog row descriptor(s) from a system table where the access a heap scan

Parameters:
scanQualifiers - qualifiers
ti - The TabInfo to use
parentTupleDescriptor - The parentDescriptor, if applicable.
Returns:
The last matching descriptor
Throws:
StandardException - Thrown on error

getNonCoreTI

private TabInfo getNonCoreTI(int catalogNumber)
                      throws StandardException
Get a TabInfo for a non-core table. (We fault in information about non-core tables as needed.)

Returns:
Nothing.
Throws:
StandardException - Thrown on error

getNonCoreTIByNumber

protected TabInfo getNonCoreTIByNumber(int catalogNumber)
                                throws StandardException
returns the tabinfo for a non core system catalog. Input is a catalogNumber (defined in DataDictionary).

Throws:
StandardException

initSystemIndexVariables

protected void initSystemIndexVariables(TabInfo ti)
                                 throws StandardException
Throws:
StandardException

clearNoncoreTable

private void clearNoncoreTable(int nonCoreNum)

getCoreCatalog

public TabInfo getCoreCatalog(int coreNum)
                       throws StandardException
Get core catalog info.

Specified by:
getCoreCatalog in interface DataDictionary
Parameters:
coreNum - The index into coreInfo[].
Returns:
Nothing.
Throws:
StandardException - Thrown on error

faultInTabInfo

public void faultInTabInfo(TabInfo ti)
                    throws StandardException
Finishes building a TabInfo if it hasn't already been faulted in. NOP if TabInfo has already been faulted in.

Parameters:
ti - TabInfo to fault in.
Throws:
StandardException - Thrown on error

getIndexRowFromHeapRow

public static ExecIndexRow getIndexRowFromHeapRow(IndexRowGenerator irg,
                                                  RowLocation rl,
                                                  ExecRow heapRow)
                                           throws StandardException
Get an index row based on a row from the heap.

Parameters:
irg - IndexRowGenerator to use
rl - RowLocation for heap
heapRow - Row from the heap
Returns:
ExecIndexRow Index row.
Throws:
StandardException - Thrown on error

getEngineType

public int getEngineType()
Specified by:
getEngineType in interface DataDictionary

getSYSCOLUMNSHeapConglomerateNumber

public long getSYSCOLUMNSHeapConglomerateNumber()
Get the heap conglomerate number for SYS.SYSCOLUMNS. (Useful for adding new index to the table.)

Returns:
The heap conglomerate number for SYS.SYSCOLUMNS.

addSYSCOLUMNSIndex2Property

void addSYSCOLUMNSIndex2Property(TransactionController tc,
                                 long index2ConglomerateNumber)

getBootParameter

private long getBootParameter(java.util.Properties startParams,
                              java.lang.String key,
                              boolean required)
                       throws StandardException
Throws:
StandardException

getSystemSQLName

public java.lang.String getSystemSQLName()
Returns a unique system generated name of the form SQLyymmddhhmmssxxn yy - year, mm - month, dd - day of month, hh - hour, mm - minute, ss - second, xx - the first 2 digits of millisec because we don't have enough space to keep the exact millisec value, n - number between 0-9 The number at the end is to handle more than one system generated name request came at the same time. In that case, the timestamp will remain the same, we will just increment n at the end of the name. Following is how we get around the problem of more than 10 system generated name requestes at the same time: When the database boots up, we start a counter with value -1 for the last digit in the generated name. We also keep the time in millisec to keep track of when the last system name was generated. At the boot time, it will be default to 0L. In addition, we have a calendar object for the time in millisec That calendar object is used to fetch yy, mm, dd, etc for the string SQLyymmddhhmmssxxn When the first request for the system generated name comes, time of last system generated name will be less than the current time. We initialize the counter to 0, set the time of last system generated name to the current time truncated off to lower 10ms time. The first name request is the only time we know for sure the time of last system generated name will be less than the current time. After this first request, the next request could be at any time. We go through the following algorithm for every generated name request. First check if the current time(truncated off to lower 10ms) is greater than the timestamp for last system generated name If yes, then we change the timestamp for system generated name to the current timestamp and reset the counter to 0 and generate the name using the current timestamp and 0 as the number at the end of the generated name. If no, then it means this request for generated name has come at the same time as last one. Or it may come at a time less than the last generated name request. This could be because of seasonal time change or somebody manually changing the time on the computer. In any case, if the counter is less than 10(meaning this is not yet our 11th request for generated name at a given time), we use that in the generated name. But if the counter has reached 10(which means, this is the 11th name request at the same time), then we increment the system generated name timestamp by 10ms and reset the counter to 0 (notice, at this point, the timestamp for system generated names is not in sync with the real current time, but we need to have this mechanism to get around the problem of more than 10 generated name requests at a same physical time).

Specified by:
getSystemSQLName in interface DataDictionary
Returns:
system generated unique name

twoDigits

private static java.lang.String twoDigits(int val)

setAutoincrementValue

public void setAutoincrementValue(TransactionController tc,
                                  UUID tableUUID,
                                  java.lang.String columnName,
                                  long aiValue,
                                  boolean incrementNeeded)
                           throws StandardException
sets a new value in SYSCOLUMNS for a particular autoincrement column.

Specified by:
setAutoincrementValue in interface DataDictionary
Parameters:
tc - Transaction Controller to use.
columnName - Name of the column.
aiValue - Value to write to SYSCOLUMNS.
incrementNeeded - whether to increment the value passed in by the user (aiValue) or not before writing it to SYSCOLUMNS.
Throws:
StandardException

computeRowLocation

private RowLocation computeRowLocation(TransactionController tc,
                                       TableDescriptor td,
                                       java.lang.String columnName)
                                throws StandardException
Computes the RowLocation in SYSCOLUMNS for a particular autoincrement column.

Parameters:
tc - Transaction Controller to use.
td - Table Descriptor.
columnName - Name of column which has autoincrement column.
Throws:
StandardException - thrown on failure.

getRowLocationTemplate

public RowLocation getRowLocationTemplate(LanguageConnectionContext lcc,
                                          TableDescriptor td)
                                   throws StandardException
Specified by:
getRowLocationTemplate in interface DataDictionary
Throws:
StandardException

addTableDescriptorToOtherCache

public void addTableDescriptorToOtherCache(TableDescriptor td,
                                           Cacheable c)
                                    throws StandardException
Add a table descriptor to the "other" cache. The other cache is determined by the type of the object c.

Parameters:
td - TableDescriptor to add to the other cache.
c - Cacheable Object which lets us figure out the other cache.
Throws:
StandardException

dropStatisticsDescriptors

public void dropStatisticsDescriptors(UUID tableUUID,
                                      UUID referenceUUID,
                                      TransactionController tc)
                               throws StandardException
Description copied from interface: DataDictionary
Drops all statistics descriptors for a given table/index column combination. If the index is not specified, then all statistics for the table are dropped.

Specified by:
dropStatisticsDescriptors in interface DataDictionary
Parameters:
tableUUID - UUID of the table
referenceUUID - UUID of the index. This can be null.
tc - Transcation Controller to use.
Throws:
StandardException
See Also:
DataDictionary.dropStatisticsDescriptors(org.apache.derby.catalog.UUID, org.apache.derby.catalog.UUID, org.apache.derby.iapi.store.access.TransactionController)

getLCC

private static LanguageConnectionContext getLCC()

newSystemSchemaDesc

private SchemaDescriptor newSystemSchemaDesc(java.lang.String name,
                                             java.lang.String uuid)

newDeclaredGlobalTemporaryTablesSchemaDesc

private SchemaDescriptor newDeclaredGlobalTemporaryTablesSchemaDesc(java.lang.String name)

checkVersion

public boolean checkVersion(int requiredMajorVersion,
                            java.lang.String feature)
                     throws StandardException
Check to see if a database has been upgraded to the required level in order to use a language feature.

Specified by:
checkVersion in interface DataDictionary
Parameters:
feature - Non-null to throw an error, null to return the state of the version match.
requiredMajorVersion - Data Dictionary major version (DataDictionary.DD_ constant)
Returns:
True if the database has been upgraded to the required level, false otherwise.
Throws:
StandardException

createSystemSps

void createSystemSps(TransactionController tc)
               throws StandardException
Create system built-in metadata stored prepared statements.

Throws:
StandardException

createSPSSet

private void createSPSSet(TransactionController tc,
                          boolean net,
                          UUID schemaID)
                   throws StandardException
Create a set of stored prepared statements from a properties file. Key is the statement name, value is the SQL statement.

Throws:
StandardException

createSystemProcedureOrFunction

private final void createSystemProcedureOrFunction(java.lang.String routine_name,
                                                   UUID schema_uuid,
                                                   java.lang.String[] arg_names,
                                                   TypeDescriptor[] arg_types,
                                                   int num_out_param,
                                                   int num_result_sets,
                                                   short routine_sql_control,
                                                   TypeDescriptor return_type,
                                                   TransactionController tc)
                                            throws StandardException
Generic create procedure routine.

Takes the input procedure and inserts it into the appropriate catalog. Assumes all arguments are "IN" type.

Parameters:
routine_name - name of the routine in java and the SQL procedure name.
arg_names - String array of procedure argument names in order.
arg_types - Internal SQL types of the arguments
routine_sql_control - One of the RoutineAliasInfo constants: MODIFIES_SQL_DATA READS_SQL_DATA CONTAINS_SQL NO_SQL
return_type - null for procedure. For functions the return type of the function.
Returns:
The identifier to be used to open the conglomerate later.
Throws:
StandardException - Standard exception policy.

create_SYSCS_procedures

private final void create_SYSCS_procedures(TransactionController tc)
                                    throws StandardException
Create system procedures

Used to add the system procedures to the database when it is created. System procedures are currently added to either SYSCS_UTIL or SQLJ schemas.

Parameters:
tc - transaction controller to use. Counts on caller to commit.
Throws:
StandardException - Standard exception policy.

create_SYSIBM_procedures

protected final void create_SYSIBM_procedures(TransactionController tc)
                                       throws StandardException
Create system procedures in SYSIBM

Used to add the system procedures to the database when it is created. Full upgrade from version 5.1 or earlier also calls this method.

Parameters:
tc - transaction controller to use. Counts on caller to commit.
Throws:
StandardException - Standard exception policy.

create_10_1_system_procedures

void create_10_1_system_procedures(TransactionController tc,
                                   UUID sysUtilUUID)
                             throws StandardException
Create system procedures added in version 10.1.

Create 10.1 system procedures, called by either code creating new database, or code doing hard upgrade from previous version.

Parameters:
sysUtilUUID - uuid of the SYSUTIL schema.
Throws:
StandardException - Standard exception policy.

getQueryDescriptions

private final java.util.Properties getQueryDescriptions(boolean net)

run

public final java.lang.Object run()
Specified by:
run in interface java.security.PrivilegedAction

newSList

private static java.util.List newSList()

Built on Mon 2007-06-04 09:58:47+0400, from revision ???

Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.