Program: 7966
Project: 7966
Buggy source:
@Override public List<byte[]> getKeys(int limit,int offset,ReadPointer readPointer) throws OperationException {
  PreparedStatement ps=null;
  try {
    ps=this.connection.prepareStatement("String_Node_Str" + "String_Node_Str" + this.quotedTableName + "String_Node_Str"+ "String_Node_Str");
    ResultSet result=ps.executeQuery();
    List<byte[]> keys=new ArrayList<byte[]>(limit > 1024 ? 1024 : limit);
    int returned=0;
    int skipped=0;
    long lastDelete=-1;
    long undeleted=-1;
    byte[] lastRow=new byte[0];
    byte[] curRow=new byte[0];
    byte[] curCol=new byte[0];
    byte[] lastCol=new byte[0];
    while (result.next() && returned < limit) {
      byte[] row=result.getBytes(1);
      if (Bytes.equals(lastRow,row))       continue;
      if (!Bytes.equals(curRow,row)) {
        lastCol=new byte[0];
        curCol=new byte[0];
        lastDelete=-1;
        undeleted=-1;
      }
      curRow=row;
      long curVersion=result.getLong(3);
      if (!readPointer.isVisible(curVersion))       continue;
      byte[] column=result.getBytes(2);
      if (Bytes.equals(lastCol,column)) {
        continue;
      }
      if (!Bytes.equals(curCol,column)) {
        curCol=column;
        lastDelete=-1;
        undeleted=-1;
      }
      Type type=Type.from(result.getInt(4));
      if (type.isUndeleteAll()) {
        undeleted=curVersion;
        continue;
      }
      if (type.isDeleteAll()) {
        if (undeleted == curVersion)         continue;
 else {
          lastCol=column;
          continue;
        }
      }
      if (type.isDelete()) {
        lastDelete=curVersion;
        continue;
      }
      if (curVersion == lastDelete)       continue;
      lastRow=row;
      if (skipped < offset) {
        skipped++;
      }
 else {
        keys.add(row);
        returned++;
      }
    }
    return keys;
  }
 catch (  SQLException e) {
    throw createOperationException(e,"String_Node_Str");
  }
 finally {
    if (ps != null) {
      try {
        ps.close();
      }
 catch (      SQLException e) {
        throw createOperationException(e,"String_Node_Str");
      }
    }
  }
}

Fixed version (ground truth):
@Override public List<byte[]> getKeys(int limit,int offset,ReadPointer readPointer) throws OperationException {
  PreparedStatement ps=null;
  try {
    ps=this.connection.prepareStatement("String_Node_Str" + "String_Node_Str" + this.quotedTableName + "String_Node_Str"+ "String_Node_Str");
    ResultSet result=ps.executeQuery();
    List<byte[]> keys=new ArrayList<byte[]>(limit > 1024 ? 1024 : limit);
    int returned=0;
    int skipped=0;
    long lastDelete=-1;
    long undeleted=-1;
    byte[] lastRow=new byte[0];
    byte[] curRow=new byte[0];
    byte[] curCol=new byte[0];
    byte[] lastCol=new byte[0];
    while (result.next() && returned < limit) {
      byte[] row=result.getBytes(1);
      if (Bytes.equals(lastRow,row)) {
        continue;
      }
      if (!Bytes.equals(curRow,row)) {
        lastCol=new byte[0];
        curCol=new byte[0];
        lastDelete=-1;
        undeleted=-1;
      }
      curRow=row;
      long curVersion=result.getLong(3);
      if (!readPointer.isVisible(curVersion)) {
        continue;
      }
      byte[] column=result.getBytes(2);
      if (Bytes.equals(lastCol,column)) {
        continue;
      }
      if (!Bytes.equals(curCol,column)) {
        curCol=column;
        lastDelete=-1;
        undeleted=-1;
      }
      Type type=Type.from(result.getInt(4));
      if (type.isUndeleteAll()) {
        undeleted=curVersion;
        continue;
      }
      if (type.isDeleteAll()) {
        if (undeleted == curVersion) {
          continue;
        }
 else {
          lastCol=column;
          continue;
        }
      }
      if (type.isDelete()) {
        lastDelete=curVersion;
        continue;
      }
      if (curVersion == lastDelete) {
        continue;
      }
      lastRow=row;
      if (skipped < offset) {
        skipped++;
      }
 else {
        keys.add(row);
        returned++;
      }
    }
    return keys;
  }
 catch (  SQLException e) {
    throw createOperationException(e,"String_Node_Str");
  }
 finally {
    if (ps != null) {
      try {
        ps.close();
      }
 catch (      SQLException e) {
        throw createOperationException(e,"String_Node_Str");
      }
    }
  }
}