List list,
boolean forUpdate)
throws StandardException
{
CatalogRowFactory rf = ti.getCatalogRowFactory();
ConglomerateController heapCC;
ExecIndexRow indexRow1;
ExecIndexRow indexTemplateRow;
ExecRow outRow;
RowLocation baseRowLocation;
ScanController scanController;
TransactionController tc;
TupleDescriptor td = null;
// Get the current transaction controller
tc = getTransactionCompile();
outRow = rf.makeEmptyRow();
heapCC = tc.openConglomerate(
ti.getHeapConglomerate(), false, 0,
TransactionController.MODE_RECORD,
TransactionController.ISOLATION_REPEATABLE_READ);
/* Scan the index and go to the data pages for qualifying rows to
* build the column descriptor.
*/
scanController = tc.openScan(
ti.getIndexConglomerate(indexId), // conglomerate to open
false, // don't hold open across commit
(forUpdate) ? TransactionController.OPENMODE_FORUPDATE : 0,
TransactionController.MODE_RECORD,
TransactionController.ISOLATION_REPEATABLE_READ,
(FormatableBitSet) null, // all fields as objects
keyRow.getRowArray(), // start position - first row
ScanController.GE, // startSearchOperation
scanQualifiers, //scanQualifier,
keyRow.getRowArray(), // stop position - through last row
ScanController.GT); // stopSearchOperation
while (scanController.next())
{
// create an index row template
indexRow1 = getIndexRowFromHeapRow(
ti.getIndexRowGenerator(indexId),
heapCC.newRowLocationTemplate(),
outRow);
scanController.fetch(indexRow1.getRowArray());
baseRowLocation = (RowLocation) indexRow1.getColumn(
indexRow1.nColumns());
// RESOLVE paulat - remove the try catch block when track 3677 is fixed
// just leave the contents of the try block
// adding to get more info on track 3677
boolean base_row_exists = false;
try
{
base_row_exists =
heapCC.fetch(
baseRowLocation, outRow.getRowArray(), (FormatableBitSet) null);
}
catch (RuntimeException re)
{
if (SanityManager.DEBUG)
{
if (re instanceof AssertFailure)
{
StringBuffer strbuf = new StringBuffer("Error retrieving base row in table "+ti.getTableName());
strbuf.append(": An ASSERT was thrown when trying to locate a row matching index row "+indexRow1+" from index "+ti.getIndexName(indexId)+", conglom number "+ti.getIndexConglomerate(indexId));
debugGenerateInfo(strbuf,tc,heapCC,ti,indexId);
}
}
throw re;
}
catch (StandardException se)
{
if (SanityManager.DEBUG)
{
// only look for a specific error i.e. that of record on page
// no longer exists
// do not want to catch lock timeout errors here
if (se.getSQLState().equals("XSRS9"))
{
StringBuffer strbuf = new StringBuffer("Error retrieving base row in table "+ti.getTableName());
strbuf.append(": A StandardException was thrown when trying to locate a row matching index row "+indexRow1+" from index "+ti.getIndexName(indexId)+", conglom number "+ti.getIndexConglomerate(indexId));
debugGenerateInfo(strbuf,tc,heapCC,ti,indexId);
}
}
throw se;
}
if (SanityManager.DEBUG)
{
// it can not be possible for heap row to disappear while
// holding scan cursor on index at ISOLATION_REPEATABLE_READ.
if (! base_row_exists)
{
StringBuffer strbuf = new StringBuffer("Error retrieving base row in table "+ti.getTableName());
strbuf.append(": could not locate a row matching index row "+indexRow1+" from index "+ti.getIndexName(indexId)+", conglom number "+ti.getIndexConglomerate(indexId));
debugGenerateInfo(strbuf,tc,heapCC,ti,indexId);
// RESOLVE: for now, we are going to kill the VM
// to help debug this problem.
System.exit(1);
// RESOLVE: not currently reached
//SanityManager.THROWASSERT(strbuf.toString());
}
}
td = rf.buildDescriptor(outRow, parentTupleDescriptor, this);
/* If list is null, then caller only wants a single descriptor - we're done
* else just add the current descriptor to the list.
*/
if (list == null)
{
break;
}
else
{
list.add(td);
}
}
scanController.close();
heapCC.close();
return td;
}