try {
SchemaDescriptor sd =
data_dictionary.getSchemaDescriptor(
schemaName, nested_tc, true);
TableDescriptor td =
data_dictionary.getTableDescriptor(tableName, sd);
nested_tc =
tc.startNestedUserTransaction(false);
if (td == null)
{
throw StandardException.newException(
SQLState.LANG_TABLE_NOT_FOUND,
schemaName + "." + tableName);
}
switch (td.getTableType())
{
/* Skip views and vti tables */
case TableDescriptor.VIEW_TYPE:
case TableDescriptor.VTI_TYPE:
return;
// other types give various errors here
// DERBY-719,DERBY-720
default:
break;
}
ConglomerateDescriptor heapCD =
td.getConglomerateDescriptor(td.getHeapConglomerateId());
/* Get a row template for the base table */
ExecRow baseRow =
lcc.getLanguageConnectionFactory().getExecutionFactory().getValueRow(
td.getNumberOfColumns());
/* Fill the row with nulls of the correct type */
ColumnDescriptorList cdl = td.getColumnDescriptorList();
int cdlSize = cdl.size();
for (int index = 0; index < cdlSize; index++)
{
ColumnDescriptor cd = (ColumnDescriptor) cdl.elementAt(index);
baseRow.setColumn(cd.getPosition(), cd.getType().getNull());
}
DataValueDescriptor[][] row_array = new DataValueDescriptor[100][];
row_array[0] = baseRow.getRowArray();
RowLocation[] old_row_location_array = new RowLocation[100];
RowLocation[] new_row_location_array = new RowLocation[100];
// Create the following 3 arrays which will be used to update
// each index as the scan moves rows about the heap as part of
// the compress:
// index_col_map - map location of index cols in the base row,
// ie. index_col_map[0] is column offset of 1st
// key column in base row. All offsets are 0
// based.
// index_scan - open ScanController used to delete old index row
// index_cc - open ConglomerateController used to insert new
// row
ConglomerateDescriptor[] conglom_descriptors =
td.getConglomerateDescriptors();
// conglom_descriptors has an entry for the conglomerate and each
// one of it's indexes.
num_indexes = conglom_descriptors.length - 1;
// if indexes exist, set up data structures to update them
if (num_indexes > 0)
{
// allocate arrays
index_col_map = new int[num_indexes][];
index_scan = new ScanController[num_indexes];
index_cc = new ConglomerateController[num_indexes];
index_row = new DataValueDescriptor[num_indexes][];
setup_indexes(
nested_tc,
td,
index_col_map,
index_scan,
index_cc,
index_row);
}
/* Open the heap for reading */
base_group_fetch_cc =
nested_tc.defragmentConglomerate(
td.getHeapConglomerateId(),
false,
true,
TransactionController.OPENMODE_FORUPDATE,
TransactionController.MODE_TABLE,
TransactionController.ISOLATION_SERIALIZABLE);