Program: 166887
Project: 166887
Buggy source:
private String constructSelectSinglePathSql(SqlgGraph sqlgGraph,boolean partOfDuplicateQuery,LinkedList<SchemaTableTree> distinctQueryStack,SchemaTableTree lastOfPrevious,SchemaTableTree firstOfNextStack,Set<SchemaTableTree> leftJoinOn,boolean dropStep){
  StringBuilder singlePathSql=new StringBuilder("String_Node_Str");
  SchemaTableTree firstSchemaTableTree=distinctQueryStack.getFirst();
  SchemaTable firstSchemaTable=firstSchemaTableTree.getSchemaTable();
  if (!dropStep && lastOfPrevious == null && distinctQueryStack.getFirst().stepType != STEP_TYPE.GRAPH_STEP) {
    if (this.parentIdsAndIndexes.size() == 1) {
      singlePathSql.append(this.parentIdsAndIndexes.get(0).getRight());
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
    }
 else     if (sqlgGraph.getSqlDialect().supportsValuesExpression()) {
      if (sqlgGraph.getSqlDialect().supportsFullValueExpression()) {
        singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
      }
 else {
        singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
      }
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
    }
 else {
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
    }
    singlePathSql.append("String_Node_Str");
  }
  singlePathSql.append(constructFromClause(sqlgGraph,distinctQueryStack,lastOfPrevious,firstOfNextStack,dropStep));
  singlePathSql.append("String_Node_Str");
  singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(firstSchemaTableTree.getSchemaTable().getSchema()));
  singlePathSql.append("String_Node_Str");
  singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(firstSchemaTableTree.getSchemaTable().getTable()));
  SchemaTableTree previous=firstSchemaTableTree;
  boolean skipFirst=true;
  for (  SchemaTableTree schemaTableTree : distinctQueryStack) {
    if (skipFirst) {
      skipFirst=false;
      continue;
    }
    singlePathSql.append(constructJoinBetweenSchemaTables(sqlgGraph,previous,schemaTableTree));
    previous=schemaTableTree;
  }
  SchemaTableTree previousLeftJoinSchemaTableTree=null;
  for (  SchemaTableTree schemaTableTree : leftJoinOn) {
    if (previousLeftJoinSchemaTableTree == null || !previousLeftJoinSchemaTableTree.getSchemaTable().equals(schemaTableTree.getSchemaTable())) {
      singlePathSql.append(constructJoinBetweenSchemaTables(sqlgGraph,previous,schemaTableTree,true));
    }
 else {
      singlePathSql.append(appendToJoinBetweenSchemaTables(sqlgGraph,previous,schemaTableTree,true));
    }
    previousLeftJoinSchemaTableTree=schemaTableTree;
  }
  for (  SchemaTableTree schemaTableTree : distinctQueryStack) {
    if (sqlgGraph.getSqlDialect().supportsBulkWithinOut() && schemaTableTree.hasBulkWithinOrOut(sqlgGraph)) {
      singlePathSql.append(schemaTableTree.bulkWithJoin(sqlgGraph));
    }
  }
  MutableBoolean mutableWhere=new MutableBoolean(false);
  MutableBoolean mutableOrderBy=new MutableBoolean(false);
  if (lastOfPrevious == null && distinctQueryStack.getFirst().stepType != STEP_TYPE.GRAPH_STEP) {
    if (this.parentIdsAndIndexes.size() != 1 && sqlgGraph.getSqlDialect().supportsValuesExpression()) {
      singlePathSql.append("String_Node_Str");
      int count=1;
      for (      Pair<Long,Long> parentIdAndIndex : this.parentIdsAndIndexes) {
        singlePathSql.append("String_Node_Str");
        singlePathSql.append(parentIdAndIndex.getLeft());
        singlePathSql.append("String_Node_Str");
        singlePathSql.append(parentIdAndIndex.getRight());
        singlePathSql.append("String_Node_Str");
        if (count++ < this.parentIdsAndIndexes.size()) {
          singlePathSql.append("String_Node_Str");
        }
      }
      if (sqlgGraph.getSqlDialect().supportsFullValueExpression()) {
        singlePathSql.append("String_Node_Str");
        singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
        singlePathSql.append("String_Node_Str");
        singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
        singlePathSql.append("String_Node_Str");
        singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(firstSchemaTable.getSchema()));
        singlePathSql.append("String_Node_Str");
        singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(firstSchemaTable.getTable()));
        singlePathSql.append("String_Node_Str");
        singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(Topology.ID));
        singlePathSql.append("String_Node_Str");
        singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
      }
 else {
        singlePathSql.append("String_Node_Str");
        singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(firstSchemaTable.getSchema()));
        singlePathSql.append("String_Node_Str");
        singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(firstSchemaTable.getTable()));
        singlePathSql.append("String_Node_Str");
        singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(Topology.ID));
        singlePathSql.append("String_Node_Str");
        singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
      }
    }
 else     if (this.parentIdsAndIndexes.size() != 1 && !sqlgGraph.getSqlDialect().supportsValuesExpression()) {
      SecureRandom random=new SecureRandom();
      byte bytes[]=new byte[6];
      random.nextBytes(bytes);
      String tmpTableIdentified=Base64.getEncoder().encodeToString(bytes);
      sqlgGraph.tx().normalBatchModeOn();
      for (      Pair<Long,Long> parentIdsAndIndex : this.parentIdsAndIndexes) {
        sqlgGraph.addTemporaryVertex(T.label,tmpTableIdentified,"String_Node_Str",parentIdsAndIndex.getLeft(),"String_Node_Str",parentIdsAndIndex.getRight());
      }
      sqlgGraph.tx().flush();
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(sqlgGraph.getSqlDialect().getPublicSchema()));
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(VERTEX_PREFIX + tmpTableIdentified));
      singlePathSql.append("String_Node_Str");
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(firstSchemaTable.getSchema()));
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(firstSchemaTable.getTable()));
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(Topology.ID));
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
    }
 else {
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(firstSchemaTable.getSchema()));
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(firstSchemaTable.getTable()));
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(Topology.ID));
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(this.parentIdsAndIndexes.get(0).getLeft());
      mutableWhere.setTrue();
    }
  }
  for (  SchemaTableTree schemaTableTree : distinctQueryStack) {
    singlePathSql.append(schemaTableTree.toWhereClause(sqlgGraph,mutableWhere));
  }
  for (  SchemaTableTree schemaTableTree : leftJoinOn) {
    singlePathSql.append(schemaTableTree.toOptionalLeftJoinWhereClause(sqlgGraph,mutableWhere));
  }
  if (!partOfDuplicateQuery) {
    if (!dropStep && lastOfPrevious == null && distinctQueryStack.getFirst().stepType != STEP_TYPE.GRAPH_STEP) {
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
      mutableOrderBy.setTrue();
    }
    for (    SchemaTableTree schemaTableTree : distinctQueryStack) {
      singlePathSql.append(schemaTableTree.toOrderByClause(sqlgGraph,mutableOrderBy,-1));
      singlePathSql.append(schemaTableTree.toRangeClause(sqlgGraph,mutableOrderBy));
    }
  }
  return singlePathSql.toString();
}

