/**
   * {@inheritDoc}
   *
   * @see com.continuent.tungsten.replicator.database.SqlCommentEditor#fetchComment(String,
   *     SqlOperation)
   */
  public String fetchComment(String statement, SqlOperation sqlOp) {
    // Select correct comment pattern.
    Pattern commentPattern = standardPattern;
    if (sqlOp.getOperation() == SqlOperation.CREATE) {
      int objectType = sqlOp.getObjectType();
      if (objectType == SqlOperation.PROCEDURE) commentPattern = sprocPattern;
      else if (objectType == SqlOperation.FUNCTION) commentPattern = sprocPattern;
    } else if (sqlOp.dropTable()) {
      commentPattern = dropTablePattern;
    }

    // Look for pattern match and return value if found.
    Matcher m = commentPattern.matcher(statement);
    if (m.find()) return m.group(1);
    else return null;
  }
  /**
   * {@inheritDoc}
   *
   * @see com.continuent.tungsten.replicator.database.SqlCommentEditor#addComment(java.lang.String,
   *     com.continuent.tungsten.replicator.database.SqlOperation, java.lang.String)
   */
  public String addComment(String statement, SqlOperation sqlOp, String comment) {
    // If editing is enabled, return now.
    if (!this.commentEditingEnabled) return statement;

    // Look for a stored procedure or function creation.
    if (sqlOp.getOperation() == SqlOperation.CREATE) {
      int objectType = sqlOp.getObjectType();
      if (objectType == SqlOperation.PROCEDURE || objectType == SqlOperation.FUNCTION) {
        return processCreateProcedure(statement, comment);
      }
    } else if (sqlOp.dropTable()) {
      return processDropTable(statement, comment);
    }

    // For any others just append the comment.
    return statement + " /* " + comment + " */";
  }
  /**
   * {@inheritDoc}
   *
   * @see
   *     com.continuent.tungsten.replicator.database.SqlCommentEditor#formatAppendableComment(SqlOperation,
   *     String)
   */
  public String formatAppendableComment(SqlOperation sqlOp, String comment) {
    // If editing is enabled, return now.
    if (!this.commentEditingEnabled) return null;

    // Look for a stored procedure or function and return null. They are not
    // safe for appending.
    if (sqlOp.getOperation() == SqlOperation.CREATE) {
      int objectType = sqlOp.getObjectType();
      if (objectType == SqlOperation.PROCEDURE || objectType == SqlOperation.FUNCTION) {
        return null;
      }
    } else if (sqlOp.dropTable()) {
      // Drop table requires special handling as MySQL 5.5+ drops
      // comments.
      return null;
    }

    // For any others return a properly formatted comment.
    return " /* " + comment + " */";
  }