Search in sources :

Example 1 with ExecIndexRow

use of org.apache.derby.iapi.sql.execute.ExecIndexRow in project derby by apache.

the class DataDictionaryImpl method getUUIDForCoreTable.

/**
 * 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.
 *
 * @param tableName		Name of the table
 * @param schemaUUID	UUID of schema
 * @param tc			TransactionController to user
 *
 * @return UUID	The UUID of the core table.
 *
 * @exception StandardException		Thrown on failure
 */
private UUID getUUIDForCoreTable(String tableName, String schemaUUID, TransactionController tc) throws StandardException {
    ConglomerateController heapCC;
    ExecRow row;
    DataValueDescriptor schemaIDOrderable;
    DataValueDescriptor tableNameOrderable;
    ScanController scanController;
    TabInfoImpl ti = coreInfo[SYSTABLES_CORE_NUM];
    SYSTABLESRowFactory rf = (SYSTABLESRowFactory) ti.getCatalogRowFactory();
    // We only want the 1st column from the heap
    row = exFactory.getValueRow(1);
    /* Use tableNameOrderable and schemaIdOrderable in both start 
		 * and stop position for scan. 
		 */
    tableNameOrderable = new SQLVarchar(tableName);
    schemaIDOrderable = new SQLChar(schemaUUID);
    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow = exFactory.getIndexableRow(2);
    keyRow.setColumn(1, tableNameOrderable);
    keyRow.setColumn(2, schemaIDOrderable);
    heapCC = tc.openConglomerate(ti.getHeapConglomerate(), false, 0, TransactionController.MODE_RECORD, TransactionController.ISOLATION_REPEATABLE_READ);
    ExecRow indexTemplateRow = rf.buildEmptyIndexRow(SYSTABLESRowFactory.SYSTABLES_INDEX1_ID, heapCC.newRowLocationTemplate());
    /* Scan the index and go to the data pages for qualifying rows to
		 * build the column descriptor.
		 */
    scanController = tc.openScan(// conglomerate to open
    ti.getIndexConglomerate(SYSTABLESRowFactory.SYSTABLES_INDEX1_ID), // don't hold open across commit
    false, 0, TransactionController.MODE_RECORD, TransactionController.ISOLATION_REPEATABLE_READ, // all fields as objects
    (FormatableBitSet) null, // start position - first row
    keyRow.getRowArray(), // startSearchOperation
    ScanController.GE, // scanQualifier,
    (ScanQualifier[][]) null, // stop position - through last row
    keyRow.getRowArray(), // stopSearchOperation
    ScanController.GT);
    /* OK to fetch into the template row, 
         * since we won't be doing a next.
         */
    if (scanController.fetchNext(indexTemplateRow.getRowArray())) {
        RowLocation baseRowLocation;
        baseRowLocation = (RowLocation) indexTemplateRow.getColumn(indexTemplateRow.nColumns());
        /* 1st column is TABLEID (UUID - char(36)) */
        row.setColumn(SYSTABLESRowFactory.SYSTABLES_TABLEID, new SQLChar());
        FormatableBitSet bi = new FormatableBitSet(1);
        bi.set(0);
        boolean base_row_exists = heapCC.fetch(baseRowLocation, row.getRowArray(), (FormatableBitSet) null);
        if (SanityManager.DEBUG) {
            // it can not be possible for heap row to disappear while
            // holding scan cursor on index at ISOLATION_REPEATABLE_READ.
            SanityManager.ASSERT(base_row_exists, "base row not found");
        }
    }
    scanController.close();
    heapCC.close();
    return uuidFactory.recreateUUID(row.getColumn(1).toString());
}
Also used : ScanController(org.apache.derby.iapi.store.access.ScanController) ConglomerateController(org.apache.derby.iapi.store.access.ConglomerateController) SQLChar(org.apache.derby.iapi.types.SQLChar) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) ScanQualifier(org.apache.derby.iapi.sql.execute.ScanQualifier) FormatableBitSet(org.apache.derby.iapi.services.io.FormatableBitSet) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) RowLocation(org.apache.derby.iapi.types.RowLocation)

Example 2 with ExecIndexRow

use of org.apache.derby.iapi.sql.execute.ExecIndexRow in project derby by apache.

the class DataDictionaryImpl method updateUser.

public void updateUser(UserDescriptor newDescriptor, TransactionController tc) throws StandardException {
    ExecIndexRow keyRow;
    TabInfoImpl ti = getNonCoreTI(SYSUSERS_CATALOG_NUM);
    /* Set up the start/stop position for the scan */
    keyRow = (ExecIndexRow) exFactory.getIndexableRow(1);
    keyRow.setColumn(1, new SQLVarchar(newDescriptor.getUserName()));
    // this zeroes out the password in the UserDescriptor
    ExecRow row = ti.getCatalogRowFactory().makeRow(newDescriptor, null);
    boolean[] bArray = { false };
    int[] colsToUpdate = { SYSUSERSRowFactory.HASHINGSCHEME_COL_NUM, SYSUSERSRowFactory.PASSWORD_COL_NUM, SYSUSERSRowFactory.LASTMODIFIED_COL_NUM };
    ti.updateRow(keyRow, row, SYSUSERSRowFactory.SYSUSERS_INDEX1_ID, bArray, colsToUpdate, tc);
}
Also used : ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Example 3 with ExecIndexRow