Fixed version (ground truth):
private String constructSelectSinglePathSql(SqlgGraph sqlgGraph,boolean partOfDuplicateQuery,LinkedList<SchemaTableTree> distinctQueryStack,SchemaTableTree lastOfPrevious,SchemaTableTree firstOfNextStack,Set<SchemaTableTree> leftJoinOn,boolean dropStep){
  StringBuilder singlePathSql=new StringBuilder("String_Node_Str");
  SchemaTableTree firstSchemaTableTree=distinctQueryStack.getFirst();
  SchemaTable firstSchemaTable=firstSchemaTableTree.getSchemaTable();
  if (!dropStep && lastOfPrevious == null && distinctQueryStack.getFirst().stepType != STEP_TYPE.GRAPH_STEP) {
    if (this.parentIdsAndIndexes.size() == 1) {
      singlePathSql.append(this.parentIdsAndIndexes.get(0).getRight());
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
    }
 else     if (sqlgGraph.getSqlDialect().supportsValuesExpression()) {
      if (sqlgGraph.getSqlDialect().supportsFullValueExpression()) {
        singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
      }
 else {
        singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
      }
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
    }
 else {
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
    }
    singlePathSql.append("String_Node_Str");
  }
  singlePathSql.append(constructFromClause(sqlgGraph,distinctQueryStack,lastOfPrevious,firstOfNextStack,dropStep));
  singlePathSql.append("String_Node_Str");
  singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(firstSchemaTableTree.getSchemaTable().getSchema()));
  singlePathSql.append("String_Node_Str");
  singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(firstSchemaTableTree.getSchemaTable().getTable()));
  SchemaTableTree previous=firstSchemaTableTree;
  boolean skipFirst=true;
  for (  SchemaTableTree schemaTableTree : distinctQueryStack) {
    if (skipFirst) {
      skipFirst=false;
      continue;
    }
    singlePathSql.append(constructJoinBetweenSchemaTables(sqlgGraph,previous,schemaTableTree));
    previous=schemaTableTree;
  }
  SchemaTableTree previousLeftJoinSchemaTableTree=null;
  for (  SchemaTableTree schemaTableTree : leftJoinOn) {
    if (previousLeftJoinSchemaTableTree == null || !previousLeftJoinSchemaTableTree.getSchemaTable().equals(schemaTableTree.getSchemaTable())) {
      singlePathSql.append(constructJoinBetweenSchemaTables(sqlgGraph,previous,schemaTableTree,true));
    }
 else {
      singlePathSql.append(appendToJoinBetweenSchemaTables(sqlgGraph,previous,schemaTableTree,true));
    }
    previousLeftJoinSchemaTableTree=schemaTableTree;
  }
  for (  SchemaTableTree schemaTableTree : distinctQueryStack) {
    if (sqlgGraph.getSqlDialect().supportsBulkWithinOut() && schemaTableTree.hasBulkWithinOrOut(sqlgGraph)) {
      singlePathSql.append(schemaTableTree.bulkWithJoin(sqlgGraph));
    }
  }
  MutableBoolean mutableWhere=new MutableBoolean(false);
  MutableBoolean mutableOrderBy=new MutableBoolean(false);
  if (lastOfPrevious == null && distinctQueryStack.getFirst().stepType != STEP_TYPE.GRAPH_STEP) {
    if (this.parentIdsAndIndexes.size() != 1 && sqlgGraph.getSqlDialect().supportsValuesExpression()) {
      singlePathSql.append("String_Node_Str");
      int count=1;
      for (      Pair<Long,Long> parentIdAndIndex : this.parentIdsAndIndexes) {
        singlePathSql.append("String_Node_Str");
        singlePathSql.append(parentIdAndIndex.getLeft());
        singlePathSql.append("String_Node_Str");
        singlePathSql.append(parentIdAndIndex.getRight());
        singlePathSql.append("String_Node_Str");
        if (count++ < this.parentIdsAndIndexes.size()) {
          singlePathSql.append("String_Node_Str");
        }
      }
      if (sqlgGraph.getSqlDialect().supportsFullValueExpression()) {
        singlePathSql.append("String_Node_Str");
        singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
        singlePathSql.append("String_Node_Str");
        singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
        singlePathSql.append("String_Node_Str");
        singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(firstSchemaTable.getSchema()));
        singlePathSql.append("String_Node_Str");
        singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(firstSchemaTable.getTable()));
        singlePathSql.append("String_Node_Str");
        singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(Topology.ID));
        singlePathSql.append("String_Node_Str");
        singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
      }
 else {
        singlePathSql.append("String_Node_Str");
        singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(firstSchemaTable.getSchema()));
        singlePathSql.append("String_Node_Str");
        singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(firstSchemaTable.getTable()));
        singlePathSql.append("String_Node_Str");
        singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(Topology.ID));
        singlePathSql.append("String_Node_Str");
        singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
      }
    }
 else     if (this.parentIdsAndIndexes.size() != 1 && !sqlgGraph.getSqlDialect().supportsValuesExpression()) {
      SecureRandom random=new SecureRandom();
      byte bytes[]=new byte[6];
      random.nextBytes(bytes);
      String tmpTableIdentified=Base64.getEncoder().encodeToString(bytes);
      sqlgGraph.tx().normalBatchModeOn();
      for (      Pair<Long,Long> parentIdsAndIndex : this.parentIdsAndIndexes) {
        sqlgGraph.addTemporaryVertex(T.label,tmpTableIdentified,"String_Node_Str",parentIdsAndIndex.getLeft(),"String_Node_Str",parentIdsAndIndex.getRight());
      }
      sqlgGraph.tx().flush();
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(sqlgGraph.getSqlDialect().getPublicSchema()));
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(VERTEX_PREFIX + tmpTableIdentified));
      singlePathSql.append("String_Node_Str");
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(firstSchemaTable.getSchema()));
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(firstSchemaTable.getTable()));
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(Topology.ID));
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
    }
 else {
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(firstSchemaTable.getSchema()));
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(firstSchemaTable.getTable()));
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(Topology.ID));
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(this.parentIdsAndIndexes.get(0).getLeft());
      mutableWhere.setTrue();
    }
  }
  for (  SchemaTableTree schemaTableTree : distinctQueryStack) {
    singlePathSql.append(schemaTableTree.toWhereClause(sqlgGraph,mutableWhere));
  }
  for (  SchemaTableTree schemaTableTree : leftJoinOn) {
    singlePathSql.append(schemaTableTree.toOptionalLeftJoinWhereClause(sqlgGraph,mutableWhere));
    if (dropStep) {
      String rawLabel;
      if (schemaTableTree.getSchemaTable().getTable().startsWith(VERTEX_PREFIX)) {
        rawLabel=schemaTableTree.getSchemaTable().getTable().substring(VERTEX_PREFIX.length());
      }
 else {
        rawLabel=schemaTableTree.getSchemaTable().getTable();
      }
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(previous.getSchemaTable().getSchema()));
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(previous.getSchemaTable().getTable()));
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes(schemaTableTree.getSchemaTable().getSchema() + "String_Node_Str" + rawLabel+ (schemaTableTree.getDirection() == Direction.IN ? Topology.OUT_VERTEX_COLUMN_END : Topology.IN_VERTEX_COLUMN_END)));
      singlePathSql.append("String_Node_Str");
    }
  }
  if (!partOfDuplicateQuery) {
    if (!dropStep && lastOfPrevious == null && distinctQueryStack.getFirst().stepType != STEP_TYPE.GRAPH_STEP) {
      singlePathSql.append("String_Node_Str");
      singlePathSql.append(sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
      mutableOrderBy.setTrue();
    }
    for (    SchemaTableTree schemaTableTree : distinctQueryStack) {
      singlePathSql.append(schemaTableTree.toOrderByClause(sqlgGraph,mutableOrderBy,-1));
      singlePathSql.append(schemaTableTree.toRangeClause(sqlgGraph,mutableOrderBy));
    }
  }
  return singlePathSql.toString();
}