Class SqlUtils
- java.lang.Object
-
- io.debezium.connector.oracle.logminer.SqlUtils
-
public class SqlUtils extends Object
This utility class contains SQL statements to configure, manage and query Oracle LogMiner todo handle INVALID file member (report somehow and continue to work with valid file), handle adding multiplexed files, todo SELECT name, value FROM v$sysstat WHERE name = 'redo wastage'; todo SELECT GROUP#, STATUS, MEMBER FROM V$LOGFILE WHERE STATUS='INVALID'; (drop and recreate? or do it manually?) todo table level supplemental logging todo When you use the SKIP_CORRUPTION option to DBMS_LOGMNR.START_LOGMNR, any corruptions in the redo log files are skipped during select operations from the V$LOGMNR_CONTENTS view. todo if file is compressed? // For every corrupt redo record encountered, // a row is returned that contains the value CORRUPTED_BLOCKS in the OPERATION column, 1343 in the STATUS column, and the number of blocks skipped in the INFO column.
-
-
Field Summary
Fields Modifier and Type Field Description private static StringALL_LOG_GROUPSprivate static StringARCHIVE_DEST_STATUS_VIEWprivate static StringARCHIVED_LOG_VIEW(package private) static StringBUILD_DICTIONARY(package private) static StringCREATE_FLUSH_TABLEprivate static StringDATABASE_VIEW(package private) static StringEND_LOGMNR(package private) static StringFILES_FOR_MININGQuerying V$LOGMNR_LOGS After a successful call to DBMS_LOGMNR.START_LOGMNR, the STATUS column of the V$LOGMNR_LOGS view contains one of the following values: 0 Indicates that the redo log file will be processed during a query of the V$LOGMNR_CONTENTS view.(package private) static StringFLUSH_TABLE_NOT_EMPTY(package private) static StringINSERT_FLUSH_TABLEprivate static StringLOG_VIEWprivate static StringLOGFILE_VIEWprivate static org.slf4j.LoggerLOGGERprivate static StringLOGMNR_CONTENTS_VIEWstatic StringLOGMNR_FLUSH_TABLE(package private) static StringNLS_SESSION_PARAMETERS(package private) static StringSELECT_SYSTIMESTAMP(package private) static StringUPDATE_FLUSH_TABLE
-
Constructor Summary
Constructors Constructor Description SqlUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static StringaddLogFileStatement(String option, String fileName)static StringallMinableLogsQuery(Scn scn, Duration archiveLogRetention, boolean archiveLogOnlyMode)Obtain a query to fetch all available minable logs, both archive and online redo logs.private static StringbuildSchemaPredicate(OracleConnectorConfig connectorConfig)private static StringbuildTablePredicate(OracleConnectorConfig connectorConfig)static booleanconnectionProblem(Throwable e)(package private) static StringcurrentRedoLogSequenceQuery()(package private) static StringcurrentRedoNameQuery()(package private) static StringcurrentScnQuery()(package private) static StringdatabaseSupplementalLoggingAllCheckQuery()(package private) static StringdatabaseSupplementalLoggingMinCheckQuery()(package private) static StringdeleteLogFileStatement(String fileName)static StringdiffInDaysQuery(Scn scn)This method return query which converts given SCN in days and deduct from the current day(package private) static StringdropTableStatement(String tableName)private static StringgetExcludedDdlTables()private static StringgetExcludedUsers(String logMinerUser)private static StringlistOfPatternsToSql(List<Pattern> patterns, String columnName, boolean applyNot)private static StringlocalArchiveLogDestinationsOnlyQuery()Returns a SQL predicate clause that should be applied to anyARCHIVED_LOG_VIEWqueries so that the results are filtered to only include the local destinations and not those that may be generated by tools such as Oracle Data Guard.(package private) static StringlogMinerContentsQuery(OracleConnectorConfig connectorConfig, String logMinerUser)This is the query from the LogMiner view to get changes.(package private) static StringlogMiningHistoryDdl(String tableName)(package private) static StringoldestFirstChangeQuery(Duration archiveLogRetention)(package private) static StringredoLogStatusQuery()private static StringresolveRegExpLikePattern(Pattern pattern)(package private) static voidsetRac(boolean isRac)(package private) static StringstartLogMinerStatement(Scn startScn, Scn endScn, OracleConnectorConfig.LogMiningStrategy strategy, boolean isContinuousMining)This returns statement to build LogMiner view for online redo log files(package private) static StringswitchHistoryQuery()(package private) static StringtableExistsQuery(String tableName)(package private) static StringtableSupplementalLoggingCheckQuery(TableId tableId)(package private) static StringtruncateTableStatement(String tableName)
-
-
-
Field Detail
-
DATABASE_VIEW
private static final String DATABASE_VIEW
- See Also:
- Constant Field Values
-
LOG_VIEW
private static final String LOG_VIEW
- See Also:
- Constant Field Values
-
LOGFILE_VIEW
private static final String LOGFILE_VIEW
- See Also:
- Constant Field Values
-
ARCHIVED_LOG_VIEW
private static final String ARCHIVED_LOG_VIEW
- See Also:
- Constant Field Values
-
ARCHIVE_DEST_STATUS_VIEW
private static final String ARCHIVE_DEST_STATUS_VIEW
- See Also:
- Constant Field Values
-
LOGMNR_CONTENTS_VIEW
private static final String LOGMNR_CONTENTS_VIEW
- See Also:
- Constant Field Values
-
ALL_LOG_GROUPS
private static final String ALL_LOG_GROUPS
- See Also:
- Constant Field Values
-
BUILD_DICTIONARY
static final String BUILD_DICTIONARY
- See Also:
- Constant Field Values
-
SELECT_SYSTIMESTAMP
static final String SELECT_SYSTIMESTAMP
- See Also:
- Constant Field Values
-
END_LOGMNR
static final String END_LOGMNR
- See Also:
- Constant Field Values
-
FILES_FOR_MINING
static final String FILES_FOR_MINING
Querying V$LOGMNR_LOGS After a successful call to DBMS_LOGMNR.START_LOGMNR, the STATUS column of the V$LOGMNR_LOGS view contains one of the following values: 0 Indicates that the redo log file will be processed during a query of the V$LOGMNR_CONTENTS view. 1 Indicates that this will be the first redo log file to be processed by LogMiner during a select operation against the V$LOGMNR_CONTENTS view. 2 Indicates that the redo log file has been pruned and therefore will not be processed by LogMiner during a query of the V$LOGMNR_CONTENTS view. It has been pruned because it is not needed to satisfy your requested time or SCN range. 4 Indicates that a redo log file (based on sequence number) is missing from the LogMiner redo log file list.- See Also:
- Constant Field Values
-
LOGMNR_FLUSH_TABLE
public static final String LOGMNR_FLUSH_TABLE
- See Also:
- Constant Field Values
-
FLUSH_TABLE_NOT_EMPTY
static final String FLUSH_TABLE_NOT_EMPTY
- See Also:
- Constant Field Values
-
CREATE_FLUSH_TABLE
static final String CREATE_FLUSH_TABLE
- See Also:
- Constant Field Values
-
INSERT_FLUSH_TABLE
static final String INSERT_FLUSH_TABLE
- See Also:
- Constant Field Values
-
UPDATE_FLUSH_TABLE
static final String UPDATE_FLUSH_TABLE
- See Also:
- Constant Field Values
-
NLS_SESSION_PARAMETERS
static final String NLS_SESSION_PARAMETERS
- See Also:
- Constant Field Values
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
-
Method Detail
-
setRac
static void setRac(boolean isRac)
-
redoLogStatusQuery
static String redoLogStatusQuery()
-
switchHistoryQuery
static String switchHistoryQuery()
-
currentRedoNameQuery
static String currentRedoNameQuery()
-
currentRedoLogSequenceQuery
static String currentRedoLogSequenceQuery()
-
databaseSupplementalLoggingAllCheckQuery
static String databaseSupplementalLoggingAllCheckQuery()
-
databaseSupplementalLoggingMinCheckQuery
static String databaseSupplementalLoggingMinCheckQuery()
-
tableSupplementalLoggingCheckQuery
static String tableSupplementalLoggingCheckQuery(TableId tableId)
-
currentScnQuery
static String currentScnQuery()
-
allMinableLogsQuery
public static String allMinableLogsQuery(Scn scn, Duration archiveLogRetention, boolean archiveLogOnlyMode)
Obtain a query to fetch all available minable logs, both archive and online redo logs.- Parameters:
scn- oldest system change number to search byarchiveLogRetention- duration archive logs will be minedarchiveLogOnlyMode- true if to only mine archive logs, false to mine all available logs- Returns:
- the query string to obtain minable log files
-
localArchiveLogDestinationsOnlyQuery
private static String localArchiveLogDestinationsOnlyQuery()
Returns a SQL predicate clause that should be applied to anyARCHIVED_LOG_VIEWqueries so that the results are filtered to only include the local destinations and not those that may be generated by tools such as Oracle Data Guard.
-
startLogMinerStatement
static String startLogMinerStatement(Scn startScn, Scn endScn, OracleConnectorConfig.LogMiningStrategy strategy, boolean isContinuousMining)
This returns statement to build LogMiner view for online redo log files- Parameters:
startScn- mine fromendScn- mine tillstrategy- Log Mining strategy- Returns:
- statement todo: handle corruption. STATUS (Double) — value of 0 indicates it is executable
-
logMinerContentsQuery
static String logMinerContentsQuery(OracleConnectorConfig connectorConfig, String logMinerUser)
This is the query from the LogMiner view to get changes. The query uses the following columns from the view:SCN - The SCN at which a change was made SQL_REDO Reconstructed SQL statement that is equivalent to the original SQL statement that made the change OPERATION_CODE - Number of the operation code TIMESTAMP - Timestamp when the database change was made XID - Transaction Identifier CSF - Continuation SQL flag, identifies rows that should be processed together as a single row (0=no,1=yes) TABLE_NAME - Name of the modified table SEG_OWNER - Schema/Tablespace name OPERATION - Database operation type USERNAME - Name of the user who executed the transaction
- Parameters:
connectorConfig- the connector configurationlogMinerUser- log mining session user name- Returns:
- the query
-
getExcludedDdlTables
private static String getExcludedDdlTables()
-
buildSchemaPredicate
private static String buildSchemaPredicate(OracleConnectorConfig connectorConfig)
-
buildTablePredicate
private static String buildTablePredicate(OracleConnectorConfig connectorConfig)
-
listOfPatternsToSql
private static String listOfPatternsToSql(List<Pattern> patterns, String columnName, boolean applyNot)
-
diffInDaysQuery
public static String diffInDaysQuery(Scn scn)
This method return query which converts given SCN in days and deduct from the current day
-
connectionProblem
public static boolean connectionProblem(Throwable e)
-
-