Program: 137698
Project: 137698
Buggy source:
public DataSet nextDataSet() throws SQLException {
  if (currentResultSet != null) {
    currentResultSet.close();
    currentResultSet=null;
  }
  if (state == State.CLOSED)   return null;
  if (state == State.PRIMARY_RESULTS) {
    currentResultSet=stmt.getResultSet();
    state=State.SECONDARY_RESULTS;
    if (currentResultSet != null)     return new DataSet(currentResultSet,null,maxRows);
  }
  while (state == State.SECONDARY_RESULTS) {
    if (!(stmt instanceof HivePreparedStatement) && stmt.getMoreResults())     currentResultSet=stmt.getResultSet();
 else {
      int updateCount=stmt.getUpdateCount();
      if (updateCount != -1 && updateCount != 0)       this.updateCount+=updateCount;
 else       state=State.PARAMETER_RESULTS;
    }
  }
  if (currentResultSet != null) {
    this.updateCount+=stmt.getUpdateCount();
    return new DataSet(currentResultSet,null,maxRows);
  }
  if (state == State.PARAMETER_RESULTS && parameters != null) {
    CallableStatement stmt=(CallableStatement)this.stmt;
    if (paramIter == null) {
      paramIter=parameters.iterator();
      paramColumnIndex=1;
    }
    while (paramIter.hasNext()) {
      NamedParameter param=paramIter.next();
      if (param.getDataType() == NamedParameter.DataType.CURSOR)       currentResultSet=product.getResultSet(stmt,param,paramColumnIndex);
      paramColumnIndex++;
      if (currentResultSet != null)       return new DataSet(Messages.getString("String_Node_Str") + ' ' + param.getName(),currentResultSet,null,maxRows);
    }
  }
  state=State.CLOSED;
  if (parameters == null)   return null;
  if (!(stmt instanceof CallableStatement))   return null;
  CallableStatement stmt=(CallableStatement)this.stmt;
  TreeMap<NamedParameter,ParamValues> params=new TreeMap<NamedParameter,ParamValues>();
  int columnIndex=1;
  int numValues=0;
  for (  NamedParameter param : parameters) {
    if (param.getDataType() != NamedParameter.DataType.CURSOR && param.isOutput()) {
      ParamValues pv=params.get(param);
      if (pv == null)       params.put(param,new ParamValues(param,columnIndex));
 else       pv.add(columnIndex);
      numValues++;
    }
    columnIndex++;
  }
  if (numValues == 0)   return null;
  Comparable[][] rows=new Comparable[numValues][2];
  columnIndex=1;
  int rowIndex=0;
  for (  ParamValues pv : params.values()) {
    int valueIndex=1;
    for (    Integer index : pv.columnIndexes) {
      Comparable[] row=rows[rowIndex++];
      row[0]=pv.param.getName();
      if (pv.columnIndexes.size() > 1)       row[0]=(pv.param.getName() + '[' + valueIndex+ ']');
 else       row[0]=pv.param.getName();
      row[1]=stmt.getString(index);
      valueIndex++;
    }
  }
  return new DataSet(Messages.getString("String_Node_Str"),new String[]{Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str")},rows);
}

Fixed version (ground truth):
public DataSet nextDataSet() throws SQLException {
  if (currentResultSet != null) {
    currentResultSet.close();
    currentResultSet=null;
  }
  if (state == State.CLOSED) {
    return null;
  }
  if (state == State.PRIMARY_RESULTS) {
    currentResultSet=stmt.getResultSet();
    state=State.SECONDARY_RESULTS;
    if (currentResultSet != null) {
      return new DataSet(currentResultSet,null,maxRows);
    }
  }
  while (state == State.SECONDARY_RESULTS) {
    if ("String_Node_Str".equals(stmt.getClass().getName())) {
      return null;
    }
    if (!(stmt instanceof HivePreparedStatement) && stmt.getMoreResults())     currentResultSet=stmt.getResultSet();
 else {
      int updateCount=stmt.getUpdateCount();
      if (updateCount != -1 && updateCount != 0) {
        this.updateCount+=updateCount;
      }
 else {
        state=State.PARAMETER_RESULTS;
      }
    }
  }
  if (currentResultSet != null) {
    this.updateCount+=stmt.getUpdateCount();
    return new DataSet(currentResultSet,null,maxRows);
  }
  if (state == State.PARAMETER_RESULTS && parameters != null) {
    CallableStatement stmt=(CallableStatement)this.stmt;
    if (paramIter == null) {
      paramIter=parameters.iterator();
      paramColumnIndex=1;
    }
    while (paramIter.hasNext()) {
      NamedParameter param=paramIter.next();
      if (param.getDataType() == NamedParameter.DataType.CURSOR) {
        currentResultSet=product.getResultSet(stmt,param,paramColumnIndex);
      }
      paramColumnIndex++;
      if (currentResultSet != null) {
        return new DataSet(Messages.getString("String_Node_Str") + ' ' + param.getName(),currentResultSet,null,maxRows);
      }
    }
  }
  state=State.CLOSED;
  if (parameters == null) {
    return null;
  }
  if (!(stmt instanceof CallableStatement)) {
    return null;
  }
  CallableStatement stmt=(CallableStatement)this.stmt;
  TreeMap<NamedParameter,ParamValues> params=new TreeMap<NamedParameter,ParamValues>();
  int columnIndex=1;
  int numValues=0;
  for (  NamedParameter param : parameters) {
    if (param.getDataType() != NamedParameter.DataType.CURSOR && param.isOutput()) {
      ParamValues pv=params.get(param);
      if (pv == null) {
        params.put(param,new ParamValues(param,columnIndex));
      }
 else {
        pv.add(columnIndex);
      }
      numValues++;
    }
    columnIndex++;
  }
  if (numValues == 0) {
    return null;
  }
  Comparable[][] rows=new Comparable[numValues][2];
  columnIndex=1;
  int rowIndex=0;
  for (  ParamValues pv : params.values()) {
    int valueIndex=1;
    for (    Integer index : pv.columnIndexes) {
      Comparable[] row=rows[rowIndex++];
      row[0]=pv.param.getName();
      if (pv.columnIndexes.size() > 1) {
        row[0]=(pv.param.getName() + '[' + valueIndex+ ']');
      }
 else {
        row[0]=pv.param.getName();
      }
      row[1]=stmt.getString(index);
      valueIndex++;
    }
  }
  return new DataSet(Messages.getString("String_Node_Str"),new String[]{Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str")},rows);
}