Search in sources :

Example 36 with DataValueDescriptor

use of org.apache.derby.iapi.types.DataValueDescriptor in project derby by apache.

the class DataDictionaryImpl method getConglomerateDescriptor.

/**
 * 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.
 *
 * @param indexName	The name of the index we're looking for
 * @param sd		The schema descriptor
 * @param forUpdate	Whether or not to get an exclusive row
 *					lock on the row in sys.sysconglomerates.
 *
 * @return	A ConglomerateDescriptor describing the requested
 *		conglomerate. Returns NULL if no such conglomerate.
 *
 * @exception StandardException		Thrown on failure
 */
public ConglomerateDescriptor getConglomerateDescriptor(String indexName, SchemaDescriptor sd, boolean forUpdate) throws StandardException {
    ExecIndexRow keyRow2 = null;
    DataValueDescriptor nameOrderable;
    DataValueDescriptor schemaIDOrderable = null;
    TabInfoImpl ti = coreInfo[SYSCONGLOMERATES_CORE_NUM];
    nameOrderable = new SQLVarchar(indexName);
    schemaIDOrderable = getIDValueAsCHAR(sd.getUUID());
    /* Set up the start/stop position for the scan */
    keyRow2 = exFactory.getIndexableRow(2);
    keyRow2.setColumn(1, nameOrderable);
    keyRow2.setColumn(2, schemaIDOrderable);
    return getDescriptorViaIndex(SYSCONGLOMERATESRowFactory.SYSCONGLOMERATES_INDEX2_ID, keyRow2, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, ConglomerateDescriptor.class, forUpdate);
}
Also used : TupleDescriptor(org.apache.derby.iapi.sql.dictionary.TupleDescriptor) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Example 37 with DataValueDescriptor

use of org.apache.derby.iapi.types.DataValueDescriptor in project derby by apache.

the class DataDictionaryImpl method dropAllRoutinePermDescriptors.

/**
 * Drops all routine permission descriptors for the given routine.
 *
 * @param routineID	The UUID of the routine from which to drop
 *			all the permission descriptors
 * @param tc		TransactionController for the transaction
 *
 * @exception StandardException		Thrown on error
 */
public void dropAllRoutinePermDescriptors(UUID routineID, TransactionController tc) throws StandardException {
    TabInfoImpl ti = getNonCoreTI(SYSROUTINEPERMS_CATALOG_NUM);
    SYSROUTINEPERMSRowFactory rf = (SYSROUTINEPERMSRowFactory) ti.getCatalogRowFactory();
    DataValueDescriptor routineIdOrderable;
    ExecRow curRow;
    PermissionsDescriptor perm;
    // In Derby authorization mode, permission catalogs may not be present
    if (!usesSqlAuthorization)
        return;
    /* Use tableIDOrderable in both start and stop position for scan. */
    routineIdOrderable = getIDValueAsCHAR(routineID);
    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow = exFactory.getIndexableRow(1);
    keyRow.setColumn(1, routineIdOrderable);
    while ((curRow = ti.getRow(tc, keyRow, rf.ALIASID_INDEX_NUM)) != null) {
        perm = (PermissionsDescriptor) rf.buildDescriptor(curRow, (TupleDescriptor) null, this);
        removePermEntryInCache(perm);
        // Build new key based on UUID and drop the entry as we want to drop
        // only this row
        ExecIndexRow uuidKey;
        uuidKey = rf.buildIndexKeyRow(rf.ROUTINEPERMSID_INDEX_NUM, perm);
        ti.deleteRow(tc, uuidKey, rf.ROUTINEPERMSID_INDEX_NUM);
    }
}
Also used : PermissionsDescriptor(org.apache.derby.iapi.sql.dictionary.PermissionsDescriptor) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Example 38 with DataValueDescriptor

use of org.apache.derby.iapi.types.DataValueDescriptor in project derby by apache.

the class DataDictionaryImpl method getColumnDescriptorByDefaultId.

/**
 * Drop all table descriptors for a schema.
 *
 * @param schema	A descriptor for the schema to drop the tables
 *			from.
 *
 * @return  Nothing.
 *
 * @exception StandardException		Thrown on failure
 */
/*
	public void dropAllTableDescriptors(SchemaDescriptor schema)
						throws StandardException
	{
		if (SanityManager.DEBUG) SanityManager.NOTREACHED();
	}
	*/
/**
 * Get a ColumnDescriptor given its Default ID.
 *
 * @param uuid	The UUID of the default
 *
 * @return The ColumnDescriptor for the column.
 *
 * @exception StandardException		Thrown on failure
 */
public ColumnDescriptor getColumnDescriptorByDefaultId(UUID uuid) throws StandardException {
    DataValueDescriptor UUIDStringOrderable;
    TabInfoImpl ti = coreInfo[SYSCOLUMNS_CORE_NUM];
    /* Use UUIDStringOrderable in both start and stop positions for scan */
    UUIDStringOrderable = getIDValueAsCHAR(uuid);
    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow = exFactory.getIndexableRow(1);
    keyRow.setColumn(1, UUIDStringOrderable);
    return getDescriptorViaIndex(SYSCOLUMNSRowFactory.SYSCOLUMNS_INDEX2_ID, keyRow, (ScanQualifier[][]) null, ti, (DefaultDescriptor) null, (List<TupleDescriptor>) null, ColumnDescriptor.class, false);
}
Also used : TupleDescriptor(org.apache.derby.iapi.sql.dictionary.TupleDescriptor) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Example 39 with DataValueDescriptor

