Search in sources :

Example 86 with ExecIndexRow

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

the class DataDictionaryImpl method getConglomerateDescriptors.

/**
 * Get an array of ConglomerateDescriptors given the UUID.  If it is a
 * heap conglomerate or an index conglomerate not shared by a duplicate
 * index, the size of the return array is 1. If the uuid argument is null, then
 * this method retrieves descriptors for all of the conglomerates in the database.
 *
 * @param uuid	The UUID
 *
 * @return An array of ConglomerateDescriptors for the conglomerate.
 *				returns size 0 array if no such conglomerate.
 *
 * @exception StandardException		Thrown on failure
 */
public ConglomerateDescriptor[] getConglomerateDescriptors(UUID uuid) throws StandardException {
    DataValueDescriptor UUIDStringOrderable;
    TabInfoImpl ti = coreInfo[SYSCONGLOMERATES_CORE_NUM];
    List<ConglomerateDescriptor> cdl = newSList();
    if (uuid != null) {
        /* 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);
        getDescriptorViaIndex(SYSCONGLOMERATESRowFactory.SYSCONGLOMERATES_INDEX1_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, cdl, ConglomerateDescriptor.class, false);
    } else {
        getDescriptorViaHeap(null, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, cdl, ConglomerateDescriptor.class);
    }
    return cdl.toArray(new ConglomerateDescriptor[cdl.size()]);
}
Also used : DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) ConglomerateDescriptor(org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Example 87 with ExecIndexRow

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

the class DataDictionaryImpl method getConstraintDescriptor.

/**
 * Get a ConstraintDescriptor given its name and schema ID.
 * Please use getConstraintDescriptorByName() if you have the
 * constraint's table descriptor, it is much faster.
 *
 * @param constraintName	Constraint name.
 * @param schemaID			The schema UUID
 *
 * @return The ConstraintDescriptor for the constraint.
 *
 * @exception StandardException		Thrown on failure
 */
public ConstraintDescriptor getConstraintDescriptor(String constraintName, UUID schemaID) throws StandardException {
    DataValueDescriptor UUIDStringOrderable;
    DataValueDescriptor constraintNameOrderable;
    TabInfoImpl ti = getNonCoreTI(SYSCONSTRAINTS_CATALOG_NUM);
    /* Construct keys for both start and stop positions for scan */
    constraintNameOrderable = new SQLVarchar(constraintName);
    UUIDStringOrderable = getIDValueAsCHAR(schemaID);
    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow = exFactory.getIndexableRow(2);
    keyRow.setColumn(1, constraintNameOrderable);
    keyRow.setColumn(2, UUIDStringOrderable);
    return getConstraintDescriptorViaIndex(SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_INDEX2_ID, keyRow, ti, (TableDescriptor) null, (ConstraintDescriptorList) null, false);
}
Also used : DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Example 88 with ExecIndexRow

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

the class DataDictionaryImpl method getForeignKeys.

/**
 * Return a list of foreign keys constraints referencing
 * this constraint.  Returns both enforced and not enforced
 * foreign keys.
 *
 * @param constraintId	The id of the referenced constraint
 *
 * @return	list of constraints, empty of there are none
 *
 * @exception StandardException		Thrown on error
 */
public ConstraintDescriptorList getForeignKeys(UUID constraintId) throws StandardException {
    TabInfoImpl ti = getNonCoreTI(SYSFOREIGNKEYS_CATALOG_NUM);
    List<SubKeyConstraintDescriptor> fkList = newSList();
    // Use constraintIDOrderable in both start and stop positions for scan
    DataValueDescriptor constraintIDOrderable = getIDValueAsCHAR(constraintId);
    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow = (ExecIndexRow) exFactory.getIndexableRow(1);
    keyRow.setColumn(1, constraintIDOrderable);
    getDescriptorViaIndex(SYSFOREIGNKEYSRowFactory.SYSFOREIGNKEYS_INDEX2_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, fkList, SubKeyConstraintDescriptor.class, false);
    TableDescriptor td;
    ConstraintDescriptorList cdl = new ConstraintDescriptorList();
    for (SubKeyConstraintDescriptor cd : fkList) {
        td = getConstraintTableDescriptor(cd.getUUID());
        cdl.add(getConstraintDescriptors(td).getConstraintDescriptorById(cd.getUUID()));
    }
    return cdl;
}
Also used : SubKeyConstraintDescriptor(org.apache.derby.iapi.sql.dictionary.SubKeyConstraintDescriptor) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) ConstraintDescriptorList(org.apache.derby.iapi.sql.dictionary.ConstraintDescriptorList) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow) TableDescriptor(org.apache.derby.iapi.sql.dictionary.TableDescriptor)

