Class LogMinerDmlParser

java.lang.Object
io.debezium.connector.oracle.logminer.parser.LogMinerDmlParser
All Implemented Interfaces:
DmlParser

public class LogMinerDmlParser extends Object implements DmlParser
A simple DML parser implementation specifically for Oracle LogMiner. The syntax of each DML operation is restricted to the format generated by Oracle LogMiner. The following are examples of each expected syntax:
     insert into "schema"."table"("C1","C2") values ('v1','v2');
     update "schema"."table" set "C1" = 'v1a', "C2" = 'v2a' where "C1" = 'v1' and "C2" = 'v2';
     delete from "schema"."table" where "C1" = 'v1' AND "C2" = 'v2';
 
Certain data types are not emitted as string literals, such as DATE and TIMESTAMP. For these data types, they're emitted as function calls. The parser can detect this use case and will emit the values for such columns as the explicit function call. Lets take the following UPDATE statement:
     update "schema"."table"
        set "C1" = TO_TIMESTAMP('2020-02-02 00:00:00', 'YYYY-MM-DD HH24:MI:SS')
      where "C1" = TO_TIMESTAMP('2020-02-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS');
 
The new value for C1 would be TO_TIMESTAMP('2020-02-02 00:00:00', 'YYYY-MM-DD HH24:MI:SS'). The old value for C1 would be TO_TIMESTAMP('2020-02-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS').
Author:
Chris Cranford
  • Field Details

  • Constructor Details

    • LogMinerDmlParser

      public LogMinerDmlParser()
  • Method Details

    • parse

      public LogMinerDmlEntry parse(String sql, Table table)
      Description copied from interface: DmlParser
      Parse a DML SQL string from the LogMiner event stream.
      Specified by:
      parse in interface DmlParser
      Parameters:
      sql - the sql statement
      table - the table the sql statement is for
      Returns:
      the parsed sql as a DML entry or null if the SQL couldn't be parsed.
    • parseInsert

      private LogMinerDmlEntry parseInsert(String sql, Table table)
      Parse an INSERT SQL statement.
      Parameters:
      sql - the sql statement
      table - the table
      Returns:
      the parsed DML entry record or null if the SQL was not parsed
    • parseUpdate

      private LogMinerDmlEntry parseUpdate(String sql, Table table)
      Parse an UPDATE SQL statement.
      Parameters:
      sql - the sql statement
      table - the table
      Returns:
      the parsed DML entry record or null if the SQL was not parsed
    • parseDelete

      private LogMinerDmlEntry parseDelete(String sql, Table table)
      Parses a SQL DELETE statement.
      Parameters:
      sql - the sql statement
      table - the table
      Returns:
      the parsed DML entry record or null if the SQL was not parsed
    • parseTableName

      private int parseTableName(String sql, int index)
      Parses a table-name in the SQL clause
      Parameters:
      sql - the sql statement
      index - the index into the sql statement to begin parsing
      Returns:
      the index into the sql string where the table name ended
    • parseColumnListClause

      private int parseColumnListClause(String sql, int start, String[] columnNames)
      Parse an INSERT statement's column-list clause.
      Parameters:
      sql - the sql statement
      start - the index into the sql statement to begin parsing
      columnNames - the list that will be populated with the column names
      Returns:
      the index into the sql string where the column-list clause ended
    • parseColumnValuesClause

      private int parseColumnValuesClause(String sql, int start, String[] columnNames, Object[] values, Table table)
      Parse an INSERT statement's column-values clause.
      Parameters:
      sql - the sql statement
      start - the index into the sql statement to begin parsing
      columnNames - the column names array, already indexed based on relational table column order
      values - the values array that will be populated with column values
      table - the relational table
      Returns:
      the index into the sql string where the column-values clause ended
    • parseSetClause

      private int parseSetClause(String sql, int start, Object[] newValues, Table table)
      Parse an UPDATE statement's SET clause.
      Parameters:
      sql - the sql statement
      start - the index into the sql statement to begin parsing
      newValues - the new values array to be populated
      table - the relational table
      Returns:
      the index into the sql string where the set-clause ended
    • parseWhereClause

      private int parseWhereClause(String sql, int start, Object[] values, Table table)
      Parses a WHERE clause populates the provided column names and values arrays.
      Parameters:
      sql - the sql statement
      start - the index into the sql statement to begin parsing
      values - the column values to be parsed from the where clause
      table - the relational table
      Returns:
      the index into the sql string to continue parsing
    • getColumnUnavailableValue

      private Object getColumnUnavailableValue(Object value, Column column)