Program: 51534
Project: 51534
Buggy source:
/** 
 * Generates the SQL statement to access the children of <code>member</code> in a parent-child hierarchy. For example, <blockquote> <pre>SELECT "employee_id" FROM "employee" WHERE "supervisor_id" = 5</pre> </blockquote> retrieves the children of the member <code>[Employee].[5]</code>. <p>See also   {@link SqlTupleReader#makeLevelMembersSql}.
 */
private String makeChildMemberSqlPC(RolapMember member,Connection jdbcConnection){
  SqlQuery sqlQuery=newQuery(jdbcConnection,"String_Node_Str" + member);
  RolapLevel level=(RolapLevel)member.getLevel();
  Util.assertTrue(!level.isAll(),"String_Node_Str");
  Util.assertTrue(level.isUnique(),"String_Node_Str" + level + "String_Node_Str");
  hierarchy.addToFrom(sqlQuery,level.getParentExp());
  String parentId=level.getParentExp().getExpression(sqlQuery);
  sqlQuery.addWhere(parentId,"String_Node_Str",member.quoteKeyForSql());
  hierarchy.addToFrom(sqlQuery,level.getKeyExp());
  String childId=level.getKeyExp().getExpression(sqlQuery);
  sqlQuery.addSelect(childId);
  sqlQuery.addGroupBy(childId);
  hierarchy.addToFrom(sqlQuery,level.getOrdinalExp());
  String orderBy=level.getOrdinalExp().getExpression(sqlQuery);
  sqlQuery.addOrderBy(orderBy);
  if (!orderBy.equals(childId)) {
    sqlQuery.addGroupBy(orderBy);
  }
  RolapProperty[] properties=level.getRolapProperties();
  for (int j=0; j < properties.length; j++) {
    RolapProperty property=properties[j];
    final MondrianDef.Expression exp=property.getExp();
    hierarchy.addToFrom(sqlQuery,exp);
    final String s=exp.getExpression(sqlQuery);
    sqlQuery.addSelect(s);
    sqlQuery.addGroupBy(s);
  }
  return sqlQuery.toString();
}

Fixed version (ground truth):
/** 
 * Generates the SQL statement to access the children of <code>member</code> in a parent-child hierarchy. For example, <blockquote> <pre>SELECT "employee_id" FROM "employee" WHERE "supervisor_id" = 5</pre> </blockquote> retrieves the children of the member <code>[Employee].[5]</code>. <p>See also   {@link SqlTupleReader#makeLevelMembersSql}.
 */
private String makeChildMemberSqlPC(RolapMember member,Connection jdbcConnection){
  SqlQuery sqlQuery=newQuery(jdbcConnection,"String_Node_Str" + member);
  RolapLevel level=(RolapLevel)member.getLevel();
  Util.assertTrue(!level.isAll(),"String_Node_Str");
  Util.assertTrue(level.isUnique(),"String_Node_Str" + level + "String_Node_Str");
  hierarchy.addToFrom(sqlQuery,level.getParentExp());
  String parentId=level.getParentExp().getExpression(sqlQuery);
  sqlQuery.addWhere(parentId,"String_Node_Str",member.quoteKeyForSql());
  hierarchy.addToFrom(sqlQuery,level.getKeyExp());
  String childId=level.getKeyExp().getExpression(sqlQuery);
  sqlQuery.addSelect(childId);
  sqlQuery.addGroupBy(childId);
  hierarchy.addToFrom(sqlQuery,level.getOrdinalExp());
  String orderBy=level.getOrdinalExp().getExpression(sqlQuery);
  sqlQuery.addOrderBy(orderBy,true,false);
  if (!orderBy.equals(childId)) {
    sqlQuery.addGroupBy(orderBy);
  }
  RolapProperty[] properties=level.getRolapProperties();
  for (int j=0; j < properties.length; j++) {
    RolapProperty property=properties[j];
    final MondrianDef.Expression exp=property.getExp();
    hierarchy.addToFrom(sqlQuery,exp);
    final String s=exp.getExpression(sqlQuery);
    sqlQuery.addSelect(s);
    sqlQuery.addGroupBy(s);
  }
  return sqlQuery.toString();
}