Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-7190

CaptureChangeMySQL processor doesn't emit DDL events if SQL statement begins with a comment

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.11.2
    • 1.20.0, 1.19.1
    • None
    • None

    Description

      The existing check for DDL Events doesn't take into account SQL statements that begin with a comment, in file: nifi/nifi-nar-bundles/nifi-cdc/nifi-cdc-mysql-bundle/nifi-cdc-mysql-processors/src/main/java/org/apache/nifi/cdc/mysql/processors/CaptureChangeMySQL.java:821

      // Check for DDL events (alter table, e.g.). Normalize the query to do string matching on the type of change
      String normalizedQuery = sql.toLowerCase().trim().replaceAll(" {2,}", " ");
      if (normalizedQuery.startsWith("alter table")
          || normalizedQuery.startsWith("alter ignore table")
          || normalizedQuery.startsWith("create table")
          || normalizedQuery.startsWith("truncate table")
          || normalizedQuery.startsWith("rename table")
          || normalizedQuery.startsWith("drop table")
          || normalizedQuery.startsWith("drop database")) 

      SQL commands such as:

      /* ApplicationName=DataGrip 2019.2.4 */ alter table test_table
          drop column test_column
      

      won't evaluate to true.

      Attachments

        Activity

          People

            feitgraph Makarov Vasiliy Nicolaevich
            przemekd Przemyslaw Dubaniewicz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 1h 20m
                1h 20m