Search in sources :

Example 86 with UUID

use of org.apache.derby.catalog.UUID in project derby by apache.

the class DataDictionaryImpl method createIdentitySequences.

/**
 * Create sequence generators for all identity columns on upgrade to 10.11.
 */
void createIdentitySequences(TransactionController tc) throws StandardException {
    Hashtable<UUID, TableDescriptor> tableMap = hashAllTableDescriptorsByTableId(tc);
    for (UUID tableID : tableMap.keySet()) {
        TableDescriptor td = getTableDescriptor(tableID);
        ColumnDescriptorList cdl = td.getColumnDescriptorList();
        for (ColumnDescriptor cd : cdl) {
            if (cd.isAutoincrement()) {
                createIdentitySequence(td, cd, tc);
            }
        }
    }
}
Also used : ColumnDescriptorList(org.apache.derby.iapi.sql.dictionary.ColumnDescriptorList) ColumnDescriptor(org.apache.derby.iapi.sql.dictionary.ColumnDescriptor) UUID(org.apache.derby.catalog.UUID) TableDescriptor(org.apache.derby.iapi.sql.dictionary.TableDescriptor)

Example 87 with UUID

use of org.apache.derby.catalog.UUID in project derby by apache.

the class DataDictionaryImpl method grantPublicAccessToSystemRoutine.

/**
 * Grant PUBLIC access to a system routine. This method should be used only
 * for granting access to a system routine (other than routines in SYSFUN
 * schema). It expects the routine to be present in SYSALIASES catalog.
 *
 * @param schemaID	Schema ID
 * @param routineName	Routine Name
 * @param nameSpace	Indicates whether the routine is a function/procedure.
 * @param tc	TransactionController to use
 * @param authorizationID	authorization ID of the permission grantor
 * @throws StandardException	Standard exception policy.
 */
private void grantPublicAccessToSystemRoutine(String schemaID, String routineName, char nameSpace, TransactionController tc, String authorizationID) throws StandardException {
    // For system routines, a valid alias descriptor will be returned.
    AliasDescriptor ad = getAliasDescriptor(schemaID, routineName, nameSpace);
    // 
    if (ad == null) {
        return;
    }
    UUID routineUUID = ad.getUUID();
    createRoutinePermPublicDescriptor(routineUUID, tc, authorizationID);
}
Also used : AliasDescriptor(org.apache.derby.iapi.sql.dictionary.AliasDescriptor) UUID(org.apache.derby.catalog.UUID)

Example 88 with UUID

use of org.apache.derby.catalog.UUID in project derby by apache.

the class DataDictionaryImpl method getTableDescriptor.

/**
 * 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.)
 *
 * @param tableName	The name of the table to get the descriptor for
 * @param schema	The descriptor for the schema the table lives in.
 *			If null, use the system schema.
 * @return	The descriptor for the table, null if table does not
 *		exist.
 *
 * @exception StandardException		Thrown on failure
 */
public TableDescriptor getTableDescriptor(String tableName, SchemaDescriptor schema, TransactionController tc) throws StandardException {
    TableDescriptor retval = null;
    /*
		** If we didn't get a schema descriptor, we had better
		** have a system table.
		*/
    if (SanityManager.DEBUG) {
        if ((schema == null) && !tableName.startsWith("SYS")) {
            SanityManager.THROWASSERT("null schema for non system table " + tableName);
        }
    }
    SchemaDescriptor sd = (schema == null) ? getSystemSchemaDescriptor() : schema;
    UUID schemaUUID = sd.getUUID();
    if (SchemaDescriptor.STD_SYSTEM_DIAG_SCHEMA_NAME.equals(sd.getSchemaName())) {
        TableDescriptor td = new TableDescriptor(this, tableName, sd, TableDescriptor.VTI_TYPE, TableDescriptor.DEFAULT_LOCK_GRANULARITY);
        // ensure a vti class exists
        if (getVTIClass(td, false) != null)
            return td;
    // otherwise just standard search
    }
    TableKey tableKey = new TableKey(schemaUUID, tableName);
    /* Only use the cache if we're in compile-only mode */
    if (getCacheMode() == DataDictionary.COMPILE_ONLY_MODE) {
        NameTDCacheable cacheEntry = (NameTDCacheable) nameTdCache.find(tableKey);
        if (cacheEntry != null) {
            retval = cacheEntry.getTableDescriptor();
            // bind in previous command might have set refernced cols
            retval.setReferencedColumnMap(null);
            nameTdCache.release(cacheEntry);
        }
        return retval;
    }
    return getTableDescriptorIndex1Scan(tableName, schemaUUID.toString());
}
Also used : SchemaDescriptor(org.apache.derby.iapi.sql.dictionary.SchemaDescriptor) UUID(org.apache.derby.catalog.UUID) TableDescriptor(org.apache.derby.iapi.sql.dictionary.TableDescriptor)