Example 89 with ExecIndexRow

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

the class DataDictionaryImpl method getProvidersDescriptorList.

/**
 * Gets a list of the dependency descriptors for the given provider's id.
 *
 * @param providerID		The ID of the provider we're interested in
 *
 * @return	List			Returns a list of DependencyDescriptors.
 *							Returns an empty List if no stored dependencies for the
 *							provider's ID.
 *
 * @exception StandardException		Thrown on failure
 */
public List<DependencyDescriptor> getProvidersDescriptorList(String providerID) throws StandardException {
    List<DependencyDescriptor> ddlList = newSList();
    DataValueDescriptor providerIDOrderable;
    TabInfoImpl ti = getNonCoreTI(SYSDEPENDS_CATALOG_NUM);
    /* Use providerIDOrderable in both start and stop positions for scan */
    providerIDOrderable = new SQLChar(providerID);
    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow = exFactory.getIndexableRow(1);
    keyRow.setColumn(1, providerIDOrderable);
    getDescriptorViaIndex(SYSDEPENDSRowFactory.SYSDEPENDS_INDEX2_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, ddlList, DependencyDescriptor.class, false);
    return ddlList;
}
Also used : DependencyDescriptor(org.apache.derby.iapi.sql.dictionary.DependencyDescriptor) SQLChar(org.apache.derby.iapi.types.SQLChar) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Example 90 with ExecIndexRow

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

the class DataDictionaryImpl method updateColumnDescriptor.

/**
 * Update the column descriptor in question.  Updates
 * every row in the base conglomerate.
 *
 * @param cd					The ColumnDescriptor
 * @param formerUUID			The UUID for this column in SYSCOLUMNS,
 *								may differ from what is in cd if this
 *								is the column that is being set.
 * @param formerName			The name for this column in SYSCOLUMNS
 *								may differ from what is in cd if this
 *								is the column that is being set.
 * @param colsToSet 			Array of ints of columns to be modified,
 *								1 based.  May be null (all cols).
 * @param tc					The TransactionController to use
 *
 * @exception StandardException		Thrown on failure
 */
private void updateColumnDescriptor(ColumnDescriptor cd, UUID formerUUID, String formerName, int[] colsToSet, TransactionController tc) throws StandardException {
    ExecIndexRow keyRow1 = null;
    ExecRow row;
    DataValueDescriptor refIDOrderable;
    DataValueDescriptor columnNameOrderable;
    TabInfoImpl ti = coreInfo[SYSCOLUMNS_CORE_NUM];
    SYSCOLUMNSRowFactory rf = (SYSCOLUMNSRowFactory) ti.getCatalogRowFactory();
    /* Use objectID/columnName in both start 
		 * and stop position for index 1 scan. 
		 */
    refIDOrderable = getIDValueAsCHAR(formerUUID);
    columnNameOrderable = new SQLVarchar(formerName);
    /* Set up the start/stop position for the scan */
    keyRow1 = (ExecIndexRow) exFactory.getIndexableRow(2);
    keyRow1.setColumn(1, refIDOrderable);
    keyRow1.setColumn(2, columnNameOrderable);
    // build the row to be stuffed into SYSCOLUMNS.
    row = rf.makeRow(cd, null);
    /*
		** Figure out if the index in syscolumns needs 
		** to be updated. 
		*/
    if (SanityManager.DEBUG) {
        SanityManager.ASSERT(rf.getNumIndexes() == 2, "There are more indexes on syscolumns than expected, the code herein needs to change");
    }
    boolean[] bArray = new boolean[rf.getNumIndexes()];
    /*
		** Do we need to update indexes?
		*/
    if (colsToSet == null) {
        bArray[0] = true;
        bArray[1] = true;
    } else {
        /*
			** Check the specific columns for indexed
			** columns.
			*/
        for (int i = 0; i < colsToSet.length; i++) {
            if ((colsToSet[i] == rf.SYSCOLUMNS_COLUMNNAME) || (colsToSet[i] == rf.SYSCOLUMNS_REFERENCEID)) {
                bArray[0] = true;
                break;
            } else if (colsToSet[i] == rf.SYSCOLUMNS_COLUMNDEFAULTID) {
                bArray[1] = true;
                break;
            }
        }
    }
    ti.updateRow(keyRow1, row, SYSCOLUMNSRowFactory.SYSCOLUMNS_INDEX1_ID, bArray, colsToSet, 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) SQLLongint(org.apache.derby.iapi.types.SQLLongint)

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