Search in sources :

Example 6 with SchemaDescriptor

use of org.apache.derby.iapi.sql.dictionary.SchemaDescriptor in project derby by apache.

the class BasicDatabase method validate.

/**
 *	  @see PropertySetCallback#validate
 *	  @exception StandardException Thrown on error.
 */
public boolean validate(String key, Serializable value, Dictionary p) throws StandardException {
    // Disallow setting static creation time only configuration properties
    if (key.equals(EngineType.PROPERTY))
        throw StandardException.newException(SQLState.PROPERTY_UNSUPPORTED_CHANGE, key, value);
    // only interested in the classpath
    if (!key.equals(Property.DATABASE_CLASSPATH))
        return false;
    String newClasspath = (String) value;
    // The parsed dbclasspath
    String[][] dbcp = null;
    if (newClasspath != null) {
        // parse it when it is set to ensure only valid values
        // are written to the actual conglomerate.
        dbcp = IdUtil.parseDbClassPath(newClasspath);
    }
    // Verify that all jar files on the database classpath are in the data dictionary.
    if (dbcp != null) {
        for (int ix = 0; ix < dbcp.length; ix++) {
            SchemaDescriptor sd = dd.getSchemaDescriptor(dbcp[ix][IdUtil.DBCP_SCHEMA_NAME], null, false);
            FileInfoDescriptor fid = null;
            if (sd != null)
                fid = dd.getFileInfoDescriptor(sd, dbcp[ix][IdUtil.DBCP_SQL_JAR_NAME]);
            if (fid == null) {
                throw StandardException.newException(SQLState.LANG_DB_CLASS_PATH_HAS_MISSING_JAR, IdUtil.mkQualifiedName(dbcp[ix]));
            }
        }
    }
    return true;
}
Also used : SchemaDescriptor(org.apache.derby.iapi.sql.dictionary.SchemaDescriptor) FileInfoDescriptor(org.apache.derby.iapi.sql.dictionary.FileInfoDescriptor)

Example 7 with SchemaDescriptor

use of org.apache.derby.iapi.sql.dictionary.SchemaDescriptor in project derby by apache.

the class DataDictionaryImpl method upgrade_addColumns.

/**
 *	Upgrade an existing catalog by adding columns.
 *
 *	@param	rowFactory				Associated with this catalog.
 *	@param	newColumnIDs			Array of 1-based column ids.
 *	@param	tc						Transaction controller
 *
 *	@exception StandardException Standard Derby error policy
 */
public void upgrade_addColumns(CatalogRowFactory rowFactory, int[] newColumnIDs, TransactionController tc) throws StandardException {
    int columnID;
    SystemColumn currentColumn;
    SystemColumn[] columns = rowFactory.buildColumnList();
    ExecRow templateRow = rowFactory.makeEmptyRowForCurrentVersion();
    int columnCount = newColumnIDs.length;
    SchemaDescriptor sd = getSystemSchemaDescriptor();
    TableDescriptor td;
    long conglomID;
    // table/column descriptor until after we add and populate the new column.
    if (rowFactory instanceof SYSTABLESRowFactory) {
        td = dataDescriptorGenerator.newTableDescriptor("SYSTABLES", sd, TableDescriptor.BASE_TABLE_TYPE, TableDescriptor.ROW_LOCK_GRANULARITY);
        td.setUUID(getUUIDForCoreTable("SYSTABLES", sd.getUUID().toString(), tc));
        conglomID = coreInfo[SYSTABLES_CORE_NUM].getHeapConglomerate();
    } else if (rowFactory instanceof SYSCOLUMNSRowFactory) {
        td = dataDescriptorGenerator.newTableDescriptor("SYSCOLUMNS", sd, TableDescriptor.BASE_TABLE_TYPE, TableDescriptor.ROW_LOCK_GRANULARITY);
        td.setUUID(getUUIDForCoreTable("SYSCOLUMNS", sd.getUUID().toString(), tc));
        conglomID = coreInfo[SYSCOLUMNS_CORE_NUM].getHeapConglomerate();
    } else {
        td = getTableDescriptor(rowFactory.getCatalogName(), sd, tc);
        conglomID = td.getHeapConglomerateId();
    }
    widenConglomerate(templateRow, newColumnIDs, conglomID, tc);
    ColumnDescriptor[] cdArray = new ColumnDescriptor[columnCount];
    for (int ix = 0; ix < columnCount; ix++) {
        columnID = newColumnIDs[ix];
        // from 1 to 0 based
        currentColumn = columns[columnID - 1];
        cdArray[ix] = makeColumnDescriptor(currentColumn, columnID, td);
    }
    addDescriptorArray(cdArray, td, SYSCOLUMNS_CATALOG_NUM, false, tc);
}
Also used : SchemaDescriptor(org.apache.derby.iapi.sql.dictionary.SchemaDescriptor) SystemColumn(org.apache.derby.iapi.sql.dictionary.SystemColumn) ColumnDescriptor(org.apache.derby.iapi.sql.dictionary.ColumnDescriptor) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) SQLLongint(org.apache.derby.iapi.types.SQLLongint) TableDescriptor(org.apache.derby.iapi.sql.dictionary.TableDescriptor)