Example 89 with UUID

use of org.apache.derby.catalog.UUID in project derby by apache.

the class DataDictionaryImpl method hashAllTableDescriptorsByTableId.

/**
 * 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 and
 * SYS.SYSSCHEMAS at READ UNCOMMITTED.
 *
 * @param tc		TransactionController for the transaction
 *
 * @return	A Hashtable with all of the Table descriptors in the database
 *			hashed by TableId
 *
 * @exception StandardException		Thrown on failure
 */
@SuppressWarnings("UseOfObsoleteCollectionType")
public Hashtable<UUID, TableDescriptor> hashAllTableDescriptorsByTableId(TransactionController tc) throws StandardException {
    Hashtable<UUID, TableDescriptor> ht = new Hashtable<UUID, TableDescriptor>();
    ScanController scanController;
    ExecRow outRow;
    TabInfoImpl ti = coreInfo[SYSTABLES_CORE_NUM];
    SYSTABLESRowFactory rf = (SYSTABLESRowFactory) ti.getCatalogRowFactory();
    outRow = rf.makeEmptyRow();
    scanController = tc.openScan(// sys.systable
    ti.getHeapConglomerate(), // don't hold open across commit
    false, // for read
    0, // scans whole table.
    TransactionController.MODE_RECORD, TransactionController.ISOLATION_READ_UNCOMMITTED, // all fields as objects
    (FormatableBitSet) null, // start position - first row
    (DataValueDescriptor[]) null, // startSearchOperation
    ScanController.GE, // scanQualifier,
    (ScanQualifier[][]) null, // stop position-through last row
    (DataValueDescriptor[]) null, // stopSearchOperation
    ScanController.GT);
    // fetch() may find the row deleted or purged from the table.
    while (scanController.fetchNext(outRow.getRowArray())) {
        TableDescriptor td = (TableDescriptor) rf.buildDescriptor(outRow, (TupleDescriptor) null, this, TransactionController.ISOLATION_READ_UNCOMMITTED);
        ht.put(td.getUUID(), td);
    }
    scanController.close();
    return ht;
}
Also used : ScanController(org.apache.derby.iapi.store.access.ScanController) Hashtable(java.util.Hashtable) TupleDescriptor(org.apache.derby.iapi.sql.dictionary.TupleDescriptor) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) ScanQualifier(org.apache.derby.iapi.sql.execute.ScanQualifier) FormatableBitSet(org.apache.derby.iapi.services.io.FormatableBitSet) UUID(org.apache.derby.catalog.UUID) TableDescriptor(org.apache.derby.iapi.sql.dictionary.TableDescriptor)

Example 90 with UUID

use of org.apache.derby.catalog.UUID in project derby by apache.

the class DataDictionaryImpl method upgradeSYSROUTINEPERMS_10_6.

/**
 * 10.6 upgrade logic to update the permissions granted to SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE.
 * If a 10.0 database was upgraded to 10.2, 10.3, or 10.4, then there will
 * be an extra permissions tuple in SYSROUTINEPERMS--that tuple will have a
 * null grantor field. We must delete this tuple. See DERBY-4215.
 */
