Buggy code:
class AlterTableConstantAction extends DDLSingleTableConstantAction implements RowLocationRetRowSource { private SchemaDescriptor sd ; private String tableName ; private UUID schemaId ; private int tableType ; private ColumnInfo [ ] columnInfo ; private ConstraintConstantAction [ ] constraintActions ; private char lockGranularity ; private long tableConglomerateId ; private boolean compressTable ; private int behavior ; private boolean sequential ; private boolean truncateTable ; private boolean purge ; private boolean defragment ; private boolean truncateEndOfTable ; private boolean updateStatistics ; private boolean updateStatisticsAll ; private boolean dropStatistics ; private boolean dropStatisticsAll ; private String indexNameForStatistics ; private boolean doneScan ; private boolean [ ] needToDropSort ; private boolean [ ] validRow ; private int bulkFetchSize = 16 ; private int currentCompressRow ; private int numIndexes ; private int rowCount ; private long estimatedRowCount ; private long [ ] indexConglomerateNumbers ; private long [ ] sortIds ; private FormatableBitSet indexedCols ; private ConglomerateController compressHeapCC ; private ExecIndexRow [ ] indexRows ; private ExecRow [ ] baseRow ; private ExecRow currentRow ; private GroupFetchScanController compressHeapGSC ; private IndexRowGenerator [ ] compressIRGs ; private DataValueDescriptor [ ] [ ] baseRowArray ; private RowLocation [ ] compressRL ; private SortController [ ] sorters ; private int droppedColumnPosition ; private ColumnOrdering [ ] [ ] ordering ; private int [ ] [ ] collation ; private TableDescriptor td ; private LanguageConnectionContext lcc ; private DataDictionary dd ; private DependencyManager dm ; private TransactionController tc ; private Activation activation ; AlterTableConstantAction ( SchemaDescriptor sd , String tableName , UUID tableId , long tableConglomerateId , int tableType , ColumnInfo [ ] columnInfo , ConstraintConstantAction [ ] constraintActions , char lockGranularity , boolean compressTable , int behavior , boolean sequential , boolean truncateTable , boolean purge , boolean defragment , boolean truncateEndOfTable , boolean updateStatistics , boolean updateStatisticsAll , boolean dropStatistics , boolean dropStatisticsAll , String indexNameForStatistics ) { } public String toString ( ) { } public void executeConstantAction ( Activation activation ) throws StandardException { } private void executeConstantActionBody ( Activation activation ) throws StandardException { } private void clearState ( ) { } private void dropStatistics ( ) throws StandardException { } private void updateStatistics ( ) throws StandardException { } private void truncateEnd ( TransactionController tc ) throws StandardException { } private void defragmentRows ( TransactionController tc ) throws StandardException { GroupFetchScanController base_group_fetch_cc = null ; int num_indexes = 0 ; int [ ] [ ] index_col_map = null ; ScanController [ ] index_scan = null ; ConglomerateController [ ] index_cc = null ; DataValueDescriptor [ ] [ ] index_row = null ; TransactionController nested_tc = null ; try { <START_BUG> nested_tc = tc . startNestedUserTransaction ( false ) ; <END_BUG> switch ( td . getTableType ( ) ) { case TableDescriptor . VIEW_TYPE : case TableDescriptor . VTI_TYPE : return ; default : break ; } ExecRow baseRow = lcc . getLanguageConnectionFactory ( ) . getExecutionFactory ( ) . getValueRow ( td . getNumberOfColumns ( ) ) ; 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 ] ; ConglomerateDescriptor [ ] conglom_descriptors = td . getConglomerateDescriptors ( ) ; num_indexes = ( conglom_descriptors . length ) - 1 ; if ( num_indexes > 0 ) { 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 ] [ ] ; AlterTableConstantAction . setup_indexes ( nested_tc , td , index_col_map , index_scan , index_cc , index_row ) ; } base_group_fetch_cc = nested_tc . defragmentConglomerate ( td . getHeapConglomerateId ( ) , false , true , OPENMODE_FORUPDATE , MODE_TABLE , ISOLATION_SERIALIZABLE ) ; int num_rows_fetched = 0 ; while ( ( num_rows_fetched = base_group_fetch_cc . fetchNextGroup ( row_array , old_row_location_array , new_row_location_array ) ) != 0 ) { if ( num_indexes > 0 ) { for ( int row = 0 ; row < num_rows_fetched ; row ++ ) { for ( int index = 0 ; index < num_indexes ; index ++ ) { AlterTableConstantAction . fixIndex ( row_array [ row ] , index_row [ index ] , old_row_location_array [ row ] , new_row_location_array [ row ] , index_cc [ index ] , index_scan [ index ] , index_col_map [ index ] ) ; } } } } nested_tc . commit ( ) ; } finally { if ( base_group_fetch_cc != null ) { base_group_fetch_cc . close ( ) ; base_group_fetch_cc = null ; } if ( num_indexes > 0 ) { for ( int i = 0 ; i < num_indexes ; i ++ ) { if ( ( index_scan != null ) && ( ( index_scan [ i ] ) != null ) ) { index_scan [ i ] . close ( ) ; index_scan [ i ] = null ; } if ( ( index_cc != null ) && ( ( index_cc [ i ] ) != null ) ) { index_cc [ i ] . close ( ) ; index_cc [ i ] = null ; } } } if ( nested_tc != null ) { nested_tc . destroy ( ) ; } } return ; }

Fix:
nested_tc = tc . startNestedUserTransaction ( false , true ) ;