[INNER TABLE] Add column for quick restore related inner tables and views

This commit is contained in:
LoLolobster
2024-05-28 04:16:08 +00:00
committed by ob-robot
parent 0701cbb82b
commit ed5f4de50d
14 changed files with 90 additions and 13 deletions

View File

@ -2110,7 +2110,7 @@ int ObInnerTableSchema::dba_ob_restore_progress_ora_schema(ObTableSchema &table_
table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
if (OB_SUCC(ret)) {
if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT P.JOB_ID AS JOB_ID, RESTORE_TENANT_NAME, RESTORE_TENANT_ID, BACKUP_TENANT_NAME, BACKUP_TENANT_ID, BACKUP_CLUSTER_NAME, BACKUP_DEST, RESTORE_OPTION, RESTORE_SCN, CASE WHEN RESTORE_SCN IS NULL THEN NULL ELSE SCN_TO_TIMESTAMP(RESTORE_SCN) END AS RESTORE_SCN_DISPLAY, CASE WHEN STATUS = 'RESTORE_PRE' THEN 'RESTORING' WHEN STATUS = 'RESTORE_CREATE_INIT_LS' THEN 'RESTORING' WHEN STATUS = 'RESTORE_WAIT_LS' THEN 'RESTORING' WHEN STATUS = 'POST_CHECK' THEN 'RESTORING' ELSE STATUS END AS STATUS, CASE WHEN START_TIMESTAMP IS NULL THEN NULL WHEN START_TIMESTAMP='' THEN NULL WHEN START_TIMESTAMP='0' THEN NULL ELSE TO_CHAR(TO_NUMBER(START_TIMESTAMP) / (1000 * 60 * 60 * 24 * 1000) + TO_DATE('1970-01-01 08:00:00', 'yyyy-mm-dd hh:mi:ss'), 'yyyy-mm-dd hh24:mi:ss') END AS START_TIMESTAMP, BACKUP_SET_LIST, BACKUP_PIECE_LIST, TOTAL_BYTES, CASE WHEN TOTAL_BYTES >= 1024*1024*1024*1024*1024 THEN CONCAT(ROUND(TOTAL_BYTES/1024/1024/1024/1024/1024,2), 'PB') WHEN TOTAL_BYTES >= 1024*1024*1024*1024 THEN CONCAT(ROUND(TOTAL_BYTES/1024/1024/1024/1024,2), 'TB') WHEN TOTAL_BYTES >= 1024*1024*1024 THEN CONCAT(ROUND(TOTAL_BYTES/1024/1024/1024,2), 'GB') ELSE CONCAT(ROUND(TOTAL_BYTES/1024/1024,2), 'MB') END AS TOTAL_BYTES_DISPLAY, FINISH_BYTES, CASE WHEN FINISH_BYTES >= 1024*1024*1024*1024*1024 THEN CONCAT(ROUND(FINISH_BYTES/1024/1024/1024/1024/1024,2), 'PB') WHEN FINISH_BYTES >= 1024*1024*1024*1024 THEN CONCAT(ROUND(FINISH_BYTES/1024/1024/1024/1024,2), 'TB') WHEN FINISH_BYTES >= 1024*1024*1024 THEN CONCAT(ROUND(FINISH_BYTES/1024/1024/1024,2), 'GB') ELSE CONCAT(ROUND(FINISH_BYTES/1024/1024,2), 'MB') END AS FINISH_BYTES_DISPLAY, DESCRIPTION FROM ( SELECT TENANT_ID, JOB_ID, MAX(CASE NAME WHEN 'tenant_name' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS RESTORE_TENANT_NAME, MAX(CASE NAME WHEN 'tenant_id' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS RESTORE_TENANT_ID, MAX(CASE NAME WHEN 'backup_tenant_name' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS BACKUP_TENANT_NAME, MAX(CASE NAME WHEN 'backup_tenant_id' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS BACKUP_TENANT_ID, MAX(CASE NAME WHEN 'backup_cluster_name' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS BACKUP_CLUSTER_NAME, MAX(CASE NAME WHEN 'target_tenant_role' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS TENANT_ROLE, MAX(CASE NAME WHEN 'backup_dest' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS BACKUP_DEST, MAX(CASE NAME WHEN 'restore_option' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS RESTORE_OPTION, MAX(CASE NAME WHEN 'status' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS STATUS, MAX(CASE NAME WHEN 'restore_scn' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS RESTORE_SCN, MAX(CASE NAME WHEN 'restore_start_ts' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS START_TIMESTAMP, MAX(CASE NAME WHEN 'backup_set_list' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS BACKUP_SET_LIST, MAX(CASE NAME WHEN 'backup_piece_list' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS BACKUP_PIECE_LIST, MAX(CASE NAME WHEN 'description' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS DESCRIPTION FROM SYS.ALL_VIRTUAL_RESTORE_JOB GROUP BY TENANT_ID, JOB_ID ) P LEFT JOIN ( SELECT TENANT_ID, JOB_ID, TOTAL_BYTES, FINISH_BYTES FROM SYS.ALL_VIRTUAL_RESTORE_PROGRESS ) J ON P.TENANT_ID=J.TENANT_ID AND P.JOB_ID=J.JOB_ID WHERE P.TENANT_ID = EFFECTIVE_TENANT_ID() )__"))) {
if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT P.JOB_ID AS JOB_ID, RESTORE_TENANT_NAME, RESTORE_TENANT_ID, BACKUP_TENANT_NAME, BACKUP_TENANT_ID, BACKUP_CLUSTER_NAME, BACKUP_DEST, RESTORE_OPTION, RESTORE_TYPE, RESTORE_SCN, CASE WHEN RESTORE_SCN IS NULL THEN NULL ELSE SCN_TO_TIMESTAMP(RESTORE_SCN) END AS RESTORE_SCN_DISPLAY, CASE WHEN STATUS = 'RESTORE_PRE' THEN 'RESTORING' WHEN STATUS = 'RESTORE_CREATE_INIT_LS' THEN 'RESTORING' WHEN STATUS = 'RESTORE_WAIT_LS' THEN 'RESTORING' WHEN STATUS = 'POST_CHECK' THEN 'RESTORING' ELSE STATUS END AS STATUS, CASE WHEN START_TIMESTAMP IS NULL THEN NULL WHEN START_TIMESTAMP='' THEN NULL WHEN START_TIMESTAMP='0' THEN NULL ELSE TO_CHAR(TO_NUMBER(START_TIMESTAMP) / (1000 * 60 * 60 * 24 * 1000) + TO_DATE('1970-01-01 08:00:00', 'yyyy-mm-dd hh:mi:ss'), 'yyyy-mm-dd hh24:mi:ss') END AS START_TIMESTAMP, BACKUP_SET_LIST, BACKUP_PIECE_LIST, TOTAL_BYTES, CASE WHEN TOTAL_BYTES >= 1024*1024*1024*1024*1024 THEN CONCAT(ROUND(TOTAL_BYTES/1024/1024/1024/1024/1024,2), 'PB') WHEN TOTAL_BYTES >= 1024*1024*1024*1024 THEN CONCAT(ROUND(TOTAL_BYTES/1024/1024/1024/1024,2), 'TB') WHEN TOTAL_BYTES >= 1024*1024*1024 THEN CONCAT(ROUND(TOTAL_BYTES/1024/1024/1024,2), 'GB') ELSE CONCAT(ROUND(TOTAL_BYTES/1024/1024,2), 'MB') END AS TOTAL_BYTES_DISPLAY, FINISH_BYTES, CASE WHEN FINISH_BYTES >= 1024*1024*1024*1024*1024 THEN CONCAT(ROUND(FINISH_BYTES/1024/1024/1024/1024/1024,2), 'PB') WHEN FINISH_BYTES >= 1024*1024*1024*1024 THEN CONCAT(ROUND(FINISH_BYTES/1024/1024/1024/1024,2), 'TB') WHEN FINISH_BYTES >= 1024*1024*1024 THEN CONCAT(ROUND(FINISH_BYTES/1024/1024/1024,2), 'GB') ELSE CONCAT(ROUND(FINISH_BYTES/1024/1024,2), 'MB') END AS FINISH_BYTES_DISPLAY, DESCRIPTION FROM ( SELECT TENANT_ID, JOB_ID, MAX(CASE NAME WHEN 'tenant_name' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS RESTORE_TENANT_NAME, MAX(CASE NAME WHEN 'tenant_id' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS RESTORE_TENANT_ID, MAX(CASE NAME WHEN 'backup_tenant_name' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS BACKUP_TENANT_NAME, MAX(CASE NAME WHEN 'backup_tenant_id' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS BACKUP_TENANT_ID, MAX(CASE NAME WHEN 'backup_cluster_name' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS BACKUP_CLUSTER_NAME, MAX(CASE NAME WHEN 'target_tenant_role' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS TENANT_ROLE, MAX(CASE NAME WHEN 'backup_dest' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS BACKUP_DEST, MAX(CASE NAME WHEN 'restore_option' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS RESTORE_OPTION, MAX(CASE NAME WHEN 'status' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS STATUS, MAX(CASE NAME WHEN 'restore_scn' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS RESTORE_SCN, MAX(CASE NAME WHEN 'restore_start_ts' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS START_TIMESTAMP, MAX(CASE NAME WHEN 'backup_set_list' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS BACKUP_SET_LIST, MAX(CASE NAME WHEN 'backup_piece_list' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS BACKUP_PIECE_LIST, MAX(CASE NAME WHEN 'description' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS DESCRIPTION, MAX(CASE NAME WHEN 'restore_type' THEN CAST(VALUE AS VARCHAR2(4096)) ELSE '' END) AS RESTORE_TYPE FROM SYS.ALL_VIRTUAL_RESTORE_JOB GROUP BY TENANT_ID, JOB_ID ) P LEFT JOIN ( SELECT TENANT_ID, JOB_ID, TOTAL_BYTES, FINISH_BYTES FROM SYS.ALL_VIRTUAL_RESTORE_PROGRESS ) J ON P.TENANT_ID=J.TENANT_ID AND P.JOB_ID=J.JOB_ID WHERE P.TENANT_ID = EFFECTIVE_TENANT_ID() )__"))) {
LOG_ERROR("fail to set view_definition", K(ret));
}
}
@ -2160,7 +2160,7 @@ int ObInnerTableSchema::dba_ob_restore_history_ora_schema(ObTableSchema &table_s
table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
if (OB_SUCC(ret)) {
if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT JOB_ID, RESTORE_TENANT_NAME, RESTORE_TENANT_ID, BACKUP_TENANT_NAME, BACKUP_TENANT_ID, BACKUP_CLUSTER_NAME, BACKUP_DEST, RESTORE_SCN, SCN_TO_TIMESTAMP(RESTORE_SCN) AS RESTORE_SCN_DISPLAY, RESTORE_OPTION, START_TIME AS START_TIMESTAMP, FINISH_TIME AS FINISH_TIMESTAMP, STATUS, BACKUP_PIECE_LIST, BACKUP_SET_LIST, BACKUP_CLUSTER_VERSION, LS_COUNT, FINISH_LS_COUNT, TABLET_COUNT, FINISH_TABLET_COUNT, TOTAL_BYTES, CASE WHEN TOTAL_BYTES >= 1024*1024*1024*1024*1024 THEN CONCAT(ROUND(TOTAL_BYTES/1024/1024/1024/1024/1024,2), 'PB') WHEN TOTAL_BYTES >= 1024*1024*1024*1024 THEN CONCAT(ROUND(TOTAL_BYTES/1024/1024/1024/1024,2), 'TB') WHEN TOTAL_BYTES >= 1024*1024*1024 THEN CONCAT(ROUND(TOTAL_BYTES/1024/1024/1024,2), 'GB') ELSE CONCAT(ROUND(TOTAL_BYTES/1024/1024,2), 'MB') END AS TOTAL_BYTES_DISPLAY, FINISH_BYTES, CASE WHEN FINISH_BYTES >= 1024*1024*1024*1024*1024 THEN CONCAT(ROUND(FINISH_BYTES/1024/1024/1024/1024/1024,2), 'PB') WHEN FINISH_BYTES >= 1024*1024*1024*1024 THEN CONCAT(ROUND(FINISH_BYTES/1024/1024/1024/1024,2), 'TB') WHEN FINISH_BYTES >= 1024*1024*1024 THEN CONCAT(ROUND(FINISH_BYTES/1024/1024/1024,2), 'GB') ELSE CONCAT(ROUND(FINISH_BYTES/1024/1024,2), 'MB') END AS FINISH_BYTES_DISPLAY, DESCRIPTION, "COMMENT" FROM SYS.ALL_VIRTUAL_RESTORE_JOB_HISTORY WHERE TENANT_ID = EFFECTIVE_TENANT_ID() )__"))) {
if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT JOB_ID, RESTORE_TENANT_NAME, RESTORE_TENANT_ID, BACKUP_TENANT_NAME, BACKUP_TENANT_ID, BACKUP_CLUSTER_NAME, BACKUP_DEST, RESTORE_SCN, SCN_TO_TIMESTAMP(RESTORE_SCN) AS RESTORE_SCN_DISPLAY, RESTORE_OPTION, RESTORE_TYPE, START_TIME AS START_TIMESTAMP, FINISH_TIME AS FINISH_TIMESTAMP, STATUS, BACKUP_PIECE_LIST, BACKUP_SET_LIST, BACKUP_CLUSTER_VERSION, LS_COUNT, FINISH_LS_COUNT, TABLET_COUNT, FINISH_TABLET_COUNT, TOTAL_BYTES, CASE WHEN TOTAL_BYTES >= 1024*1024*1024*1024*1024 THEN CONCAT(ROUND(TOTAL_BYTES/1024/1024/1024/1024/1024,2), 'PB') WHEN TOTAL_BYTES >= 1024*1024*1024*1024 THEN CONCAT(ROUND(TOTAL_BYTES/1024/1024/1024/1024,2), 'TB') WHEN TOTAL_BYTES >= 1024*1024*1024 THEN CONCAT(ROUND(TOTAL_BYTES/1024/1024/1024,2), 'GB') ELSE CONCAT(ROUND(TOTAL_BYTES/1024/1024,2), 'MB') END AS TOTAL_BYTES_DISPLAY, FINISH_BYTES, CASE WHEN FINISH_BYTES >= 1024*1024*1024*1024*1024 THEN CONCAT(ROUND(FINISH_BYTES/1024/1024/1024/1024/1024,2), 'PB') WHEN FINISH_BYTES >= 1024*1024*1024*1024 THEN CONCAT(ROUND(FINISH_BYTES/1024/1024/1024/1024,2), 'TB') WHEN FINISH_BYTES >= 1024*1024*1024 THEN CONCAT(ROUND(FINISH_BYTES/1024/1024/1024,2), 'GB') ELSE CONCAT(ROUND(FINISH_BYTES/1024/1024,2), 'MB') END AS FINISH_BYTES_DISPLAY, DESCRIPTION, "COMMENT" FROM SYS.ALL_VIRTUAL_RESTORE_JOB_HISTORY WHERE TENANT_ID = EFFECTIVE_TENANT_ID() )__"))) {
LOG_ERROR("fail to set view_definition", K(ret));
}
}