void upgradeSYSROUTINEPERMS_10_6(TransactionController tc) throws StandardException {
    // 
    // Get the aliasID of SYSCS_INPLACE_COMPRESS_TABLE
    // 
    TabInfoImpl aliasTI = getNonCoreTI(SYSALIASES_CATALOG_NUM);
    ExecIndexRow aliasKeyRow = exFactory.getIndexableRow(3);
    DataValueDescriptor aliasNameOrderable = new SQLVarchar("SYSCS_INPLACE_COMPRESS_TABLE");
    ;
    DataValueDescriptor nameSpaceOrderable = new SQLChar(new String(new char[] { AliasInfo.ALIAS_TYPE_PROCEDURE_AS_CHAR }));
    aliasKeyRow.setColumn(1, new SQLChar(SchemaDescriptor.SYSCS_UTIL_SCHEMA_UUID));
    aliasKeyRow.setColumn(2, aliasNameOrderable);
    aliasKeyRow.setColumn(3, nameSpaceOrderable);
    AliasDescriptor oldAD = getDescriptorViaIndex(SYSALIASESRowFactory.SYSALIASES_INDEX1_ID, aliasKeyRow, (ScanQualifier[][]) null, aliasTI, (TupleDescriptor) null, (List<TupleDescriptor>) null, AliasDescriptor.class, true, TransactionController.ISOLATION_REPEATABLE_READ, tc);
    UUID aliasID = oldAD.getUUID();
    // 
    // Now delete the permissions tuple which has a null grantor
    // 
    TabInfoImpl rpTI = getNonCoreTI(SYSROUTINEPERMS_CATALOG_NUM);
    ExecIndexRow rpKeyRow = exFactory.getIndexableRow(3);
    rpKeyRow.setColumn(1, new SQLVarchar("PUBLIC"));
    rpKeyRow.setColumn(2, new SQLChar(aliasID.toString()));
    rpKeyRow.setColumn(3, new SQLVarchar((String) null));
    int deleteCount = rpTI.deleteRow(tc, rpKeyRow, SYSROUTINEPERMSRowFactory.GRANTEE_ALIAS_GRANTOR_INDEX_NUM);
}
Also used : TupleDescriptor(org.apache.derby.iapi.sql.dictionary.TupleDescriptor) SQLChar(org.apache.derby.iapi.types.SQLChar) AliasDescriptor(org.apache.derby.iapi.sql.dictionary.AliasDescriptor) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) UUID(org.apache.derby.catalog.UUID) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow) SQLLongint(org.apache.derby.iapi.types.SQLLongint)

Aggregations

UUID (org.apache.derby.catalog.UUID)101 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)31 DataDescriptorGenerator (org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator)23 TableDescriptor (org.apache.derby.iapi.sql.dictionary.TableDescriptor)22 SchemaDescriptor (org.apache.derby.iapi.sql.dictionary.SchemaDescriptor)21 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)19 ColumnDescriptor (org.apache.derby.iapi.sql.dictionary.ColumnDescriptor)15 DataDictionary (org.apache.derby.iapi.sql.dictionary.DataDictionary)15 SQLChar (org.apache.derby.iapi.types.SQLChar)15 LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)14 TransactionController (org.apache.derby.iapi.store.access.TransactionController)14 ConglomerateDescriptor (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)12 SQLVarchar (org.apache.derby.iapi.types.SQLVarchar)12 DependencyManager (org.apache.derby.iapi.sql.depend.DependencyManager)11 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)10 ColumnDescriptorList (org.apache.derby.iapi.sql.dictionary.ColumnDescriptorList)10 ConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor)10 ArrayList (java.util.ArrayList)9 DataTypeDescriptor (org.apache.derby.iapi.types.DataTypeDescriptor)9 ExecIndexRow (org.apache.derby.iapi.sql.execute.ExecIndexRow)8