use of org.apache.derby.iapi.types.DataValueDescriptor in project derby by apache.

the class DataDictionaryImpl method dropDependentsStoredDependencies.

/**
 * @inheritDoc
 */
public void dropDependentsStoredDependencies(UUID dependentsUUID, TransactionController tc, boolean wait) throws StandardException {
    ExecIndexRow keyRow1 = null;
    DataValueDescriptor dependentIDOrderable;
    TabInfoImpl ti = getNonCoreTI(SYSDEPENDS_CATALOG_NUM);
    /* Use dependentIDOrderable in both start 
		 * and stop position for index 1 scan. 
		 */
    dependentIDOrderable = getIDValueAsCHAR(dependentsUUID);
    /* Set up the start/stop position for the scan */
    keyRow1 = (ExecIndexRow) exFactory.getIndexableRow(1);
    keyRow1.setColumn(1, dependentIDOrderable);
    ti.deleteRow(tc, keyRow1, SYSDEPENDSRowFactory.SYSDEPENDS_INDEX1_ID, wait);
}
Also used : DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Example 40 with DataValueDescriptor

use of org.apache.derby.iapi.types.DataValueDescriptor in project derby by apache.

the class DataDictionaryImpl method clearSPSPlans.

/**
 * 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.
 * @exception StandardException		Thrown on error
 */
void clearSPSPlans() throws StandardException {
    TabInfoImpl ti = getNonCoreTI(SYSSTATEMENTS_CATALOG_NUM);
    faultInTabInfo(ti);
    TransactionController tc = getTransactionExecute();
    FormatableBitSet columnToReadSet = new FormatableBitSet(SYSSTATEMENTSRowFactory.SYSSTATEMENTS_COLUMN_COUNT);
    FormatableBitSet columnToUpdateSet = new FormatableBitSet(SYSSTATEMENTSRowFactory.SYSSTATEMENTS_COLUMN_COUNT);
    columnToUpdateSet.set(SYSSTATEMENTSRowFactory.SYSSTATEMENTS_VALID - 1);
    columnToUpdateSet.set(SYSSTATEMENTSRowFactory.SYSSTATEMENTS_CONSTANTSTATE - 1);
    DataValueDescriptor[] replaceRow = new DataValueDescriptor[SYSSTATEMENTSRowFactory.SYSSTATEMENTS_COLUMN_COUNT];
    /* Set up a couple of row templates for fetching CHARS */
    replaceRow[SYSSTATEMENTSRowFactory.SYSSTATEMENTS_VALID - 1] = new SQLBoolean(false);
    replaceRow[SYSSTATEMENTSRowFactory.SYSSTATEMENTS_CONSTANTSTATE - 1] = new UserType((Object) null);
    /* Scan the entire heap */
    ScanController sc = tc.openScan(ti.getHeapConglomerate(), false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_TABLE, TransactionController.ISOLATION_REPEATABLE_READ, columnToReadSet, (DataValueDescriptor[]) null, ScanController.NA, (Qualifier[][]) null, (DataValueDescriptor[]) null, ScanController.NA);
    while (sc.fetchNext((DataValueDescriptor[]) null)) {
        /* Replace the column in the table */
        sc.replace(replaceRow, columnToUpdateSet);
    }
    sc.close();
}
Also used : ScanController(org.apache.derby.iapi.store.access.ScanController) FormatableBitSet(org.apache.derby.iapi.services.io.FormatableBitSet) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) TransactionController(org.apache.derby.iapi.store.access.TransactionController) UserType(org.apache.derby.iapi.types.UserType) SQLBoolean(org.apache.derby.iapi.types.SQLBoolean)

Aggregations

DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)328 ExecIndexRow (org.apache.derby.iapi.sql.execute.ExecIndexRow)72 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)62 RowLocation (org.apache.derby.iapi.types.RowLocation)54 SQLLongint (org.apache.derby.iapi.types.SQLLongint)51 StandardException (org.apache.derby.shared.common.error.StandardException)43 SQLChar (org.apache.derby.iapi.types.SQLChar)42 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)36 SQLVarchar (org.apache.derby.iapi.types.SQLVarchar)36 ScanController (org.apache.derby.iapi.store.access.ScanController)35 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)32 UUID (org.apache.derby.catalog.UUID)31 TupleDescriptor (org.apache.derby.iapi.sql.dictionary.TupleDescriptor)24 RawTransaction (org.apache.derby.iapi.store.raw.xact.RawTransaction)16 DataDescriptorGenerator (org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator)15 RawContainerHandle (org.apache.derby.iapi.store.raw.data.RawContainerHandle)15 DataTypeDescriptor (org.apache.derby.iapi.types.DataTypeDescriptor)15 Properties (java.util.Properties)14 UserType (org.apache.derby.iapi.types.UserType)13 Page (org.apache.derby.iapi.store.raw.Page)11