Class LogMinerQueryBuilder
- java.lang.Object
-
- io.debezium.connector.oracle.logminer.LogMinerQueryBuilder
-
public class LogMinerQueryBuilder extends Object
A builder that is responsible for producing the query to be executed against the LogMiner view.- Author:
- Chris Cranford
-
-
Field Summary
Fields Modifier and Type Field Description private static StringLOGMNR_CONTENTS_VIEW
-
Constructor Summary
Constructors Constructor Description LogMinerQueryBuilder()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stringbuild(OracleConnectorConfig connectorConfig, OracleDatabaseSchema schema)Builds the LogMiner contents view query.private static StringbuildDdlPredicate(String pdbPredicate)Builds a common SQL fragment used to obtain DDL operations via LogMiner.private static StringbuildSchemaPredicate(OracleConnectorConfig connectorConfig)Builds a SQL predicate of what schemas to include/exclude based on the connector configuration.private static StringbuildTablePredicate(OracleConnectorConfig connectorConfig)Builds a SQL predicate of what tables to include/exclude based on the connector configuration.private static StringlistOfPatternsToSql(List<Pattern> patterns, String columnName, boolean inclusion)Takes a list of reg-ex patterns and builds an Oracle-specific predicate usingREGEXP_LIKEin order to take the connector configuration include/exclude lists and assemble them as SQL predicates.private static StringresolveExcludedSchemaPredicate(String fieldName)Resolve the built-in excluded schemas predicate.private static StringresolveRegExpLikePattern(Pattern pattern)TheREGEXP_LIKEOracle operator acts identical to theLIKEoperator.
-
-
-
Field Detail
-
LOGMNR_CONTENTS_VIEW
private static final String LOGMNR_CONTENTS_VIEW
- See Also:
- Constant Field Values
-
-
Method Detail
-
build
public static String build(OracleConnectorConfig connectorConfig, OracleDatabaseSchema schema)
Builds the LogMiner contents view query. The returned query will contain 2 bind parameters that the caller is responsible for binding before executing the query. The first bind parameter is the lower-bounds of the SCN mining window that is not-inclusive while the second is the upper-bounds of the SCN mining window that is inclusive. The built query relies on the following columns from V$LOGMNR_CONTENTS:SCN - the system change number at which the change was made SQL_REDO - the reconstructed SQL statement that initiated the change OPERATION - the database operation type name OPERATION_CODE - the database operation numeric code TIMESTAMP - the time when the change event occurred XID - the transaction identifier the change participated in CSF - the continuation flag, identifies rows that should be processed together as single row, 0=no, 1=yes TABLE_NAME - the name of the table for which the change is for SEG_OWNER - the name of the schema for which the change is for USERNAME - the name of the database user that caused the change ROW_ID - the unique identifier of the row that the change is for, may not always be set with valid value ROLLBACK - the rollback flag, value of 0 or 1. 1 implies the row was rolled back RS_ID - the rollback segment idenifier where the change record was record from- Parameters:
connectorConfig- connector configuration, should not benullschema- database schema, should not benull- Returns:
- the SQL string to be used to fetch changes from Oracle LogMiner
-
buildDdlPredicate
private static String buildDdlPredicate(String pdbPredicate)
Builds a common SQL fragment used to obtain DDL operations via LogMiner.- Parameters:
pdbPredicate- pluggable database predicate, maybenull- Returns:
- predicate that can be used to obtain DDL operations via LogMiner
-
buildSchemaPredicate
private static String buildSchemaPredicate(OracleConnectorConfig connectorConfig)
Builds a SQL predicate of what schemas to include/exclude based on the connector configuration.- Parameters:
connectorConfig- connector configuration, should not benull- Returns:
- SQL predicate to filter results based on schema include/exclude configurations
-
buildTablePredicate
private static String buildTablePredicate(OracleConnectorConfig connectorConfig)
Builds a SQL predicate of what tables to include/exclude based on the connector configuration.- Parameters:
connectorConfig- connector configuration, should not benull- Returns:
- SQL predicate to filter results based on table include/exclude configuration
-
listOfPatternsToSql
private static String listOfPatternsToSql(List<Pattern> patterns, String columnName, boolean inclusion)
Takes a list of reg-ex patterns and builds an Oracle-specific predicate usingREGEXP_LIKEin order to take the connector configuration include/exclude lists and assemble them as SQL predicates.- Parameters:
patterns- list of each individual include/exclude reg-ex patterns from connector configurationcolumnName- the column in which the reg-ex patterns are to be applied againstinclusion- should betruewhen passing inclusion patterns,falseotherwise- Returns:
-
resolveRegExpLikePattern
private static String resolveRegExpLikePattern(Pattern pattern)
TheREGEXP_LIKEOracle operator acts identical to theLIKEoperator. Internally, it prepends and appends a "%" qualifier. The include/exclude lists are meant to be explicit in that they have an implied "^" and "$" qualifier for start/end so that the LIKE operation does not mistakently filter "DEBEZIUM2" when using the reg-ex of "DEBEZIUM".- Parameters:
pattern- the pattern to be analyzed, should not benull- Returns:
- the adjusted predicate, if necessary and doesn't already explicitly specify "^" or "$"
-
-