Program: 51323
Project: 51323
Buggy source:
/** 
 * Generates a SQL query to retrieve a cell value for an evaluation context where some of the dimensions have more than one member. <p>Returns null if the request is unsatisfiable. This would happen, say, if one of the members is null.
 * @param evaluator Provides evaluation context
 * @param aggregationLists List of aggregations, each of which is a setof members in the same hierarchy which need to be summed together.
 * @return SQL query, or null if request is unsatisfiable
 */
public static String generateMultiSql(RolapEvaluator evaluator,List<List<RolapMember>> aggregationLists){
  final RolapCube cube=(RolapCube)evaluator.getCube();
  final Map<RolapLevel,RolapStar.Column> levelToColumnMap=cube.getStar().getLevelToColumnMap(cube);
  CellRequest request=makeRequest(evaluator.getMembers());
  int[] groupOrdinals={0,0,0};
  for (  List<RolapMember> aggregationList : aggregationLists) {
    int k=0;
    boolean compound=false;
    final RolapLevel level0=aggregationList.get(0).getLevel();
    for (    RolapMember member : aggregationList) {
      if (k++ > 0) {
        RolapLevel level=member.getLevel();
        if (level != level0) {
          compound=true;
          if (level.getHierarchy() != level0.getHierarchy()) {
            throw Util.newInternal("String_Node_Str");
          }
        }
      }
    }
    for (    RolapMember member : aggregationList) {
      final boolean unsatisfiable=member.getLevel().getLevelReader().constrainRequest(member,levelToColumnMap,request,groupOrdinals);
      if (unsatisfiable) {
        return null;
      }
      ++groupOrdinals[1];
      Arrays.fill(groupOrdinals,2,groupOrdinals.length,0);
    }
    ++groupOrdinals[0];
    Arrays.fill(groupOrdinals,1,groupOrdinals.length,0);
  }
  return CompoundQuerySpec.compoundGenerateSql(request.getMeasure(),request.getConstrainedColumns(),request.getValueList(),request.getPredicateList());
}

Fixed version (ground truth):
/** 
 * Generates a SQL query to retrieve a cell value for an evaluation context where some of the dimensions have more than one member. <p>Returns null if the request is unsatisfiable. This would happen, say, if one of the members is null.
 * @param evaluator Provides evaluation context
 * @param aggregationLists List of aggregations, each of which is a setof members in the same hierarchy which need to be summed together.
 * @return SQL query, or null if request is unsatisfiable
 */
public static String generateMultiSql(RolapEvaluator evaluator,List<List<RolapMember>> aggregationLists){
  final RolapCube cube=evaluator.getMeasureCube();
  final Map<RolapLevel,RolapStar.Column> levelToColumnMap=cube.getStar().getLevelToColumnMap(cube);
  CellRequest request=makeRequest(evaluator.getMembers());
  int[] groupOrdinals={0,0,0};
  for (  List<RolapMember> aggregationList : aggregationLists) {
    int k=0;
    boolean compound=false;
    final RolapLevel level0=aggregationList.get(0).getLevel();
    for (    RolapMember member : aggregationList) {
      if (k++ > 0) {
        RolapLevel level=member.getLevel();
        if (level != level0) {
          compound=true;
          if (level.getHierarchy() != level0.getHierarchy()) {
            throw Util.newInternal("String_Node_Str");
          }
        }
      }
    }
    int unsatisfiableCount=0;
    for (    RolapMember member : aggregationList) {
      final boolean unsatisfiable=member.getLevel().getLevelReader().constrainRequest(member,levelToColumnMap,request,groupOrdinals);
      if (unsatisfiable) {
        ++unsatisfiableCount;
      }
      ++groupOrdinals[1];
      Arrays.fill(groupOrdinals,2,groupOrdinals.length,0);
    }
    if (unsatisfiableCount == aggregationList.size()) {
      return null;
    }
    ++groupOrdinals[0];
    Arrays.fill(groupOrdinals,1,groupOrdinals.length,0);
  }
  return CompoundQuerySpec.compoundGenerateSql(request.getMeasure(),request.getConstrainedColumns(),request.getValueList(),request.getPredicateList());
}