public class LogMinerDmlParser extends Object implements DmlParser
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').| Modifier and Type | Field and Description |
|---|---|
private static String |
AND |
private static String |
DELETE_FROM |
private static int |
DELETE_FROM_LENGTH |
private static String |
INSERT_INTO |
private static int |
INSERT_INTO_LENGTH |
private static String |
IS_NULL |
private static String |
NULL |
private static String |
OR |
private static String |
SET |
private static int |
SET_LENGTH |
private static String |
SINGLE_QUOTE |
private static String |
UNSUPPORTED |
private static String |
UNSUPPORTED_TYPE |
private static String |
UPDATE |
private static int |
UPDATE_LENGTH |
private static String |
VALUES |
private static int |
VALUES_LENGTH |
private static String |
WHERE |
private static int |
WHERE_LENGTH |
| Constructor and Description |
|---|
LogMinerDmlParser() |
| Modifier and Type | Method and Description |
|---|---|
private static LogMinerColumnValue |
createColumnValue(String columnName,
String columnValue)
Helper method to create a
LogMinerColumnValue from a column name/value pair. |
private static <K,V> Map<K,V> |
createMap(List<K> keys,
List<V> values) |
LogMinerDmlEntry |
parse(String sql,
Table table,
String txId)
Parse a DML SQL string from the LogMiner event stream.
|
private int |
parseColumnListClause(String sql,
int start,
List<String> columnNames)
Parse an
INSERT statement's column-list clause. |
private int |
parseColumnValuesClause(String sql,
int start,
List<String> columnValues)
Parse an
INSERT statement's column-values clause. |
private LogMinerDmlEntry |
parseDelete(String sql,
Table table)
Parses a SQL
DELETE statement. |
private LogMinerDmlEntry |
parseInsert(String sql,
Table table)
Parse an
INSERT SQL statement. |
private int |
parseSetClause(String sql,
int start,
List<String> columnNames,
List<String> columnValues)
Parse an
UPDATE statement's SET clause. |
private int |
parseTableName(String sql,
int index)
Parses a table-name in the SQL clause
|
private LogMinerDmlEntry |
parseUpdate(String sql,
Table table)
Parse an
UPDATE SQL statement. |
private int |
parseWhereClause(String sql,
int start,
List<String> columnNames,
List<String> columnValues)
Parses a
WHERE clause populates the provided column names and values arrays. |
private static String |
removeSingleQuotes(String text)
Remove
' quotes from around the provided text if they exist; otherwise the value is returned as-is. |
private static final String SINGLE_QUOTE
private static final String NULL
private static final String INSERT_INTO
private static final String UPDATE
private static final String DELETE_FROM
private static final String AND
private static final String OR
private static final String SET
private static final String WHERE
private static final String VALUES
private static final String IS_NULL
private static final String UNSUPPORTED
private static final String UNSUPPORTED_TYPE
private static final int INSERT_INTO_LENGTH
private static final int UPDATE_LENGTH
private static final int DELETE_FROM_LENGTH
private static final int VALUES_LENGTH
private static final int SET_LENGTH
private static final int WHERE_LENGTH
public LogMinerDmlEntry parse(String sql, Table table, String txId)
DmlParserprivate LogMinerDmlEntry parseInsert(String sql, Table table)
INSERT SQL statement.sql - the sql statementtable - the tablenull if the SQL was not parsedprivate LogMinerDmlEntry parseUpdate(String sql, Table table)
UPDATE SQL statement.sql - the sql statementtable - the tablenull if the SQL was not parsedprivate LogMinerDmlEntry parseDelete(String sql, Table table)
DELETE statement.sql - the sql statementtable - the tablenull if the SQL was not parsedprivate int parseTableName(String sql, int index)
sql - the sql statementindex - the index into the sql statement to begin parsingprivate int parseColumnListClause(String sql, int start, List<String> columnNames)
INSERT statement's column-list clause.sql - the sql statementstart - the index into the sql statement to begin parsingcolumnNames - the list that will be populated with the column namesprivate int parseColumnValuesClause(String sql, int start, List<String> columnValues)
INSERT statement's column-values clause.sql - the sql statementstart - the index into the sql statement to begin parsingcolumnValues - the list of that will populated with the column valuesprivate int parseSetClause(String sql, int start, List<String> columnNames, List<String> columnValues)
UPDATE statement's SET clause.sql - the sql statementstart - the index into the sql statement to begin parsingcolumnNames - the list of the changed column names that will be populatedcolumnValues - the list of the changed column values that will be populatedprivate int parseWhereClause(String sql, int start, List<String> columnNames, List<String> columnValues)
WHERE clause populates the provided column names and values arrays.sql - the sql statementstart - the index into the sql statement to begin parsingcolumnNames - the column names parsed from the clausecolumnValues - the column values parsed from the clauseprivate static String removeSingleQuotes(String text)
' quotes from around the provided text if they exist; otherwise the value is returned as-is.text - the text to remove single quotesprivate static LogMinerColumnValue createColumnValue(String columnName, String columnValue)
LogMinerColumnValue from a column name/value pair.columnName - the column namecolumnValue - the column valueCopyright © 2021 JBoss by Red Hat. All rights reserved.