private DeleteResult run_delete_v2(String accountName, String containerName, String blobName, short accountId,
      short containerId, Connection connection) throws Exception {
    String blobId;
    long version;
    Timestamp currentDeleteTime = null;
    boolean alreadyDeleted;
    List<DeleteResult.BlobVersion> blobVersions = new ArrayList<>();
    List<Long> versionsToDelete = new ArrayList<>();
    String query = "";
    try (PreparedStatement statement = connection.prepareStatement(SELECT_FOR_DELETE_QUERY)) {
      statement.setInt(1, accountId);
      statement.setInt(2, containerId);
      statement.setString(3, blobName);
      query = statement.toString();
      logger.debug("Deleting blob name in MySql. Query {}", query);
      metricsRecoder.namedBlobDeleteRate.mark();
      try (ResultSet resultSet = statement.executeQuery()) {
        while (resultSet.next()) {
          blobId = Base64.encodeBase64URLSafeString(resultSet.getBytes(1));
          version = resultSet.getLong(2);
          Timestamp originalDeletionTime = resultSet.getTimestamp(3);
          currentDeleteTime = resultSet.getTimestamp(4);
          alreadyDeleted = (originalDeletionTime != null && currentDeleteTime.after(originalDeletionTime));
          blobVersions.add(new DeleteResult.BlobVersion(blobId, version, alreadyDeleted));
          if (!alreadyDeleted) {
            versionsToDelete.add(version);
          }
        }
        if (blobVersions.isEmpty()) {
          throw buildException("DELETE: Blob not found", RestServiceErrorCode.NotFound, accountName, containerName,
              blobName);
        }
      }
    } catch (SQLException e) {
      logger.error("Failed to execute query {}, {}", query, e.getMessage());
      throw e;
    }
    // only need to issue an update statement if the row was not already marked as deleted.
    if (!versionsToDelete.isEmpty()) {
      applyDelete(accountId, containerId, blobName, currentDeleteTime, versionsToDelete, connection);
    }
    return new DeleteResult(blobVersions);
  }
Construct a list query statement with prefix when {@link MySqlNamedBlobDbConfig#listNamedBlobsSQLOption} is 3
@param statement The {@link PreparedStatement} to set the parameters on.
@param accountId The account id
@param containerId The container id
@param blobNamePrefix The blobname prefix
@param pageToken The page token
@param maxKeysValue The max key to return
@throws SQLException
ambry-named-mysql/src/main/java/com/github/ambry/named/MySqlNamedBlobDb.java