Example 8 with SchemaDescriptor

use of org.apache.derby.iapi.sql.dictionary.SchemaDescriptor in project derby by apache.

the class DataDictionaryImpl method resetDatabaseOwner.

/**
 *	Reset the database owner according to what is stored in the catalogs.
 * This can change at upgrade time so we have factored this logic into
 * a separately callable method.
 *
 *	@param	tc		TransactionController
 *
 *  @exception StandardException		Thrown on error
 */
public void resetDatabaseOwner(TransactionController tc) throws StandardException {
    SchemaDescriptor sd = locateSchemaRow(SchemaDescriptor.IBM_SYSTEM_SCHEMA_NAME, tc);
    authorizationDatabaseOwner = sd.getAuthorizationId();
    systemSchemaDesc.setAuthorizationId(authorizationDatabaseOwner);
    sysIBMSchemaDesc.setAuthorizationId(authorizationDatabaseOwner);
    systemUtilSchemaDesc.setAuthorizationId(authorizationDatabaseOwner);
}
Also used : SchemaDescriptor(org.apache.derby.iapi.sql.dictionary.SchemaDescriptor)

Example 9 with SchemaDescriptor

use of org.apache.derby.iapi.sql.dictionary.SchemaDescriptor in project derby by apache.

the class DataDictionaryImpl method getAliasDescriptorForUDT.

/**
 * Get the alias descriptor for an ANSI UDT.
 *
 * @param tc The transaction to use: if null, use the compilation transaction
 * @param dtd The UDT's type descriptor
 *
 * @return The UDT's alias descriptor if it is an ANSI UDT; null otherwise.
 */
public AliasDescriptor getAliasDescriptorForUDT(TransactionController tc, DataTypeDescriptor dtd) throws StandardException {
    if (tc == null) {
        tc = getTransactionCompile();
    }
    if (dtd == null) {
        return null;
    }
    BaseTypeIdImpl btii = dtd.getTypeId().getBaseTypeId();
    if (!btii.isAnsiUDT()) {
        return null;
    }
    SchemaDescriptor sd = getSchemaDescriptor(btii.getSchemaName(), tc, true);
    AliasDescriptor ad = getAliasDescriptor(sd.getUUID().toString(), btii.getUnqualifiedName(), AliasInfo.ALIAS_NAME_SPACE_UDT_AS_CHAR);
    return ad;
}
Also used : SchemaDescriptor(org.apache.derby.iapi.sql.dictionary.SchemaDescriptor) AliasDescriptor(org.apache.derby.iapi.sql.dictionary.AliasDescriptor) BaseTypeIdImpl(org.apache.derby.catalog.types.BaseTypeIdImpl)

Example 10 with SchemaDescriptor

use of org.apache.derby.iapi.sql.dictionary.SchemaDescriptor in project derby by apache.

the class DataDictionaryImpl method putSequenceID.

/**
 * Map ( schemaName, sequenceName ) to sequenceID
 */
private void putSequenceID(SequenceDescriptor sd) throws StandardException {
    if (sd == null) {
        return;
    }
    SchemaDescriptor schema = sd.getSchemaDescriptor();
    String schemaName = schema.getSchemaName();
    String sequenceName = sd.getSequenceName();
    String uuid = sd.getUUID().toString();
    HashMap<String, String> sequencesInSchema = sequenceIDs.get(schemaName);
    if (sequencesInSchema == null) {
        sequencesInSchema = new HashMap<String, String>();
        sequenceIDs.put(schemaName, sequencesInSchema);
    }
    if (sequencesInSchema.get(sequenceName) == null) {
        sequencesInSchema.put(sequenceName, uuid);
    }
}
Also used : SchemaDescriptor(org.apache.derby.iapi.sql.dictionary.SchemaDescriptor)

Aggregations

SchemaDescriptor (org.apache.derby.iapi.sql.dictionary.SchemaDescriptor)85 DataDictionary (org.apache.derby.iapi.sql.dictionary.DataDictionary)33 TableDescriptor (org.apache.derby.iapi.sql.dictionary.TableDescriptor)27 UUID (org.apache.derby.catalog.UUID)21 LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)20 TransactionController (org.apache.derby.iapi.store.access.TransactionController)20 DataDescriptorGenerator (org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator)14 CompilerContext (org.apache.derby.iapi.sql.compile.CompilerContext)12 ConglomerateDescriptor (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)12 AliasDescriptor (org.apache.derby.iapi.sql.dictionary.AliasDescriptor)11 ConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor)9 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)9 DependencyManager (org.apache.derby.iapi.sql.depend.DependencyManager)8 ColumnDescriptor (org.apache.derby.iapi.sql.dictionary.ColumnDescriptor)8 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)8 DataTypeDescriptor (org.apache.derby.iapi.types.DataTypeDescriptor)8 Properties (java.util.Properties)5 ColumnDescriptorList (org.apache.derby.iapi.sql.dictionary.ColumnDescriptorList)5 StandardException (org.apache.derby.shared.common.error.StandardException)5 RoutineAliasInfo (org.apache.derby.catalog.types.RoutineAliasInfo)4