private TableDescriptor cleanupTempTableOnCommitOrRollback(
TableDescriptor td,
boolean dropAndRedeclare)
throws StandardException
{
TransactionController tc = getTransactionExecute();
//create new conglomerate with same properties as the old conglomerate
//and same row template as the old conglomerate
long conglomId =
tc.createConglomerate(
"heap", // we're requesting a heap conglomerate
td.getEmptyExecRow().getRowArray(), // row template
null, //column sort order - not required for heap
td.getColumnCollationIds(), // same ids as old conglomerate
null, // properties
(TransactionController.IS_TEMPORARY |
TransactionController.IS_KEPT));
long cid = td.getHeapConglomerateId();
//remove the old conglomerate descriptor from the table descriptor
ConglomerateDescriptor cgd = td.getConglomerateDescriptor(cid);
td.getConglomerateDescriptorList().dropConglomerateDescriptorByUUID(
cgd.getUUID());
//add the new conglomerate descriptor to the table descriptor
cgd = getDataDictionary().getDataDescriptorGenerator().newConglomerateDescriptor(conglomId, null, false, null, false, null, td.getUUID(),
td.getSchemaDescriptor().getUUID());
ConglomerateDescriptorList conglomList =
td.getConglomerateDescriptorList();
conglomList.add(cgd);
//reset the heap conglomerate number in table descriptor to -1 so it
//will be refetched next time with the new value
td.resetHeapConglomNumber();
if (dropAndRedeclare)
{
//remove the old conglomerate from the system
tc.dropConglomerate(cid);
replaceDeclaredGlobalTempTable(td.getName(), td);
}
return(td);