use of org.apache.derby.iapi.sql.execute.ExecIndexRow in project derby by apache.

the class DataDictionaryImpl method dropAllConglomerateDescriptors.

/**
 * Drops all conglomerates associated with a table.
 *
 * @param td		The TableDescriptor of the table
 * @param tc		TransactionController for the transaction
 *
 * @exception StandardException		Thrown on failure
 */
public void dropAllConglomerateDescriptors(TableDescriptor td, TransactionController tc) throws StandardException {
    ExecIndexRow keyRow3 = null;
    DataValueDescriptor tableIDOrderable;
    TabInfoImpl ti = coreInfo[SYSCONGLOMERATES_CORE_NUM];
    /* Use tableIDOrderable in both start 
		 * and stop position for index 3 scan. 
		 */
    tableIDOrderable = getIDValueAsCHAR(td.getUUID());
    /* Set up the start/stop position for the scan */
    keyRow3 = (ExecIndexRow) exFactory.getIndexableRow(1);
    keyRow3.setColumn(1, tableIDOrderable);
    ti.deleteRow(tc, keyRow3, SYSCONGLOMERATESRowFactory.SYSCONGLOMERATES_INDEX3_ID);
}
Also used : DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Example 4 with ExecIndexRow

use of org.apache.derby.iapi.sql.execute.ExecIndexRow in project derby by apache.

the class DataDictionaryImpl method locateSchemaRowBody.

private SchemaDescriptor locateSchemaRowBody(UUID schemaId, int isolationLevel, TransactionController tc) throws StandardException {
    DataValueDescriptor UUIDStringOrderable;
    TabInfoImpl ti = coreInfo[SYSSCHEMAS_CORE_NUM];
    /* Use UUIDStringOrderable in both start and stop positions for scan */
    UUIDStringOrderable = getIDValueAsCHAR(schemaId);
    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow = exFactory.getIndexableRow(1);
    keyRow.setColumn(1, UUIDStringOrderable);
    return getDescriptorViaIndex(SYSSCHEMASRowFactory.SYSSCHEMAS_INDEX2_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, SchemaDescriptor.class, false, isolationLevel, tc);
}
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 5 with ExecIndexRow

use of org.apache.derby.iapi.sql.execute.ExecIndexRow in project derby by apache.

the class DataDictionaryImpl method updateSchemaAuth.

/**
 * Update authorizationId of specified schemaName
 *
 * @param schemaName			Schema Name of system schema
 * @param authorizationId		authorizationId of new schema owner
 * @param tc					The TransactionController to use
 *
 * @exception StandardException		Thrown on failure
 */
public void updateSchemaAuth(String schemaName, String authorizationId, TransactionController tc) throws StandardException {
    ExecIndexRow keyRow;
    DataValueDescriptor schemaNameOrderable;
    TabInfoImpl ti = coreInfo[SYSSCHEMAS_CORE_NUM];
    /* Use schemaNameOrderable in both start 
		 * and stop position for index 1 scan. 
		 */
    schemaNameOrderable = new SQLVarchar(schemaName);
    /* Set up the start/stop position for the scan */
    keyRow = (ExecIndexRow) exFactory.getIndexableRow(1);
    keyRow.setColumn(1, schemaNameOrderable);
    SYSSCHEMASRowFactory rf = (SYSSCHEMASRowFactory) ti.getCatalogRowFactory();
    ExecRow row = rf.makeEmptyRow();
    row.setColumn(SYSSCHEMASRowFactory.SYSSCHEMAS_SCHEMAAID, new SQLVarchar(authorizationId));
    boolean[] bArray = { false, false };
    int[] colsToUpdate = { SYSSCHEMASRowFactory.SYSSCHEMAS_SCHEMAAID };
    ti.updateRow(keyRow, row, SYSSCHEMASRowFactory.SYSSCHEMAS_INDEX1_ID, bArray, colsToUpdate, tc);
}
Also used : ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Aggregations

ExecIndexRow (org.apache.derby.iapi.sql.execute.ExecIndexRow)110 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)72 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)34 SQLVarchar (org.apache.derby.iapi.types.SQLVarchar)30 TupleDescriptor (org.apache.derby.iapi.sql.dictionary.TupleDescriptor)27 SQLChar (org.apache.derby.iapi.types.SQLChar)22 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)14 SQLLongint (org.apache.derby.iapi.types.SQLLongint)13 RowLocation (org.apache.derby.iapi.types.RowLocation)12 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)10 ScanController (org.apache.derby.iapi.store.access.ScanController)9 UUID (org.apache.derby.catalog.UUID)8 ArrayList (java.util.ArrayList)7 ColumnDescriptorList (org.apache.derby.iapi.sql.dictionary.ColumnDescriptorList)6 ConglomerateDescriptorList (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptorList)6 ConstraintDescriptorList (org.apache.derby.iapi.sql.dictionary.ConstraintDescriptorList)6 TransactionController (org.apache.derby.iapi.store.access.TransactionController)6 Properties (java.util.Properties)5 PermissionsDescriptor (org.apache.derby.iapi.sql.dictionary.PermissionsDescriptor)5 TableDescriptor (org.apache.derby.iapi.sql.dictionary.TableDescriptor)5