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 Details

  • Constructor Details

    • LogMinerQueryBuilder

      public LogMinerQueryBuilder()
  • Method Details

    • build

      public static String build(OracleConnectorConfig connectorConfig)
      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 identifier where the change record was record from
           STATUS - the final LogMiner status for the row
           INFO - any information data provided by LogMiner
           SSN - the SQL sequence number for event ordering
           THREAD# - the redo thread number
           DATA_OBJ# - the data block object number identifying the object
           DATA_OBJV# - the version number of the table being modified
           DATA_OBJD# - the data block object number identifying the object within the tablespace
       
      Parameters:
      connectorConfig - connector configuration, should not be null
      Returns:
      the SQL string to be used to fetch changes from Oracle LogMiner
    • getOperationCodePredicate

      private static String getOperationCodePredicate(OracleConnectorConfig connectorConfig)
      Get the redo entry operation code predicate.
      Parameters:
      connectorConfig - connector configuration, should not be null
      Returns:
      operation code predicate, never null nor EMPTY.
    • getDdlPredicate

      private static String getDdlPredicate()
    • getMultiTenantPredicate

      private static String getMultiTenantPredicate(OracleConnectorConfig connectorConfig)
      Get the multi-tenant predicate based on the configured pluggable database name.
      Parameters:
      connectorConfig - connector configuration, should not be null
      Returns:
      multi-tenant predicate, may be an empty string if multi-tenancy is not enabled
    • getUserNamePredicate

      private static String getUserNamePredicate(OracleConnectorConfig connectorConfig)
      Generate a username based predicate for include/exclude usernames.
      Parameters:
      connectorConfig - connector configuration, should not be null
      Returns:
      the username predicate, may be an empty string if no predicate is generated
    • getSchemaNamePredicate

      private static String getSchemaNamePredicate(OracleConnectorConfig connectorConfig)
      Get the schema-based predicate.
      Parameters:
      connectorConfig - connector configuration, should not be null
      Returns:
      the schema predicate, may be an empty string if no predicate is generated
    • getTableNamePredicate

      private static String getTableNamePredicate(OracleConnectorConfig connectorConfig)
    • getSignalDataCollectionId

      private static Optional<TableId> getSignalDataCollectionId(OracleConnectorConfig connectorConfig)
    • tableIncludeListContains

      private static boolean tableIncludeListContains(Collection<String> values, TableId searchValue)
    • matches

      private static boolean matches(Collection<Pattern> patterns, String searchValue)
    • resolveExcludedSchemaPredicate

      private static String resolveExcludedSchemaPredicate(String fieldName)
      Resolve the built-in excluded schemas predicate.
      Parameters:
      fieldName - the query field name the predicate applies to, should never be null
      Returns:
      the predicate
    • getBuiltInExcludedSchemas

      private static List<String> getBuiltInExcludedSchemas()
    • getTableIncludeExcludeListAsInValueList

      private static List<String> getTableIncludeExcludeListAsInValueList(String list)
    • toUpperCase

      private static List<String> toUpperCase(Collection<String> values)