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 asDATEandTIMESTAMP. 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 followingUPDATEstatement: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 forC1would beTO_TIMESTAMP('2020-02-02 00:00:00', 'YYYY-MM-DD HH24:MI:SS'). The old value forC1would beTO_TIMESTAMP('2020-02-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS').- Author:
- Chris Cranford
-
-
Field Summary
Fields Modifier and Type Field Description private static StringANDprivate static StringDELETE_FROMprivate static intDELETE_FROM_LENGTHprivate static StringINSERT_INTOprivate static intINSERT_INTO_LENGTHprivate static StringIS_NULLprivate static StringNULLprivate static StringNULL_SENTINELprivate static StringORprivate static StringSETprivate static intSET_LENGTHprivate static StringUNSUPPORTEDprivate static StringUNSUPPORTED_TYPEprivate static StringUPDATEprivate static intUPDATE_LENGTHprivate static StringVALUESprivate static intVALUES_LENGTHprivate static StringWHEREprivate static intWHERE_LENGTH
-
Constructor Summary
Constructors Constructor Description LogMinerDmlParser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private ObjectgetColumnUnavailableValue(Object value, Column column)LogMinerDmlEntryparse(String sql, Table table)Parse a DML SQL string from the LogMiner event stream.private intparseColumnListClause(String sql, int start, String[] columnNames)Parse anINSERTstatement's column-list clause.private intparseColumnValuesClause(String sql, int start, String[] columnNames, Object[] values, Table table)Parse anINSERTstatement's column-values clause.private LogMinerDmlEntryparseDelete(String sql, Table table)Parses a SQLDELETEstatement.private LogMinerDmlEntryparseInsert(String sql, Table table)Parse anINSERTSQL statement.private intparseSetClause(String sql, int start, Object[] newValues, Table table)Parse anUPDATEstatement'sSETclause.private intparseTableName(String sql, int index)Parses a table-name in the SQL clauseprivate LogMinerDmlEntryparseUpdate(String sql, Table table)Parse anUPDATESQL statement.private intparseWhereClause(String sql, int start, Object[] values, Table table)Parses aWHEREclause populates the provided column names and values arrays.
-
-
-
Field Detail
-
NULL_SENTINEL
private static final String NULL_SENTINEL
- See Also:
- Constant Field Values
-
NULL
private static final String NULL
- See Also:
- Constant Field Values
-
INSERT_INTO
private static final String INSERT_INTO
- See Also:
- Constant Field Values
-
UPDATE
private static final String UPDATE
- See Also:
- Constant Field Values
-
DELETE_FROM
private static final String DELETE_FROM
- See Also:
- Constant Field Values
-
AND
private static final String AND
- See Also:
- Constant Field Values
-
OR
private static final String OR
- See Also:
- Constant Field Values
-
SET
private static final String SET
- See Also:
- Constant Field Values
-
WHERE
private static final String WHERE
- See Also:
- Constant Field Values
-
VALUES
private static final String VALUES
- See Also:
- Constant Field Values
-
IS_NULL
private static final String IS_NULL
- See Also:
- Constant Field Values
-
UNSUPPORTED
private static final String UNSUPPORTED
- See Also:
- Constant Field Values
-
UNSUPPORTED_TYPE
private static final String UNSUPPORTED_TYPE
- See Also:
- Constant Field Values
-
INSERT_INTO_LENGTH
private static final int INSERT_INTO_LENGTH
-
UPDATE_LENGTH
private static final int UPDATE_LENGTH
-
DELETE_FROM_LENGTH
private static final int DELETE_FROM_LENGTH
-
VALUES_LENGTH
private static final int VALUES_LENGTH
-
SET_LENGTH
private static final int SET_LENGTH
-
WHERE_LENGTH
private static final int WHERE_LENGTH
-
-
Method Detail
-
parse
public LogMinerDmlEntry parse(String sql, Table table)
Description copied from interface:DmlParserParse a DML SQL string from the LogMiner event stream.
-
parseInsert
private LogMinerDmlEntry parseInsert(String sql, Table table)
Parse anINSERTSQL statement.- Parameters:
sql- the sql statementtable- the table- Returns:
- the parsed DML entry record or
nullif the SQL was not parsed
-
parseUpdate
private LogMinerDmlEntry parseUpdate(String sql, Table table)
Parse anUPDATESQL statement.- Parameters:
sql- the sql statementtable- the table- Returns:
- the parsed DML entry record or
nullif the SQL was not parsed
-
parseDelete
private LogMinerDmlEntry parseDelete(String sql, Table table)
Parses a SQLDELETEstatement.- Parameters:
sql- the sql statementtable- the table- Returns:
- the parsed DML entry record or
nullif 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 statementindex- 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 anINSERTstatement's column-list clause.- Parameters:
sql- the sql statementstart- the index into the sql statement to begin parsingcolumnNames- 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 anINSERTstatement's column-values clause.- Parameters:
sql- the sql statementstart- the index into the sql statement to begin parsingcolumnNames- the column names array, already indexed based on relational table column ordervalues- the values array that will be populated with column valuestable- 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 anUPDATEstatement'sSETclause.- Parameters:
sql- the sql statementstart- the index into the sql statement to begin parsingnewValues- the new values array to be populatedtable- 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 aWHEREclause populates the provided column names and values arrays.- Parameters:
sql- the sql statementstart- the index into the sql statement to begin parsingvalues- the column values to be parsed from the where clausetable- the relational table- Returns:
- the index into the sql string to continue parsing
-
-