Search in sources :

Example 11 with SchemaDescriptor

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

the class DataDictionaryImpl method dropJDBCMetadataSPSes.

/**
 * Remove metadata stored prepared statements.
 * @param tc the xact
 */
private void dropJDBCMetadataSPSes(TransactionController tc) throws StandardException {
    for (SPSDescriptor spsd : getAllSPSDescriptors()) {
        SchemaDescriptor sd = spsd.getSchemaDescriptor();
        // don't drop statements in non-system schemas
        if (!sd.isSystemSchema()) {
            continue;
        }
        dropSPSDescriptor(spsd, tc);
        dropDependentsStoredDependencies(spsd.getUUID(), tc);
    }
}
Also used : SchemaDescriptor(org.apache.derby.iapi.sql.dictionary.SchemaDescriptor) SPSDescriptor(org.apache.derby.iapi.sql.dictionary.SPSDescriptor)

Example 12 with SchemaDescriptor

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

the class DataDictionaryImpl method addSystemSchema.

/**
 * Add a system schema to the database.
 * <p>
 *
 * @param schema_name   name of the schema to add.
 *
 * @exception  StandardException  Standard exception policy.
 */
private SchemaDescriptor addSystemSchema(String schema_name, String schema_uuid, TransactionController tc) throws StandardException {
    // create the descriptor
    SchemaDescriptor schema_desc = new SchemaDescriptor(this, schema_name, authorizationDatabaseOwner, uuidFactory.recreateUUID(schema_uuid), true);
    // add it to the catalog.
    addDescriptor(schema_desc, null, SYSSCHEMAS_CATALOG_NUM, false, tc);
    return (schema_desc);
}
Also used : SchemaDescriptor(org.apache.derby.iapi.sql.dictionary.SchemaDescriptor)

Example 13 with SchemaDescriptor

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

the class DataDictionaryImpl method getVTIClass.

/**
 * @see DataDictionary#getVTIClass(TableDescriptor, boolean)
 */
public String getVTIClass(TableDescriptor td, boolean asTableFunction) throws StandardException {
    if (SchemaDescriptor.STD_SYSTEM_DIAG_SCHEMA_NAME.equals(td.getSchemaName())) {
        return getBuiltinVTIClass(td, asTableFunction);
    } else // see if it's a user-defined table function
    {
        String schemaName = td.getSchemaName();
        String functionName = td.getDescriptorName();
        SchemaDescriptor sd = getSchemaDescriptor(td.getSchemaName(), null, true);
        if (sd != null) {
            AliasDescriptor ad = getAliasDescriptor(sd.getUUID().toString(), functionName, AliasInfo.ALIAS_TYPE_FUNCTION_AS_CHAR);
            if ((ad != null) && ad.isTableFunction()) {
                return ad.getJavaClassName();
            }
            throw StandardException.newException(SQLState.LANG_NOT_TABLE_FUNCTION, schemaName, functionName);
        }
    }
    return null;
}
Also used : SchemaDescriptor(org.apache.derby.iapi.sql.dictionary.SchemaDescriptor) AliasDescriptor(org.apache.derby.iapi.sql.dictionary.AliasDescriptor)

Example 14 with SchemaDescriptor

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

the class DataDictionaryImpl method createIdentitySequence.

/**
 * Create a sequence generator for an identity column on upgrade to 10.11.
 */
private void createIdentitySequence(TableDescriptor td, // the identity column
ColumnDescriptor cd, TransactionController tc) throws StandardException {
    DataTypeDescriptor dtd = cd.getType();
    long[] bounds = dtd.getNumericBounds();
    long currentValue = cd.getAutoincValue();
    long initialValue = cd.getAutoincStart();
    long minValue = bounds[DataTypeDescriptor.MIN_VALUE_IDX];
    long maxValue = bounds[DataTypeDescriptor.MAX_VALUE_IDX];
    long stepValue = cd.getAutoincInc();
    SchemaDescriptor sd = getSystemSchemaDescriptor();
    SequenceDescriptor seqDef = getDataDescriptorGenerator().newSequenceDescriptor(sd, getUUIDFactory().createUUID(), TableDescriptor.makeSequenceName(td.getUUID()), dtd, currentValue, initialValue, minValue, maxValue, stepValue, // whether the sequence can wrap-around
    false);
    addDescriptor(seqDef, // parent
    null, DataDictionary.SYSSEQUENCES_CATALOG_NUM, // duplicatesAllowed
    false, tc);
}
Also used : SchemaDescriptor(org.apache.derby.iapi.sql.dictionary.SchemaDescriptor) DataTypeDescriptor(org.apache.derby.iapi.types.DataTypeDescriptor) SequenceDescriptor(org.apache.derby.iapi.sql.dictionary.SequenceDescriptor)

Example 15 with SchemaDescriptor

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

the class DataDictionaryImpl method upgradeFixSystemColumnDefinition.

/**
 *	Upgrade an existing system catalog column's definition
 * by setting it to the value it would have in a newly
 * created database. This is only used to for a couple
 * of columns that had incorrectly nullability. Other
 * uses (e.g. changing column type) might require more work.
 *
 *	@param	columnNumber			The column to change
 *	@param	tc						Transaction controller
 *
 *	@exception StandardException Standard Derby error policy
 */
public void upgradeFixSystemColumnDefinition(CatalogRowFactory rowFactory, int columnNumber, TransactionController tc) throws StandardException {
    SystemColumn theColumn;
    SystemColumn[] columns = rowFactory.buildColumnList();
    SchemaDescriptor sd = getSystemSchemaDescriptor();
    TableDescriptor td = getTableDescriptor(rowFactory.getCatalogName(), sd, tc);
    // from 1 to 0 based
    theColumn = columns[columnNumber - 1];
    ColumnDescriptor cd = makeColumnDescriptor(theColumn, columnNumber, td);
    String columnName = cd.getColumnName();
    int[] columnNameColArray = new int[1];
    columnNameColArray[0] = SYSCOLUMNSRowFactory.SYSCOLUMNS_COLUMNDATATYPE;
    updateColumnDescriptor(cd, td.getUUID(), columnName, columnNameColArray, 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) TableDescriptor(org.apache.derby.iapi.sql.dictionary.TableDescriptor)

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