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()]);
}
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);
}
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;
}
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;
}
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);
}
Aggregations