Program: 177690
Project: 177690
Buggy source:
/** 
 * Prepares DDL queries to create existing scheme from scrats. TODO return them as a list to execute somehow.
 */
private static void constructScheme(){
  Queue<Query> constructionQueries=new LinkedList<Query>();
  SchemeCreationPolicy policy=configuration.getCreationPolicy();
  Log.info("String_Node_Str",policy.toString());
  if (policy.equals(SchemeCreationPolicy.CREATE) || policy.equals(SchemeCreationPolicy.UPDATE)) {
    EntityDependencyGraph serialSchedule=new EntityDependencyGraph(scheme.getEntities());
    for (    Entity e : serialSchedule.getDestroySchedule()) {
      if (policy.equals(SchemeCreationPolicy.CREATE)) {
        Query dT=DDLQueryGenerator.dropTableQuery(e);
        constructionQueries.offer(dT);
      }
    }
    for (    Entity e : serialSchedule.getConstructSchedule()) {
      Query cT=DDLQueryGenerator.createTableQuery(e,policy.equals(SchemeCreationPolicy.UPDATE));
      constructionQueries.offer(cT);
      List<Field> compositeIndexFields=new ArrayList<Field>(2);
      List<Field> singleIndexFields=new ArrayList<Field>(2);
      for (      Field f : e.getFields()) {
        if (f.getIndex() != null) {
          if (f.isPrimaryKey() && !f.isAutoIncrement())           compositeIndexFields.add(f);
          if (!f.isPrimaryKey()) {
            singleIndexFields.add(f);
          }
        }
      }
      if (policy.equals(SchemeCreationPolicy.CREATE)) {
        Query dCI=DDLQueryGenerator.dropCompositeIndexQuery(e);
        if (dCI != null)         constructionQueries.offer(dCI);
      }
      Query cCI=DDLQueryGenerator.createCompositeIndexQuery(e,compositeIndexFields,policy.equals(SchemeCreationPolicy.UPDATE));
      if (cCI != null)       constructionQueries.offer(cCI);
      for (      Field f : singleIndexFields) {
        if (policy.equals(SchemeCreationPolicy.CREATE)) {
          Query dI=DDLQueryGenerator.dropIndexQuery(e,f);
          constructionQueries.offer(dI);
        }
        Query cI=DDLQueryGenerator.createIndexQuery(e,f,policy.equals(SchemeCreationPolicy.UPDATE));
        constructionQueries.offer(cI);
      }
    }
    Log.info("String_Node_Str");
    for (    Query q : constructionQueries) {
      getExecuter().executeOnly(q);
    }
    Log.info("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Prepares DDL queries to create existing scheme from scrats. TODO return them as a list to execute somehow.
 */
private static void constructScheme(){
  Queue<Query> constructionQueries=new LinkedList<Query>();
  SchemeCreationPolicy policy=configuration.getCreationPolicy();
  Log.info("String_Node_Str",policy.toString());
  if (policy.equals(SchemeCreationPolicy.CREATE) || policy.equals(SchemeCreationPolicy.CREATE_IF_NOT_EXISTS)) {
    EntityDependencyGraph serialSchedule=new EntityDependencyGraph(scheme.getEntities());
    for (    Entity e : serialSchedule.getDestroySchedule()) {
      if (policy.equals(SchemeCreationPolicy.CREATE)) {
        Query dT=DDLQueryGenerator.dropTableQuery(e);
        constructionQueries.offer(dT);
      }
    }
    for (    Entity e : serialSchedule.getConstructSchedule()) {
      Query cT=DDLQueryGenerator.createTableQuery(e,policy.equals(SchemeCreationPolicy.CREATE_IF_NOT_EXISTS));
      constructionQueries.offer(cT);
      List<Field> compositeIndexFields=new ArrayList<Field>(2);
      List<Field> singleIndexFields=new ArrayList<Field>(2);
      for (      Field f : e.getFields()) {
        if (f.getIndex() != null) {
          if (f.isPrimaryKey() && !f.isAutoIncrement())           compositeIndexFields.add(f);
          if (!f.isPrimaryKey()) {
            singleIndexFields.add(f);
          }
        }
      }
      if (policy.equals(SchemeCreationPolicy.CREATE)) {
        Query dCI=DDLQueryGenerator.dropCompositeIndexQuery(e);
        if (dCI != null)         constructionQueries.offer(dCI);
      }
      Query cCI=DDLQueryGenerator.createCompositeIndexQuery(e,compositeIndexFields,policy.equals(SchemeCreationPolicy.CREATE_IF_NOT_EXISTS));
      if (cCI != null)       constructionQueries.offer(cCI);
      for (      Field f : singleIndexFields) {
        if (policy.equals(SchemeCreationPolicy.CREATE)) {
          Query dI=DDLQueryGenerator.dropIndexQuery(e,f);
          constructionQueries.offer(dI);
        }
        Query cI=DDLQueryGenerator.createIndexQuery(e,f,policy.equals(SchemeCreationPolicy.CREATE_IF_NOT_EXISTS));
        constructionQueries.offer(cI);
      }
    }
    Log.info("String_Node_Str");
    for (    Query q : constructionQueries) {
      getExecuter().executeOnly(q);
    }
    Log.info("String_Node_Str");
  }
}