Class LogMinerDmlParser
java.lang.Object
io.debezium.connector.oracle.logminer.parser.LogMinerDmlParser
- All Implemented Interfaces:
DmlParser
- Direct Known Subclasses:
LogMinerColumnResolverDmlParser
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 Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final Stringprivate static final intprivate static final Stringprivate static final intprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final intprivate static final Stringprivate static final Stringprivate static final Stringprivate static final intprivate static final Stringprivate static final intprivate static final Stringprivate static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected intgetColumnIndexByName(String columnName, Table table) Calculates the column index by the column name.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 Details
-
NULL_SENTINEL
- See Also:
-
NULL
- See Also:
-
INSERT_INTO
- See Also:
-
UPDATE
- See Also:
-
DELETE_FROM
- See Also:
-
AND
- See Also:
-
OR
- See Also:
-
SET
- See Also:
-
WHERE
- See Also:
-
VALUES
- See Also:
-
IS_NULL
- See Also:
-
UNSUPPORTED
- See Also:
-
UNSUPPORTED_TYPE
- See Also:
-
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
-
-
Constructor Details
-
LogMinerDmlParser
public LogMinerDmlParser()
-
-
Method Details
-
parse
Description copied from interface:DmlParserParse a DML SQL string from the LogMiner event stream. -
getColumnIndexByName
Calculates the column index by the column name.- Parameters:
columnName- the column nametable- the relational table mode, should not benull- Returns:
- the column's index
-
parseInsert
Parse anINSERTSQL statement.- Parameters:
sql- the sql statementtable- the table- Returns:
- the parsed DML entry record or
nullif the SQL was not parsed
-
parseUpdate
Parse anUPDATESQL statement.- Parameters:
sql- the sql statementtable- the table- Returns:
- the parsed DML entry record or
nullif the SQL was not parsed
-
parseDelete
Parses a SQLDELETEstatement.- Parameters:
sql- the sql statementtable- the table- Returns:
- the parsed DML entry record or
nullif the SQL was not parsed
-
parseTableName
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
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
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
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
-