diff --git a/src/rootserver/ob_ddl_operator.cpp b/src/rootserver/ob_ddl_operator.cpp index b19b97670d..a4b72aed9d 100644 --- a/src/rootserver/ob_ddl_operator.cpp +++ b/src/rootserver/ob_ddl_operator.cpp @@ -4310,7 +4310,7 @@ int ObDDLOperator::drop_table_for_not_dropped_schema( // When tables with auto-increment columns are frequently created or deleted, if the auto-increment column cache is not cleared, the memory will grow slowly. // so every time when you drop table, if you bring auto-increment columns, clean up the corresponding cache. int ObDDLOperator::cleanup_autoinc_cache(const ObTableSchema &table_schema, - const common::ObArray* alive_server_list/*nullptr*/) + const common::ObArray *alive_server_list/*nullptr*/) { int ret = OB_SUCCESS; ObAutoincrementService &autoinc_service = share::ObAutoincrementService::get_instance(); diff --git a/src/rootserver/ob_ddl_service.cpp b/src/rootserver/ob_ddl_service.cpp index 6ee07ab810..cb1c403f81 100644 --- a/src/rootserver/ob_ddl_service.cpp +++ b/src/rootserver/ob_ddl_service.cpp @@ -16087,6 +16087,12 @@ int ObDDLService::generate_table_schemas(const ObIArray &o void *new_schema_ptr = NULL; ObTableSchema *new_table_schema = NULL; const ObTableSchema *tmp_table_schema = NULL; + int64_t truncate_version = OB_INVALID_VERSION; + //use first new schema version as truncate version instead of orig_table_schema schema version + //orig table schema version as refresh schema low boundary will load more useless info + if (OB_SUCC(ret) && 0 != gen_schema_version_array.count()) { + truncate_version = gen_schema_version_array.at(0); + } // construnct new table_schemas for (int64_t i = 0; OB_SUCC(ret) && i < orig_table_count; ++i) { new_schema_ptr = allocator.alloc(sizeof(ObTableSchema)); @@ -16103,6 +16109,7 @@ int ObDDLService::generate_table_schemas(const ObIArray &o LOG_WARN("fail to assign orig table schema to new table schema", KR(ret), K(tenant_id), K(tmp_table_schema->get_table_id())); } else if (i == 0 && FALSE_IT(new_table_schema->set_auto_increment(1))) { + } else if (FALSE_IT(new_table_schema->set_truncate_version(truncate_version))) { } else if (OB_FAIL(new_table_schemas.push_back(new_table_schema))) { LOG_WARN("failed to push back table_schema", KR(ret), K(tenant_id), K(new_table_schema->get_table_id())); @@ -16206,7 +16213,6 @@ int ObDDLService::new_truncate_table_in_trans(const ObIArray alive_server_list; - if (FAILEDx(get_server_manager().get_alive_servers(nullzone, alive_server_list))) { LOG_WARN("fail to get alive server list", KR(ret)); } else if (OB_FAIL(ddl_operator.reinit_autoinc_row(*orig_table_schemas.at(0), trans, &alive_server_list))) { diff --git a/src/share/inner_table/ob_inner_table_schema.101_150.cpp b/src/share/inner_table/ob_inner_table_schema.101_150.cpp index f1d7c72095..3e822d23ab 100644 --- a/src/share/inner_table/ob_inner_table_schema.101_150.cpp +++ b/src/share/inner_table/ob_inner_table_schema.101_150.cpp @@ -6348,6 +6348,25 @@ int ObInnerTableSchema::all_table_history_schema(ObTableSchema &table_schema) table_flags_default, table_flags_default); //default_value } + + if (OB_SUCC(ret)) { + ObObj truncate_version_default; + truncate_version_default.set_int(-1); + ADD_COLUMN_SCHEMA_T("truncate_version", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObIntType, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(int64_t), //column_length + -1, //column_precision + -1, //column_scale + true, //is_nullable + false, //is_autoincrement + truncate_version_default, + truncate_version_default); //default_value + } table_schema.set_index_using_type(USING_BTREE); table_schema.set_row_store_type(ENCODING_ROW_STORE); table_schema.set_store_format(OB_STORE_FORMAT_DYNAMIC_MYSQL); diff --git a/src/share/inner_table/ob_inner_table_schema.11001_11050.cpp b/src/share/inner_table/ob_inner_table_schema.11001_11050.cpp index 3bfc7931c2..4387676f45 100644 --- a/src/share/inner_table/ob_inner_table_schema.11001_11050.cpp +++ b/src/share/inner_table/ob_inner_table_schema.11001_11050.cpp @@ -13741,6 +13741,25 @@ int ObInnerTableSchema::all_virtual_core_all_table_schema(ObTableSchema &table_s table_flags_default, table_flags_default); //default_value } + + if (OB_SUCC(ret)) { + ObObj truncate_version_default; + truncate_version_default.set_int(-1); + ADD_COLUMN_SCHEMA_T("truncate_version", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObIntType, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(int64_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false, //is_autoincrement + truncate_version_default, + truncate_version_default); //default_value + } table_schema.set_index_using_type(USING_HASH); table_schema.set_row_store_type(ENCODING_ROW_STORE); table_schema.set_store_format(OB_STORE_FORMAT_DYNAMIC_MYSQL); diff --git a/src/share/inner_table/ob_inner_table_schema.12051_12100.cpp b/src/share/inner_table/ob_inner_table_schema.12051_12100.cpp index 01f43b3269..057c46ae01 100644 --- a/src/share/inner_table/ob_inner_table_schema.12051_12100.cpp +++ b/src/share/inner_table/ob_inner_table_schema.12051_12100.cpp @@ -6285,6 +6285,25 @@ int ObInnerTableSchema::all_virtual_table_schema(ObTableSchema &table_schema) table_flags_default, table_flags_default); //default_value } + + if (OB_SUCC(ret)) { + ObObj truncate_version_default; + truncate_version_default.set_int(-1); + ADD_COLUMN_SCHEMA_T("truncate_version", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObIntType, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(int64_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false, //is_autoincrement + truncate_version_default, + truncate_version_default); //default_value + } table_schema.set_index_using_type(USING_BTREE); table_schema.set_row_store_type(ENCODING_ROW_STORE); table_schema.set_store_format(OB_STORE_FORMAT_DYNAMIC_MYSQL); @@ -7554,6 +7573,25 @@ int ObInnerTableSchema::all_virtual_table_history_schema(ObTableSchema &table_sc table_flags_default, table_flags_default); //default_value } + + if (OB_SUCC(ret)) { + ObObj truncate_version_default; + truncate_version_default.set_int(-1); + ADD_COLUMN_SCHEMA_T("truncate_version", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObIntType, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(int64_t), //column_length + -1, //column_precision + -1, //column_scale + true, //is_nullable + false, //is_autoincrement + truncate_version_default, + truncate_version_default); //default_value + } table_schema.set_index_using_type(USING_BTREE); table_schema.set_row_store_type(ENCODING_ROW_STORE); table_schema.set_store_format(OB_STORE_FORMAT_DYNAMIC_MYSQL); diff --git a/src/share/inner_table/ob_inner_table_schema.15101_15150.cpp b/src/share/inner_table/ob_inner_table_schema.15101_15150.cpp index c29cc54168..4dd54d308d 100644 --- a/src/share/inner_table/ob_inner_table_schema.15101_15150.cpp +++ b/src/share/inner_table/ob_inner_table_schema.15101_15150.cpp @@ -6188,6 +6188,21 @@ int ObInnerTableSchema::all_virtual_table_real_agent_ora_schema(ObTableSchema &t false); //is_autoincrement } + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("TRUNCATE_VERSION", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObNumberType, //column_type + CS_TYPE_INVALID, //column_collation_type + 38, //column_length + 38, //column_precision + 0, //column_scale + false, //is_nullable + false); //is_autoincrement + } + if (OB_SUCC(ret)) { ADD_COLUMN_SCHEMA("GMT_CREATE", //column_name ++column_id, //column_id diff --git a/src/share/inner_table/ob_inner_table_schema.15201_15250.cpp b/src/share/inner_table/ob_inner_table_schema.15201_15250.cpp index 51d818bda2..5dc365376f 100644 --- a/src/share/inner_table/ob_inner_table_schema.15201_15250.cpp +++ b/src/share/inner_table/ob_inner_table_schema.15201_15250.cpp @@ -5941,6 +5941,21 @@ int ObInnerTableSchema::all_virtual_core_all_table_ora_schema(ObTableSchema &tab false, //is_nullable false); //is_autoincrement } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("TRUNCATE_VERSION", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObNumberType, //column_type + CS_TYPE_INVALID, //column_collation_type + 38, //column_length + 38, //column_precision + 0, //column_scale + false, //is_nullable + false); //is_autoincrement + } table_schema.set_index_using_type(USING_HASH); table_schema.set_row_store_type(ENCODING_ROW_STORE); table_schema.set_store_format(OB_STORE_FORMAT_DYNAMIC_MYSQL); diff --git a/src/share/inner_table/ob_inner_table_schema.1_50.cpp b/src/share/inner_table/ob_inner_table_schema.1_50.cpp index 9d44c77d85..91e1437e40 100644 --- a/src/share/inner_table/ob_inner_table_schema.1_50.cpp +++ b/src/share/inner_table/ob_inner_table_schema.1_50.cpp @@ -1432,6 +1432,25 @@ int ObInnerTableSchema::all_table_schema(ObTableSchema &table_schema) table_flags_default, table_flags_default); //default_value } + + if (OB_SUCC(ret)) { + ObObj truncate_version_default; + truncate_version_default.set_int(-1); + ADD_COLUMN_SCHEMA_T("truncate_version", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObIntType, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(int64_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false, //is_autoincrement + truncate_version_default, + truncate_version_default); //default_value + } table_schema.set_index_using_type(USING_BTREE); table_schema.set_row_store_type(ENCODING_ROW_STORE); table_schema.set_store_format(OB_STORE_FORMAT_DYNAMIC_MYSQL); diff --git a/src/share/inner_table/ob_inner_table_schema_def.py b/src/share/inner_table/ob_inner_table_schema_def.py index 8d05638777..ac1678bf2c 100644 --- a/src/share/inner_table/ob_inner_table_schema_def.py +++ b/src/share/inner_table/ob_inner_table_schema_def.py @@ -266,7 +266,8 @@ all_table_def = dict( ('interval_range', 'varchar:OB_MAX_PARTITION_EXPR_LENGTH', 'true'), ('b_interval_range', 'varchar:OB_MAX_B_HIGH_BOUND_VAL_LENGTH', 'true'), ('object_status', 'int', 'false', '1'), - ('table_flags', 'int', 'false', '0') + ('table_flags', 'int', 'false', '0'), + ('truncate_version', 'int', 'false', '-1') ], ) @@ -1774,19 +1775,19 @@ def_table_schema( # TODO: abandoned def_table_schema( - owner = 'quanwei.wqw', - table_name = '__all_freeze_schema_version', - table_id = '219', - table_type = 'SYSTEM_TABLE', - gm_columns = ['gmt_create', 'gmt_modified'], - rowkey_columns = [ - ('frozen_version', 'int', 'false'), - ('tenant_id', 'int', 'false'), - ], - - normal_columns = [ - ('schema_version', 'int', 'false'), - ], + owner = 'quanwei.wqw', + table_name = '__all_freeze_schema_version', + table_id = '219', + table_type = 'SYSTEM_TABLE', + gm_columns = ['gmt_create', 'gmt_modified'], + rowkey_columns = [ + ('frozen_version', 'int', 'false'), + ('tenant_id', 'int', 'false'), + ], + + normal_columns = [ + ('schema_version', 'int', 'false'), + ], ) all_type_def = dict( @@ -1919,7 +1920,7 @@ def_table_schema( ], ) -#abandoned on 4.0 table_id = 228 __all_cluster +#abandoned on 4.0 table_id = 228 __all_cluster # table_id = 229: __all_gts not used on 4.0 @@ -3661,7 +3662,7 @@ def_table_schema( meta_record_in_sys = False, normal_columns = [ ('dest_id', 'int', 'true', '0'), - ('dest_type', 'varchar:OB_DEFAULT_OUTPUT_DEVICE_TYPE_LENTH', 'true', ''), + ('dest_type', 'varchar:OB_DEFAULT_OUTPUT_DEVICE_TYPE_LENTH', 'true', ''), ('authorization', 'varchar:OB_MAX_BACKUP_AUTHORIZATION_LENGTH'), ('extension', 'varchar:OB_MAX_BACKUP_EXTENSION_LENGTH'), ('check_file_name', 'varchar:OB_MAX_BACKUP_CHECK_FILE_NAME_LENGTH', 'true', ''), @@ -3735,7 +3736,7 @@ def_table_schema( ('end_ts', 'int'), ('status', 'varchar:OB_INNER_TABLE_DEFAULT_VALUE_LENTH'), ('result', 'int'), - ('retry_count', 'int', 'true', '0'), + ('retry_count', 'int', 'true', '0'), ('comment', 'varchar:OB_INNER_TABLE_DEFAULT_VALUE_LENTH', 'true', ''), ('description', 'varchar:OB_INNER_TABLE_DEFAULT_VALUE_LENTH', 'true', ''), ('path', 'varchar:OB_INNER_TABLE_DEFAULT_VALUE_LENTH', 'true', ''), @@ -3770,7 +3771,7 @@ def_table_schema( ('end_ts', 'int'), ('status', 'varchar:OB_INNER_TABLE_DEFAULT_VALUE_LENTH'), ('result', 'int'), - ('retry_count', 'int', 'true', '0'), + ('retry_count', 'int', 'true', '0'), ('comment', 'varchar:OB_INNER_TABLE_DEFAULT_VALUE_LENTH', 'true', ''), ('description', 'varchar:OB_INNER_TABLE_DEFAULT_VALUE_LENTH', 'true', ''), ('path', 'varchar:OB_INNER_TABLE_DEFAULT_VALUE_LENTH', 'true', ''), @@ -4051,8 +4052,8 @@ def_table_schema( ], ) -#abandoned on 4.0 table_id = 367 __all_cluster_info -#abandoned on 4.0 table_id = 368 __all_cluster_config +#abandoned on 4.0 table_id = 367 __all_cluster_info +#abandoned on 4.0 table_id = 368 __all_cluster_config def_table_schema( owner = 'yanmu.ztl', @@ -4486,8 +4487,8 @@ def_table_schema( normal_columns = [ ('incarnation', 'int'), ('initiator_tenant_id', 'int'), - ('initiator_job_id', 'int'), - ('executor_tenant_id', 'varchar:OB_MAX_EXECUTOR_TENANT_LENGTH'), + ('initiator_job_id', 'int'), + ('executor_tenant_id', 'varchar:OB_MAX_EXECUTOR_TENANT_LENGTH'), ('type', 'varchar:OB_INNER_TABLE_BACKUP_CLEAN_TYPE_LENGTH'), ('parameter', 'varchar:OB_MAX_BACKUP_PATH_LENGTH'), ('job_level', 'varchar:OB_INNER_TABLE_BACKUP_LEVEL_LENGTH'), @@ -4497,11 +4498,11 @@ def_table_schema( ('task_count', 'int', 'true', '0'), ('success_task_count', 'int', 'true', '0'), ('result', 'int'), - ('retry_count', 'int', 'true', '0'), + ('retry_count', 'int', 'true', '0'), ('comment', 'varchar:OB_INNER_TABLE_DEFAULT_VALUE_LENTH', 'true', ''), ('data_backup_dest_id_list', 'varchar:OB_INNER_TABLE_BACKUP_DEFAULT_FIELD_LENGTH', 'true', ''), - ('log_archive_dest_id_list', 'varchar:OB_INNER_TABLE_BACKUP_DEFAULT_FIELD_LENGTH', 'true', ''), - ('data_backup_path_list', 'varchar:OB_MAX_BACKUP_PTAH_LIST_LENGTH', 'true', ''), + ('log_archive_dest_id_list', 'varchar:OB_INNER_TABLE_BACKUP_DEFAULT_FIELD_LENGTH', 'true', ''), + ('data_backup_path_list', 'varchar:OB_MAX_BACKUP_PTAH_LIST_LENGTH', 'true', ''), ('log_archive_path_list', 'varchar:OB_MAX_BACKUP_PTAH_LIST_LENGTH', 'true', ''), ('description', 'varchar:OB_INNER_TABLE_DEFAULT_VALUE_LENTH', 'true', ''), ], @@ -4523,8 +4524,8 @@ def_table_schema( normal_columns = [ ('incarnation', 'int'), ('initiator_tenant_id', 'int'), - ('initiator_job_id', 'int'), - ('executor_tenant_id', 'varchar:OB_MAX_EXECUTOR_TENANT_LENGTH'), + ('initiator_job_id', 'int'), + ('executor_tenant_id', 'varchar:OB_MAX_EXECUTOR_TENANT_LENGTH'), ('type', 'varchar:OB_INNER_TABLE_BACKUP_CLEAN_TYPE_LENGTH'), ('parameter', 'varchar:OB_MAX_BACKUP_PATH_LENGTH'), ('job_level', 'varchar:OB_INNER_TABLE_BACKUP_LEVEL_LENGTH'), @@ -4534,11 +4535,11 @@ def_table_schema( ('task_count', 'int', 'true', '0'), ('success_task_count', 'int', 'true', '0'), ('result', 'int'), - ('retry_count', 'int', 'true', '0'), + ('retry_count', 'int', 'true', '0'), ('comment', 'varchar:OB_INNER_TABLE_DEFAULT_VALUE_LENTH', 'true', ''), ('data_backup_dest_id_list', 'varchar:OB_INNER_TABLE_BACKUP_DEFAULT_FIELD_LENGTH', 'true', ''), - ('log_archive_dest_id_list', 'varchar:OB_INNER_TABLE_BACKUP_DEFAULT_FIELD_LENGTH', 'true', ''), - ('data_backup_path_list', 'varchar:OB_MAX_BACKUP_PTAH_LIST_LENGTH', 'true', ''), + ('log_archive_dest_id_list', 'varchar:OB_INNER_TABLE_BACKUP_DEFAULT_FIELD_LENGTH', 'true', ''), + ('data_backup_path_list', 'varchar:OB_MAX_BACKUP_PTAH_LIST_LENGTH', 'true', ''), ('log_archive_path_list', 'varchar:OB_MAX_BACKUP_PTAH_LIST_LENGTH', 'true', ''), ('description', 'varchar:OB_INNER_TABLE_DEFAULT_VALUE_LENTH', 'true', ''), ], @@ -4643,7 +4644,7 @@ def_table_schema( ('delete_bytes', 'int', 'true', '0'), ('total_files_count', 'int', 'true', '0'), ('delete_files_count', 'int', 'true', '0'), - ('retry_id', 'int', 'true', '0'), + ('retry_id', 'int', 'true', '0'), ('result', 'int', 'true', '0'), ('comment', 'varchar:OB_INNER_TABLE_DEFAULT_VALUE_LENTH', 'true', ''), ], @@ -4667,7 +4668,7 @@ def_table_schema( ('job_id', 'int'), ('task_type', 'varchar:OB_INNER_TABLE_BACKUP_CLEAN_TYPE_LENGTH'), ('id', 'int'), - ('round_id', 'int'), + ('round_id', 'int'), ('status', 'varchar:OB_DEFAULT_STATUS_LENTH'), ('start_ts', 'int'), ('end_ts', 'int'), @@ -4678,7 +4679,7 @@ def_table_schema( ('delete_bytes', 'int', 'true', '0'), ('total_files_count', 'int', 'true', '0'), ('delete_files_count', 'int', 'true', '0'), - ('retry_id', 'int', 'true', '0'), + ('retry_id', 'int', 'true', '0'), ('result', 'int', 'true', '0'), ('comment', 'varchar:OB_INNER_TABLE_DEFAULT_VALUE_LENTH', 'true', ''), ], @@ -4973,8 +4974,8 @@ def_table_schema( is_cluster_private = True, meta_record_in_sys = False, normal_columns = [ - ('dest_id', 'int', 'true', '0'), - ('dest_type', 'varchar:OB_DEFAULT_OUTPUT_DEVICE_TYPE_LENTH', 'true', ''), + ('dest_id', 'int', 'true', '0'), + ('dest_type', 'varchar:OB_DEFAULT_OUTPUT_DEVICE_TYPE_LENTH', 'true', ''), ('authorization', 'varchar:OB_MAX_BACKUP_AUTHORIZATION_LENGTH'), ('extension', 'varchar:OB_MAX_BACKUP_EXTENSION_LENGTH'), ('check_file_name', 'varchar:OB_MAX_BACKUP_CHECK_FILE_NAME_LENGTH', 'true', ''), @@ -8525,7 +8526,7 @@ def_table_schema( vtable_route_policy = 'distributed', ) -## abandoned on 4.0 table_id = 12042 __all_virtual_weak_read_stat +## abandoned on 4.0 table_id = 12042 __all_virtual_weak_read_stat ## abandoned on 4.0 table_id = 12054 __all_virtual_partition_audit @@ -11021,7 +11022,7 @@ def_table_schema(**gen_iterate_private_virtual_table_def( keywords = all_def_keywords['__all_column_checksum_error_info'])) def_table_schema( - owner = 'zhaoruizhe.zrz', + owner = 'zhaoruizhe.zrz', table_name = '__all_virtual_kvcache_handle_leak_info', table_type = 'VIRTUAL_TABLE', table_id='12331', @@ -12356,7 +12357,7 @@ def_table_schema( join oceanbase.__all_column c2 on f.tenant_id = c2.tenant_id and fc.parent_column_id = c2.column_id and t2.table_id = c2.table_id where f.tenant_id = 0) - + union all (select 'def' as CONSTRAINT_CATALOG, d.database_name as CONSTRAINT_SCHEMA, @@ -14446,15 +14447,15 @@ def_table_schema( normal_columns = [], gm_columns = [], view_definition = """ - SELECT - P.TENANT_ID AS TENANT_ID, - P.JOB_ID AS JOB_ID, - RESTORE_TENANT_NAME, + SELECT + P.TENANT_ID AS TENANT_ID, + P.JOB_ID AS JOB_ID, + RESTORE_TENANT_NAME, RESTORE_TENANT_ID, - BACKUP_TENANT_NAME, + BACKUP_TENANT_NAME, BACKUP_TENANT_ID, - BACKUP_CLUSTER_NAME, - BACKUP_DEST, + BACKUP_CLUSTER_NAME, + BACKUP_DEST, RESTORE_OPTION, RESTORE_SCN, CASE @@ -14462,7 +14463,7 @@ def_table_schema( THEN NULL WHEN RESTORE_SCN=0 THEN NULL - ELSE + ELSE SCN_TO_TIMESTAMP(RESTORE_SCN) END AS RESTORE_SCN_DISPLAY, CASE @@ -14483,12 +14484,12 @@ def_table_schema( THEN NULL WHEN START_TIMESTAMP='0' THEN NULL - ELSE + ELSE USEC_TO_TIME(START_TIMESTAMP) END AS START_TIMESTAMP, - BACKUP_SET_LIST, + BACKUP_SET_LIST, BACKUP_PIECE_LIST, - TOTAL_BYTES, + TOTAL_BYTES, CASE WHEN TOTAL_BYTES >= 1024*1024*1024*1024*1024 THEN CONCAT(ROUND(TOTAL_BYTES/1024/1024/1024/1024/1024,2), 'PB') @@ -14510,19 +14511,19 @@ def_table_schema( ELSE CONCAT(ROUND(FINISH_BYTES/1024/1024,2), 'MB') END AS FINISH_BYTES_DISPLAY, - DESCRIPTION + DESCRIPTION FROM ( - SELECT - TENANT_ID, - JOB_ID, - MAX(CASE NAME WHEN 'tenant_name' THEN VALUE ELSE '' END) AS RESTORE_TENANT_NAME, + SELECT + TENANT_ID, + JOB_ID, + MAX(CASE NAME WHEN 'tenant_name' THEN VALUE ELSE '' END) AS RESTORE_TENANT_NAME, MAX(CASE NAME WHEN 'tenant_id' THEN VALUE ELSE '' END) AS RESTORE_TENANT_ID, MAX(CASE NAME WHEN 'backup_tenant_name' THEN VALUE ELSE '' END) AS BACKUP_TENANT_NAME, - MAX(CASE NAME WHEN 'backup_tenant_id' THEN VALUE ELSE '' END) AS BACKUP_TENANT_ID, + MAX(CASE NAME WHEN 'backup_tenant_id' THEN VALUE ELSE '' END) AS BACKUP_TENANT_ID, MAX(CASE NAME WHEN 'backup_cluster_name' THEN VALUE ELSE '' END) AS BACKUP_CLUSTER_NAME, - MAX(CASE NAME WHEN 'target_tenant_role' THEN VALUE ELSE '' END) AS TENANT_ROLE, - MAX(CASE NAME WHEN 'backup_dest' THEN VALUE ELSE '' END) AS BACKUP_DEST, + MAX(CASE NAME WHEN 'target_tenant_role' THEN VALUE ELSE '' END) AS TENANT_ROLE, + MAX(CASE NAME WHEN 'backup_dest' THEN VALUE ELSE '' END) AS BACKUP_DEST, MAX(CASE NAME WHEN 'restore_option' THEN VALUE ELSE '' END) AS RESTORE_OPTION, MAX(CASE NAME WHEN 'status' THEN VALUE ELSE '' END) AS STATUS, MAX(CASE NAME WHEN 'restore_scn' THEN VALUE ELSE '' END) AS RESTORE_SCN, @@ -14532,9 +14533,9 @@ def_table_schema( MAX(CASE NAME WHEN 'description' THEN VALUE ELSE '' END) AS DESCRIPTION FROM OCEANBASE.__ALL_VIRTUAL_RESTORE_JOB GROUP BY TENANT_ID, JOB_ID ) P LEFT JOIN - ( - SELECT - TENANT_ID, + ( + SELECT + TENANT_ID, JOB_ID, TOTAL_BYTES, FINISH_BYTES @@ -14567,7 +14568,7 @@ def_table_schema( CASE WHEN RESTORE_SCN = 0 THEN NULL - ELSE + ELSE SCN_TO_TIMESTAMP(RESTORE_SCN) END AS RESTORE_SCN_DISPLAY, RESTORE_OPTION, @@ -14887,7 +14888,7 @@ def_table_schema( ELSE 'NORMAL' END AS STATUS, A.tenant_id as CON_ID FROM - (SELECT T.tenant_id, T.table_id, T.table_name, T.table_type, T.tablespace_id, T.tablet_id + (SELECT T.tenant_id, T.table_id, T.table_name, T.table_type, T.tablespace_id, T.tablet_id FROM oceanbase.__all_table T where T.part_level = 0 UNION ALL SELECT T.tenant_id, T.table_id, T.table_name, T.table_type, T.tablespace_id, P.tablet_id @@ -14957,14 +14958,14 @@ def_table_schema( CASE WHEN START_SCN = 0 THEN NULL - ELSE + ELSE SCN_TO_TIMESTAMP(START_SCN) END AS START_SCN_DISPLAY, CHECKPOINT_SCN, CASE WHEN CHECKPOINT_SCN = 0 THEN NULL - ELSE + ELSE SCN_TO_TIMESTAMP(CHECKPOINT_SCN) END AS CHECKPOINT_SCN_DISPLAY, MAX_SCN, @@ -15028,7 +15029,7 @@ def_table_schema( WHEN END_TS = 0 THEN NULL ELSE - USEC_TO_TIME(END_TS) + USEC_TO_TIME(END_TS) END AS END_TIMESTAMP, STATUS, FILE_STATUS, @@ -15036,30 +15037,30 @@ def_table_schema( WHEN END_TS = 0 THEN 0 ELSE - ROUND((END_TS - START_TS)/1000/1000,0) + ROUND((END_TS - START_TS)/1000/1000,0) END AS ELAPSED_SECONDES, PLUS_ARCHIVELOG, START_REPLAY_SCN, - CASE + CASE WHEN START_REPLAY_SCN = 0 THEN NULL - ELSE - SCN_TO_TIMESTAMP(START_REPLAY_SCN) + ELSE + SCN_TO_TIMESTAMP(START_REPLAY_SCN) END AS START_REPLAY_SCN_DISPLAY, MIN_RESTORE_SCN, - CASE + CASE WHEN MIN_RESTORE_SCN = 0 THEN NULL - ELSE + ELSE SCN_TO_TIMESTAMP(MIN_RESTORE_SCN) END AS MIN_RESTORE_SCN_DISPLAY, INPUT_BYTES, OUTPUT_BYTES, - CASE + CASE WHEN END_TS = 0 THEN 0 ELSE - OUTPUT_BYTES / ((END_TS - START_TS)/1000/1000) + OUTPUT_BYTES / ((END_TS - START_TS)/1000/1000) END AS OUTPUT_RATE_BYTES, EXTRA_BYTES AS EXTRA_META_BYTES, TABLET_COUNT, @@ -15304,11 +15305,11 @@ def_table_schema( ENCRYPTION_MODE, PASSWD, USEC_TO_TIME(START_TS) AS START_TIMESTAMP, - CASE + CASE WHEN END_TS = 0 THEN NULL ELSE - USEC_TO_TIME(END_TS) + USEC_TO_TIME(END_TS) END AS END_TIMESTAMP, STATUS, RESULT, @@ -15342,11 +15343,11 @@ def_table_schema( ENCRYPTION_MODE, PASSWD, USEC_TO_TIME(START_TS) AS START_TIMESTAMP, - CASE + CASE WHEN END_TS = 0 THEN NULL ELSE - USEC_TO_TIME(END_TS) + USEC_TO_TIME(END_TS) END AS END_TIMESTAMP, STATUS, RESULT, @@ -15373,11 +15374,11 @@ def_table_schema( INCARNATION, BACKUP_SET_ID, USEC_TO_TIME(START_TS) AS START_TIMESTAMP, - CASE + CASE WHEN END_TS = 0 THEN NULL ELSE - USEC_TO_TIME(END_TS) + USEC_TO_TIME(END_TS) END AS END_TIMESTAMP, STATUS, START_SCN, @@ -15390,8 +15391,8 @@ def_table_schema( CASE WHEN END_TS = 0 THEN 0 - ELSE - OUTPUT_BYTES / ((END_TS - START_TS)/1000/1000) + ELSE + OUTPUT_BYTES / ((END_TS - START_TS)/1000/1000) END AS OUTPUT_RATE_BYTES, EXTRA_BYTES AS EXTRA_META_BYTES, TABLET_COUNT, @@ -15424,11 +15425,11 @@ def_table_schema( INCARNATION, BACKUP_SET_ID, USEC_TO_TIME(START_TS) AS START_TIMESTAMP, - CASE + CASE WHEN END_TS = 0 THEN NULL ELSE - USEC_TO_TIME(END_TS) + USEC_TO_TIME(END_TS) END AS END_TIMESTAMP, STATUS, START_SCN, @@ -15441,8 +15442,8 @@ def_table_schema( CASE WHEN END_TS = 0 THEN 0 - ELSE - OUTPUT_BYTES / ((END_TS - START_TS)/1000/1000) + ELSE + OUTPUT_BYTES / ((END_TS - START_TS)/1000/1000) END AS OUTPUT_RATE_BYTES, EXTRA_BYTES AS EXTRA_META_BYTES, TABLET_COUNT, @@ -20690,7 +20691,7 @@ def_table_schema( CASE WHEN END_TS = 0 THEN NULL - ELSE + ELSE USEC_TO_TIME(END_TS) END AS END_TIMESTAMP, STATUS, @@ -20725,7 +20726,7 @@ def_table_schema( CASE WHEN END_TS = 0 THEN NULL - ELSE + ELSE USEC_TO_TIME(END_TS) END AS END_TIMESTAMP, STATUS, @@ -20759,7 +20760,7 @@ def_table_schema( CASE WHEN END_TS = 0 THEN NULL - ELSE + ELSE USEC_TO_TIME(END_TS) END AS END_TIMESTAMP, STATUS, @@ -20794,7 +20795,7 @@ def_table_schema( CASE WHEN END_TS = 0 THEN NULL - ELSE + ELSE USEC_TO_TIME(END_TS) END AS END_TIMESTAMP, STATUS, @@ -21543,11 +21544,11 @@ def_table_schema( ENCRYPTION_MODE, PASSWD, USEC_TO_TIME(START_TS) AS START_TIMESTAMP, - CASE + CASE WHEN END_TS = 0 THEN NULL ELSE - USEC_TO_TIME(END_TS) + USEC_TO_TIME(END_TS) END AS END_TIMESTAMP, STATUS, RESULT, @@ -21583,11 +21584,11 @@ def_table_schema( ENCRYPTION_MODE, PASSWD, USEC_TO_TIME(START_TS) AS START_TIMESTAMP, - CASE + CASE WHEN END_TS = 0 THEN NULL ELSE - USEC_TO_TIME(END_TS) + USEC_TO_TIME(END_TS) END AS END_TIMESTAMP, STATUS, RESULT, @@ -21616,11 +21617,11 @@ def_table_schema( INCARNATION, BACKUP_SET_ID, USEC_TO_TIME(START_TS) AS START_TIMESTAMP, - CASE + CASE WHEN END_TS = 0 THEN NULL ELSE - USEC_TO_TIME(END_TS) + USEC_TO_TIME(END_TS) END AS END_TIMESTAMP, STATUS, START_SCN, @@ -21633,8 +21634,8 @@ def_table_schema( CASE WHEN END_TS = 0 THEN 0 - ELSE - OUTPUT_BYTES / ((END_TS - START_TS)/1000/1000) + ELSE + OUTPUT_BYTES / ((END_TS - START_TS)/1000/1000) END AS OUTPUT_RATE_BYTES, EXTRA_BYTES AS EXTRA_META_BYTES, TABLET_COUNT, @@ -21669,11 +21670,11 @@ def_table_schema( INCARNATION, BACKUP_SET_ID, USEC_TO_TIME(START_TS) AS START_TIMESTAMP, - CASE + CASE WHEN END_TS = 0 THEN NULL ELSE - USEC_TO_TIME(END_TS) + USEC_TO_TIME(END_TS) END AS END_TIMESTAMP, STATUS, START_SCN, @@ -21686,8 +21687,8 @@ def_table_schema( CASE WHEN END_TS = 0 THEN 0 - ELSE - OUTPUT_BYTES / ((END_TS - START_TS)/1000/1000) + ELSE + OUTPUT_BYTES / ((END_TS - START_TS)/1000/1000) END AS OUTPUT_RATE_BYTES, EXTRA_BYTES AS EXTRA_META_BYTES, TABLET_COUNT, @@ -21728,7 +21729,7 @@ def_table_schema( WHEN END_TS = 0 THEN NULL ELSE - USEC_TO_TIME(END_TS) + USEC_TO_TIME(END_TS) END AS END_TIMESTAMP, STATUS, FILE_STATUS, @@ -21736,30 +21737,30 @@ def_table_schema( WHEN END_TS = 0 THEN 0 ELSE - ROUND((END_TS - START_TS)/1000/1000,0) + ROUND((END_TS - START_TS)/1000/1000,0) END AS ELAPSED_SECONDES, PLUS_ARCHIVELOG, START_REPLAY_SCN, - CASE + CASE WHEN START_REPLAY_SCN = 0 THEN NULL - ELSE - SCN_TO_TIMESTAMP(START_REPLAY_SCN) + ELSE + SCN_TO_TIMESTAMP(START_REPLAY_SCN) END AS START_REPLAY_SCN_DISPLAY, MIN_RESTORE_SCN, - CASE + CASE WHEN MIN_RESTORE_SCN = 0 THEN NULL - ELSE + ELSE SCN_TO_TIMESTAMP(MIN_RESTORE_SCN) END AS MIN_RESTORE_SCN_DISPLAY, INPUT_BYTES, OUTPUT_BYTES, - CASE + CASE WHEN END_TS = 0 THEN 0 ELSE - OUTPUT_BYTES / ((END_TS - START_TS)/1000/1000) + OUTPUT_BYTES / ((END_TS - START_TS)/1000/1000) END AS OUTPUT_RATE_BYTES, EXTRA_BYTES AS EXTRA_META_BYTES, TABLET_COUNT, @@ -22240,7 +22241,7 @@ def_table_schema( CASE WHEN END_TS = 0 THEN NULL - ELSE + ELSE USEC_TO_TIME(END_TS) END AS END_TIMESTAMP, STATUS, @@ -22277,7 +22278,7 @@ def_table_schema( CASE WHEN END_TS = 0 THEN NULL - ELSE + ELSE USEC_TO_TIME(END_TS) END AS END_TIMESTAMP, STATUS, @@ -22313,7 +22314,7 @@ def_table_schema( CASE WHEN END_TS = 0 THEN NULL - ELSE + ELSE USEC_TO_TIME(END_TS) END AS END_TIMESTAMP, STATUS, @@ -22350,7 +22351,7 @@ def_table_schema( CASE WHEN END_TS = 0 THEN NULL - ELSE + ELSE USEC_TO_TIME(END_TS) END AS END_TIMESTAMP, STATUS, @@ -22437,14 +22438,14 @@ def_table_schema( gm_columns = [], in_tenant_space = True, view_definition = """ - SELECT - P.JOB_ID AS JOB_ID, - RESTORE_TENANT_NAME, + SELECT + P.JOB_ID AS JOB_ID, + RESTORE_TENANT_NAME, RESTORE_TENANT_ID, - BACKUP_TENANT_NAME, + BACKUP_TENANT_NAME, BACKUP_TENANT_ID, - BACKUP_CLUSTER_NAME, - BACKUP_DEST, + BACKUP_CLUSTER_NAME, + BACKUP_DEST, RESTORE_OPTION, RESTORE_SCN, CASE @@ -22452,7 +22453,7 @@ def_table_schema( THEN NULL WHEN RESTORE_SCN=0 THEN NULL - ELSE + ELSE SCN_TO_TIMESTAMP(RESTORE_SCN) END AS RESTORE_SCN_DISPLAY, CASE @@ -22473,10 +22474,10 @@ def_table_schema( THEN NULL WHEN START_TIMESTAMP='0' THEN NULL - ELSE + ELSE USEC_TO_TIME(START_TIMESTAMP) END AS START_TIMESTAMP, - BACKUP_SET_LIST, + BACKUP_SET_LIST, BACKUP_PIECE_LIST, TOTAL_BYTES, CASE @@ -22500,19 +22501,19 @@ def_table_schema( ELSE CONCAT(ROUND(FINISH_BYTES/1024/1024,2), 'MB') END AS FINISH_BYTES_DISPLAY, - DESCRIPTION + DESCRIPTION FROM ( - SELECT - TENANT_ID, - JOB_ID, - MAX(CASE NAME WHEN 'tenant_name' THEN VALUE ELSE '' END) AS RESTORE_TENANT_NAME, + SELECT + TENANT_ID, + JOB_ID, + MAX(CASE NAME WHEN 'tenant_name' THEN VALUE ELSE '' END) AS RESTORE_TENANT_NAME, MAX(CASE NAME WHEN 'tenant_id' THEN VALUE ELSE '' END) AS RESTORE_TENANT_ID, MAX(CASE NAME WHEN 'backup_tenant_name' THEN VALUE ELSE '' END) AS BACKUP_TENANT_NAME, - MAX(CASE NAME WHEN 'backup_tenant_id' THEN VALUE ELSE '' END) AS BACKUP_TENANT_ID, + MAX(CASE NAME WHEN 'backup_tenant_id' THEN VALUE ELSE '' END) AS BACKUP_TENANT_ID, MAX(CASE NAME WHEN 'backup_cluster_name' THEN VALUE ELSE '' END) AS BACKUP_CLUSTER_NAME, - MAX(CASE NAME WHEN 'target_tenant_role' THEN VALUE ELSE '' END) AS TENANT_ROLE, - MAX(CASE NAME WHEN 'backup_dest' THEN VALUE ELSE '' END) AS BACKUP_DEST, + MAX(CASE NAME WHEN 'target_tenant_role' THEN VALUE ELSE '' END) AS TENANT_ROLE, + MAX(CASE NAME WHEN 'backup_dest' THEN VALUE ELSE '' END) AS BACKUP_DEST, MAX(CASE NAME WHEN 'restore_option' THEN VALUE ELSE '' END) AS RESTORE_OPTION, MAX(CASE NAME WHEN 'status' THEN VALUE ELSE '' END) AS STATUS, MAX(CASE NAME WHEN 'restore_scn' THEN VALUE ELSE '' END) AS RESTORE_SCN, @@ -22522,9 +22523,9 @@ def_table_schema( MAX(CASE NAME WHEN 'description' THEN VALUE ELSE '' END) AS DESCRIPTION FROM OCEANBASE.__ALL_VIRTUAL_RESTORE_JOB GROUP BY TENANT_ID, JOB_ID ) P LEFT JOIN - ( - SELECT - TENANT_ID, + ( + SELECT + TENANT_ID, JOB_ID, TOTAL_BYTES, FINISH_BYTES @@ -22558,7 +22559,7 @@ def_table_schema( CASE WHEN RESTORE_SCN = 0 THEN NULL - ELSE + ELSE SCN_TO_TIMESTAMP(RESTORE_SCN) END AS RESTORE_SCN_DISPLAY, RESTORE_OPTION, @@ -22644,14 +22645,14 @@ def_table_schema( CASE WHEN START_SCN = 0 THEN NULL - ELSE + ELSE SCN_TO_TIMESTAMP(START_SCN) END AS START_SCN_DISPLAY, CHECKPOINT_SCN, CASE WHEN CHECKPOINT_SCN = 0 THEN NULL - ELSE + ELSE SCN_TO_TIMESTAMP(CHECKPOINT_SCN) END AS CHECKPOINT_SCN_DISPLAY, COMPATIBLE, @@ -22738,14 +22739,14 @@ def_table_schema( CASE WHEN START_SCN = 0 THEN NULL - ELSE + ELSE SCN_TO_TIMESTAMP(START_SCN) END AS START_SCN_DISPLAY, CHECKPOINT_SCN, CASE WHEN CHECKPOINT_SCN = 0 THEN NULL - ELSE + ELSE SCN_TO_TIMESTAMP(CHECKPOINT_SCN) END AS CHECKPOINT_SCN_DISPLAY, COMPATIBLE, @@ -22806,7 +22807,7 @@ def_table_schema( END AS DELETED_OUTPUT_BYTES_DISPLAY, PATH, COMMENT - FROM + FROM ( SELECT DEST_ID, ROUND_ID, @@ -22876,14 +22877,14 @@ def_table_schema( CASE WHEN START_SCN = 0 THEN NULL - ELSE + ELSE SCN_TO_TIMESTAMP(START_SCN) END AS START_SCN_DISPLAY, CHECKPOINT_SCN, CASE WHEN CHECKPOINT_SCN = 0 THEN NULL - ELSE + ELSE SCN_TO_TIMESTAMP(CHECKPOINT_SCN) END AS CHECKPOINT_SCN_DISPLAY, MAX_SCN, @@ -22987,14 +22988,14 @@ def_table_schema( CASE WHEN START_SCN = 0 THEN NULL - ELSE + ELSE SCN_TO_TIMESTAMP(START_SCN) END AS START_SCN_DISPLAY, CHECKPOINT_SCN, CASE WHEN CHECKPOINT_SCN = 0 THEN NULL - ELSE + ELSE SCN_TO_TIMESTAMP(CHECKPOINT_SCN) END AS CHECKPOINT_SCN_DISPLAY, COMPATIBLE, @@ -23080,14 +23081,14 @@ def_table_schema( CASE WHEN START_SCN = 0 THEN NULL - ELSE + ELSE SCN_TO_TIMESTAMP(START_SCN) END AS START_SCN_DISPLAY, CHECKPOINT_SCN, CASE WHEN CHECKPOINT_SCN = 0 THEN NULL - ELSE + ELSE SCN_TO_TIMESTAMP(CHECKPOINT_SCN) END AS CHECKPOINT_SCN_DISPLAY, COMPATIBLE, @@ -23148,7 +23149,7 @@ def_table_schema( END AS DELETED_OUTPUT_BYTES_DISPLAY, PATH, COMMENT - FROM + FROM ( SELECT TENANT_ID, DEST_ID, @@ -23658,7 +23659,7 @@ def_table_schema( """ SELECT TENANT_ID, TABLET_ID - FROM + FROM ( SELECT A.TENANT_ID AS TENANT_ID, A.TABLET_ID AS TABLET_ID, @@ -41078,7 +41079,7 @@ def_table_schema( rowkey_columns = [], normal_columns = [], in_tenant_space = True, - view_definition = + view_definition = """ SELECT JOB_ID, @@ -41093,11 +41094,11 @@ def_table_schema( ENCRYPTION_MODE, PASSWD, TO_CHAR(START_TS / (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') AS START_TIMESTAMP, - CASE + CASE WHEN END_TS = 0 THEN NULL ELSE - TO_CHAR(END_TS / (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') + TO_CHAR(END_TS / (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 END_TIMESTAMP, STATUS, RESULT, @@ -41135,11 +41136,11 @@ def_table_schema( ENCRYPTION_MODE, PASSWD, TO_CHAR(START_TS / (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') AS START_TIMESTAMP, - CASE + CASE WHEN END_TS = 0 THEN NULL ELSE - TO_CHAR(END_TS / (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') + TO_CHAR(END_TS / (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 END_TIMESTAMP, STATUS, RESULT, @@ -41170,11 +41171,11 @@ def_table_schema( INCARNATION, BACKUP_SET_ID, TO_CHAR(START_TS / (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') AS START_TIMESTAMP, - CASE + CASE WHEN END_TS = 0 THEN NULL ELSE - TO_CHAR(END_TS / (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') + TO_CHAR(END_TS / (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 END_TIMESTAMP, STATUS, START_SCN, @@ -41184,11 +41185,11 @@ def_table_schema( PASSWD, INPUT_BYTES, OUTPUT_BYTES, - CASE + CASE WHEN END_TS = 0 THEN 0 ELSE - OUTPUT_BYTES / ((END_TS - START_TS)/1000/1000) + OUTPUT_BYTES / ((END_TS - START_TS)/1000/1000) END AS OUTPUT_RATE_BYTES, EXTRA_BYTES AS EXTRA_META_BYTES, TABLET_COUNT, @@ -41225,11 +41226,11 @@ def_table_schema( INCARNATION, BACKUP_SET_ID, TO_CHAR(START_TS / (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') AS START_TIMESTAMP, - CASE + CASE WHEN END_TS = 0 THEN NULL ELSE - TO_CHAR(END_TS / (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') + TO_CHAR(END_TS / (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 END_TIMESTAMP, STATUS, START_SCN, @@ -41239,11 +41240,11 @@ def_table_schema( PASSWD, INPUT_BYTES, OUTPUT_BYTES, - CASE + CASE WHEN END_TS = 0 THEN 0 ELSE - OUTPUT_BYTES / ((END_TS - START_TS)/1000/1000) + OUTPUT_BYTES / ((END_TS - START_TS)/1000/1000) END AS OUTPUT_RATE_BYTES, EXTRA_BYTES AS EXTRA_META_BYTES, TABLET_COUNT, @@ -41286,15 +41287,15 @@ def_table_schema( WHEN END_TS = 0 THEN NULL ELSE - TO_CHAR(END_TS / (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') + TO_CHAR(END_TS / (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 END_TIMESTAMP, STATUS, FILE_STATUS, - CASE + CASE WHEN END_TS = 0 THEN 0 - ELSE - ROUND((END_TS - START_TS)/1000/1000,0) + ELSE + ROUND((END_TS - START_TS)/1000/1000,0) END AS ELAPSED_SECONDES, PLUS_ARCHIVELOG, START_REPLAY_SCN, @@ -41303,11 +41304,11 @@ def_table_schema( SCN_TO_TIMESTAMP(MIN_RESTORE_SCN) AS MIN_RESTORE_SCN_DISPLAY, INPUT_BYTES, OUTPUT_BYTES, - CASE + CASE WHEN END_TS = 0 THEN 0 ELSE - OUTPUT_BYTES / ((END_TS - START_TS)/1000/1000) + OUTPUT_BYTES / ((END_TS - START_TS)/1000/1000) END AS OUTPUT_RATE_BYTES, EXTRA_BYTES AS EXTRA_META_BYTES, TABLET_COUNT, @@ -41618,7 +41619,7 @@ def_table_schema( WHEN END_TS = 0 THEN NULL ELSE - TO_CHAR(END_TS / (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') + TO_CHAR(END_TS / (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 END_TIMESTAMP, STATUS, TASK_COUNT, @@ -41657,7 +41658,7 @@ def_table_schema( WHEN END_TS = 0 THEN NULL ELSE - TO_CHAR(END_TS / (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') + TO_CHAR(END_TS / (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 END_TIMESTAMP, STATUS, TASK_COUNT, @@ -41695,7 +41696,7 @@ def_table_schema( WHEN END_TS = 0 THEN NULL ELSE - TO_CHAR(END_TS / (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') + TO_CHAR(END_TS / (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 END_TIMESTAMP, STATUS, TOTAL_LS_COUNT, @@ -41734,7 +41735,7 @@ def_table_schema( WHEN END_TS = 0 THEN NULL ELSE - TO_CHAR(END_TS / (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') + TO_CHAR(END_TS / (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 END_TIMESTAMP, STATUS, TOTAL_LS_COUNT, @@ -41761,20 +41762,20 @@ def_table_schema( gm_columns = [], in_tenant_space = True, view_definition = """ - SELECT - P.JOB_ID AS JOB_ID, + SELECT + P.JOB_ID AS JOB_ID, RESTORE_TENANT_NAME, - RESTORE_TENANT_ID, - BACKUP_TENANT_NAME, + RESTORE_TENANT_ID, + BACKUP_TENANT_NAME, BACKUP_TENANT_ID, - BACKUP_CLUSTER_NAME, - BACKUP_DEST, + BACKUP_CLUSTER_NAME, + BACKUP_DEST, RESTORE_OPTION, RESTORE_SCN, CASE WHEN RESTORE_SCN IS NULL THEN NULL - ELSE + ELSE SCN_TO_TIMESTAMP(RESTORE_SCN) END AS RESTORE_SCN_DISPLAY, CASE @@ -41795,12 +41796,12 @@ def_table_schema( THEN NULL WHEN START_TIMESTAMP='0' THEN NULL - ELSE + 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_SET_LIST, BACKUP_PIECE_LIST, - TOTAL_BYTES, + TOTAL_BYTES, CASE WHEN TOTAL_BYTES >= 1024*1024*1024*1024*1024 THEN CONCAT(ROUND(TOTAL_BYTES/1024/1024/1024/1024/1024,2), 'PB') @@ -41822,19 +41823,19 @@ def_table_schema( ELSE CONCAT(ROUND(FINISH_BYTES/1024/1024,2), 'MB') END AS FINISH_BYTES_DISPLAY, - DESCRIPTION + DESCRIPTION FROM ( - SELECT - TENANT_ID, - JOB_ID, + 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_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 '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, @@ -41844,9 +41845,9 @@ def_table_schema( 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, + ( + SELECT + TENANT_ID, JOB_ID, TOTAL_BYTES, FINISH_BYTES @@ -41934,7 +41935,7 @@ def_table_schema( rowkey_columns = [], normal_columns = [], in_tenant_space = True, - view_definition = + view_definition = """ SELECT DEST_NO, @@ -42112,7 +42113,7 @@ def_table_schema( END AS DELETED_OUTPUT_BYTES_DISPLAY, PATH, "COMMENT" - FROM + FROM ( SELECT DEST_ID, ROUND_ID, @@ -42236,7 +42237,7 @@ def_table_schema( rowkey_columns = [], normal_columns = [], in_tenant_space = True, - view_definition = + view_definition = """ SELECT NAME, diff --git a/src/share/ob_autoincrement_param.cpp b/src/share/ob_autoincrement_param.cpp index d2434beb13..ee67e1ffb2 100644 --- a/src/share/ob_autoincrement_param.cpp +++ b/src/share/ob_autoincrement_param.cpp @@ -34,7 +34,8 @@ OB_SERIALIZE_MEMBER(AutoincParam, part_level_, auto_increment_cache_size_, part_value_no_order_, - autoinc_mode_is_order_); + autoinc_mode_is_order_, + autoinc_version_); }//end namespace share }//end namespace oceanbase diff --git a/src/share/ob_autoincrement_param.h b/src/share/ob_autoincrement_param.h index e2a1e1f543..b3100e1c81 100644 --- a/src/share/ob_autoincrement_param.h +++ b/src/share/ob_autoincrement_param.h @@ -98,7 +98,8 @@ struct AutoincParam autoinc_intervals_count_(0), part_level_(schema::PARTITION_LEVEL_ZERO), auto_increment_cache_size_(DEFAULT_INCREMENT_CACHE_SIZE), - autoinc_mode_is_order_(true) + autoinc_mode_is_order_(true), + autoinc_version_(0) {} TO_STRING_KV("tenant_id" , tenant_id_, @@ -121,7 +122,8 @@ struct AutoincParam "part_level" , part_level_, "auto_increment_cache_size" , auto_increment_cache_size_, "part_value_no_order" , part_value_no_order_, - "autoinc_mode_is_order" , autoinc_mode_is_order_); + "autoinc_mode_is_order" , autoinc_mode_is_order_, + "autoinc_version" , autoinc_version_); inline bool with_order() const { return !part_value_no_order_; } // pay attention to schema changes @@ -158,6 +160,7 @@ struct AutoincParam schema::ObPartitionLevel part_level_; int64_t auto_increment_cache_size_; bool autoinc_mode_is_order_; + int64_t autoinc_version_; OB_UNIS_VERSION(1); }; diff --git a/src/share/ob_autoincrement_service.cpp b/src/share/ob_autoincrement_service.cpp index 5a332f637d..6eb35ea9e5 100644 --- a/src/share/ob_autoincrement_service.cpp +++ b/src/share/ob_autoincrement_service.cpp @@ -744,6 +744,7 @@ int ObAutoincrementService::get_table_node(const AutoincParam ¶m, TableNode LOG_ERROR("failed to init table node", K(param), K(ret)); } else { table_node->prefetch_node_.reset(); + table_node->autoinc_version_ = param.autoinc_version_; lib::ObMutexGuard guard(map_mutex_); if (OB_FAIL(node_map_.insert_and_get(key, table_node))) { LOG_WARN("failed to create table node", K(param), K(ret)); @@ -756,6 +757,20 @@ int ObAutoincrementService::get_table_node(const AutoincParam ¶m, TableNode } mutex.unlock(); } + } else { + if (OB_FAIL(alloc_autoinc_try_lock(table_node->alloc_mutex_))) { + LOG_WARN("failed to get lock", K(ret)); + } else if (OB_UNLIKELY(param.autoinc_version_ != table_node->autoinc_version_)) { + LOG_INFO("start reset table node", K(*table_node), K(param)); + table_node->next_value_ = 0; + table_node->local_sync_ = 0; + table_node->curr_node_.reset(); + table_node->prefetch_node_.reset(); + table_node->prefetching_ = false; + table_node->curr_node_state_is_pending_ = true; + table_node->autoinc_version_ = param.autoinc_version_; + } + table_node->alloc_mutex_.unlock(); } if (OB_SUCC(ret)) { LOG_DEBUG("succ to get table node", K(param), KPC(table_node), K(ret)); diff --git a/src/share/ob_autoincrement_service.h b/src/share/ob_autoincrement_service.h index 7f6137ed0d..9d57d5d6fc 100644 --- a/src/share/ob_autoincrement_service.h +++ b/src/share/ob_autoincrement_service.h @@ -114,7 +114,8 @@ struct TableNode: public common::LinkHashValue local_sync_(0), last_refresh_ts_(common::ObTimeUtility::current_time()), prefetching_(false), - curr_node_state_is_pending_(false) + curr_node_state_is_pending_(false), + autoinc_version_(0) {} virtual ~TableNode() { @@ -128,7 +129,8 @@ struct TableNode: public common::LinkHashValue K_(last_refresh_ts), K_(curr_node), K_(prefetch_node), - K_(prefetching)); + K_(prefetching), + K_(autoinc_version)); int alloc_handle(common::ObSmallAllocator &allocator, const uint64_t offset, @@ -167,6 +169,7 @@ struct TableNode: public common::LinkHashValue // and combine them together. // ref: https://yuque.antfin-inc.com/xiaochu.yh/doc/eqnlv0 bool curr_node_state_is_pending_; + int64_t autoinc_version_; }; // atomic update if greater than origin value diff --git a/src/share/schema/ob_schema_retrieve_utils.ipp b/src/share/schema/ob_schema_retrieve_utils.ipp index 25b9fb1c04..ccd1e633b9 100644 --- a/src/share/schema/ob_schema_retrieve_utils.ipp +++ b/src/share/schema/ob_schema_retrieve_utils.ipp @@ -1284,6 +1284,7 @@ int ObSchemaRetrieveUtils::fill_table_schema( EXTRACT_INT_FIELD_TO_CLASS_MYSQL_WITH_DEFAULT_VALUE(result, table_flags, table_schema, uint64_t, true, ignore_column_error, 0); EXTRACT_INT_FIELD_TO_CLASS_MYSQL_WITH_DEFAULT_VALUE(result, object_status, table_schema, int64_t, true, ignore_column_error, static_cast (ObObjectStatus::VALID)); + EXTRACT_INT_FIELD_TO_CLASS_MYSQL_WITH_DEFAULT_VALUE(result, truncate_version, table_schema, int64_t, true, ignore_column_error, common::OB_INVALID_VERSION); } if (OB_SUCC(ret) && OB_FAIL(fill_sys_table_lob_tid(table_schema))) { SHARE_SCHEMA_LOG(WARN, "fail to fill lob table id for inner table", K(ret), K(table_schema.get_table_id())); @@ -3844,6 +3845,7 @@ int ObSchemaRetrieveUtils::fill_table_schema(const uint64_t tenant_id, EXTRACT_INT_FIELD_TO_CLASS_MYSQL_WITH_DEFAULT_VALUE(result, tablet_id, table_schema, uint64_t, true, ignore_column_error, 0); ignore_column_error = true; EXTRACT_INT_FIELD_TO_CLASS_MYSQL_WITH_DEFAULT_VALUE(result, object_status, table_schema, int64_t, true, ignore_column_error, ObObjectStatus::VALID); + EXTRACT_INT_FIELD_TO_CLASS_MYSQL_WITH_DEFAULT_VALUE(result, truncate_version, table_schema, int64_t, true, ignore_column_error, common::OB_INVALID_VERSION); } return ret; } diff --git a/src/share/schema/ob_schema_service_sql_impl.cpp b/src/share/schema/ob_schema_service_sql_impl.cpp index c4779df6a6..1c43407788 100644 --- a/src/share/schema/ob_schema_service_sql_impl.cpp +++ b/src/share/schema/ob_schema_service_sql_impl.cpp @@ -1666,7 +1666,7 @@ int ObSchemaServiceSQLImpl::fetch_all_part_info( const uint64_t tenant_id, ObISQLClient &sql_client, ObArray &range_part_tables, - const uint64_t *table_ids /* = NULL */, + const TableTrunc *table_ids /* = NULL */, const int64_t table_ids_size /*= 0 */) { int ret = OB_SUCCESS; @@ -1698,10 +1698,8 @@ int ObSchemaServiceSQLImpl::fetch_all_part_info( LOG_WARN("append sql failed", K(ret)); } else { if (NULL != table_ids && table_ids_size > 0) { - if (OB_FAIL(sql.append_fmt(" AND table_id IN "))) { - LOG_WARN("append sql failed", K(ret)); - } else if (OB_FAIL(sql_append_pure_ids(schema_status, table_ids, table_ids_size, sql))) { - LOG_WARN("sql append table ids failed", K(ret)); + if (OB_FAIL(sql_append_ids_and_truncate_version(schema_status, table_ids, table_ids_size, schema_version, sql))) { + LOG_WARN("sql append table is failed", K(ret)); } } } @@ -1818,7 +1816,7 @@ int ObSchemaServiceSQLImpl::fetch_all_subpart_info( const uint64_t tenant_id, ObISQLClient &sql_client, ObArray &range_subpart_tables, - const uint64_t *table_ids /* = NULL */, + const TableTrunc *table_ids /* = NULL */, const int64_t table_ids_size /*= 0 */) { int ret = OB_SUCCESS; @@ -1850,10 +1848,8 @@ int ObSchemaServiceSQLImpl::fetch_all_subpart_info( LOG_WARN("append sql failed", K(ret)); } else { if (NULL != table_ids && table_ids_size > 0) { - if (OB_FAIL(sql.append_fmt(" AND table_id IN "))) { - LOG_WARN("append sql failed", K(ret)); - } else if (OB_FAIL(sql_append_pure_ids(schema_status, table_ids, table_ids_size, sql))) { - LOG_WARN("sql append table ids failed"); + if (OB_FAIL(sql_append_ids_and_truncate_version(schema_status, table_ids, table_ids_size, schema_version, sql))) { + LOG_WARN("sql append table is failed", K(ret)); } } } @@ -1889,9 +1885,9 @@ int ObSchemaServiceSQLImpl::gen_batch_fetch_array( common::ObArray &table_schema_array, const uint64_t *table_ids /* = NULL */, const int64_t table_ids_size /*= 0 */, - common::ObIArray &part_tables, + common::ObIArray &part_tables, + common::ObIArray &subpart_tables, common::ObIArray &def_subpart_tables, - common::ObIArray &subpart_tables, common::ObIArray &part_idxs, common::ObIArray &def_subpart_idxs, common::ObIArray &subpart_idxs) @@ -1919,7 +1915,7 @@ int ObSchemaServiceSQLImpl::gen_batch_fetch_array( continue; } else if (table_schema->is_user_partition_table()) { if (PARTITION_LEVEL_ONE <= table_schema->get_part_level()) { - if (OB_FAIL(part_tables.push_back(table_id))) { + if (OB_FAIL(part_tables.push_back(TableTrunc(table_id, table_schema->get_truncate_version())))) { LOG_WARN("Failed to push back table id", K(ret)); } else { batch_part_num += table_schema->get_part_option().get_part_num(); @@ -1962,7 +1958,7 @@ int ObSchemaServiceSQLImpl::gen_batch_fetch_array( } if (OB_SUCC(ret) && PARTITION_LEVEL_TWO == table_schema->get_part_level()) { - if (OB_FAIL(subpart_tables.push_back(table_id))) { + if (OB_FAIL(subpart_tables.push_back(TableTrunc(table_id, table_schema->get_truncate_version())))) { LOG_WARN("Failed to push back table id", K(ret)); } else { //FIXME:(yanmu.ztl) use precise total partition num instead @@ -2032,14 +2028,14 @@ int ObSchemaServiceSQLImpl::fetch_all_partition_info( ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid tenant_id", K(ret), K(tenant_id)); } else { - ObSEArray part_tables; + ObSEArray part_tables; + ObSEArray subpart_tables; ObSEArray def_subpart_tables; - ObSEArray subpart_tables; ObSEArray part_idxs; ObSEArray def_subpart_idxs; ObSEArray subpart_idxs; if (OB_FAIL(gen_batch_fetch_array(table_schema_array, table_ids, table_ids_size, - part_tables, def_subpart_tables, subpart_tables, + part_tables, subpart_tables, def_subpart_tables, part_idxs, def_subpart_idxs, subpart_idxs))) { LOG_WARN("fail to gen batch fetch array", K(ret), K(schema_status), K(tenant_id), K(schema_version)); @@ -2056,7 +2052,7 @@ int ObSchemaServiceSQLImpl::fetch_all_partition_info( int64_t start_idx = 0 == i ? 0 : part_idxs.at(i - 1) + 1; int64_t part_cnt = part_idxs.at(i) - start_idx + 1; LOG_TRACE("batch parts:", K(start_idx), K(part_cnt), - "part_tables", ObArrayWrap(&part_tables.at(start_idx), part_cnt)); + "part_tables", ObArrayWrap(&part_tables.at(start_idx), part_cnt)); if (OB_FAIL(fetch_all_part_info(schema_status, schema_version, tenant_id, sql_client, table_schema_array, &part_tables.at(start_idx), @@ -2088,7 +2084,7 @@ int ObSchemaServiceSQLImpl::fetch_all_partition_info( int64_t start_idx = 0 == i ? 0 : subpart_idxs.at(i - 1) + 1; int64_t part_cnt = subpart_idxs.at(i) - start_idx + 1; LOG_TRACE("batch subparts:", K(start_idx), K(part_cnt), - "subpart_tables", ObArrayWrap(&subpart_tables.at(start_idx), part_cnt)); + "subpart_tables", ObArrayWrap(&subpart_tables.at(start_idx), part_cnt)); if (OB_FAIL(fetch_all_subpart_info(schema_status, schema_version, tenant_id, sql_client, table_schema_array, &subpart_tables.at(start_idx), @@ -2960,6 +2956,39 @@ GET_BATCH_SCHEMAS_FUNC_DEFINE(rls_policy, ObRlsPolicySchema); GET_BATCH_SCHEMAS_FUNC_DEFINE(rls_group, ObRlsGroupSchema); GET_BATCH_SCHEMAS_FUNC_DEFINE(rls_context, ObRlsContextSchema); +int ObSchemaServiceSQLImpl::sql_append_pure_ids( + const ObRefreshSchemaStatus &schema_status, + const TableTrunc *ids, + const int64_t ids_size, + common::ObSqlString &sql) +{ + int ret = OB_SUCCESS; + if (OB_ISNULL(ids) || ids_size <= 0) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("invalid argument", K(ids), K(ids_size)); + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(sql.append("("))) { + LOG_WARN("append sql failed", K(ret)); + } else { + for (int64_t i = 0; OB_SUCC(ret) && i < ids_size; ++i) { + if (OB_FAIL(sql.append_fmt("%s%lu", 0 == i ? "" : ", ", + fill_extract_schema_id(schema_status, ids[i].table_id_)))) { + LOG_WARN("append sql failed", K(ret), K(i)); + } + } + if (OB_SUCC(ret)) { + if (OB_FAIL(sql.append(")"))) { + LOG_WARN("append sql failed", K(ret)); + } + } + } + } + + return ret; +} + int ObSchemaServiceSQLImpl::sql_append_pure_ids( const ObRefreshSchemaStatus &schema_status, const uint64_t *ids, @@ -2993,6 +3022,44 @@ int ObSchemaServiceSQLImpl::sql_append_pure_ids( return ret; } +int ObSchemaServiceSQLImpl::sql_append_ids_and_truncate_version( + const ObRefreshSchemaStatus &schema_status, + const TableTrunc *ids, + const int64_t ids_size, + const int64_t schema_version, + common::ObSqlString &sql) +{ + int ret = OB_SUCCESS; + if (OB_ISNULL(ids) || ids_size <= 0) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("invalid argument", KR(ret), K(ids), K(ids_size)); + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(sql.append(" AND ("))) { + LOG_WARN("append sql failed", KR(ret)); + } else { + for (int64_t i = 0; OB_SUCC(ret) && i < ids_size; ++i) { + if (ids[i].truncate_version_ > schema_version) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("truncate version can not bigger than schema version", KR(ret), K(table_id), K(ids[i].truncate_version_), K(schema_version)); + } else if (OB_FAIL(sql.append_fmt("%s(table_id = %lu AND schema_version >= %ld)", 0 == i ? "" : "OR ", + fill_extract_schema_id(schema_status, ids[i].table_id_), + ids[i].truncate_version_))) { + LOG_WARN("append sql failed", KR(ret), K(i)); + } + } + if (OB_SUCC(ret)) { + if (OB_FAIL(sql.append(")"))) { + LOG_WARN("append sql failed", KR(ret)); + } + } + } + } + + return ret; +} + int ObSchemaServiceSQLImpl::get_batch_tenants( common::ObISQLClient &sql_client, const int64_t schema_version, @@ -5569,6 +5636,10 @@ int ObSchemaServiceSQLImpl::fetch_part_info( if (OB_ISNULL(schema)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("schema should not be NULL", K(ret)); + } else if (schema->get_truncate_version() > schema_version) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("truncate version can not bigger than schema version", KR(ret), K(fill_extract_tenant_id(schema_status, tenant_id)), + K(schema->get_truncate_version()), K(schema_version)); } else if (PARTITION_LEVEL_ZERO == schema->get_part_level()) { // skip } else { @@ -5577,8 +5648,9 @@ int ObSchemaServiceSQLImpl::fetch_part_info( if (OB_FAIL(sql.append_fmt(FETCH_ALL_PART_HISTORY_SQL, OB_ALL_PART_HISTORY_TNAME, fill_extract_tenant_id(schema_status, tenant_id)))) { LOG_WARN("append sql failed", K(ret)); - } else if (OB_FAIL(sql.append_fmt(" AND table_id = %lu AND schema_version <= %ld", + } else if (OB_FAIL(sql.append_fmt(" AND table_id = %lu AND schema_version >= %ld AND schema_version <= %ld", fill_extract_schema_id(schema_status, schema_id), + schema->get_truncate_version(), schema_version))) { LOG_WARN("append sql failed", K(ret)); } else if (OB_FAIL(sql.append_fmt(" ORDER BY tenant_id, table_id, part_id, schema_version"))) { @@ -5618,6 +5690,10 @@ int ObSchemaServiceSQLImpl::fetch_sub_part_info( if (OB_ISNULL(schema)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("schema should not be NULL", K(ret)); + } else if (schema->get_truncate_version() > schema_version) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("truncate version can not bigger than schema version", KR(ret), K(fill_extract_tenant_id(schema_status, tenant_id)), + K(schema->get_truncate_version()), K(schema_version)); } else if (PARTITION_LEVEL_TWO != schema->get_part_level()) { // skip } else if (schema->has_sub_part_template_def()) { @@ -5653,9 +5729,10 @@ int ObSchemaServiceSQLImpl::fetch_sub_part_info( if (OB_FAIL(sql.append_fmt(FETCH_ALL_SUB_PART_HISTORY_SQL, OB_ALL_SUB_PART_HISTORY_TNAME, fill_extract_tenant_id(schema_status, tenant_id)))) { LOG_WARN("append sql failed", K(ret)); - } else if (OB_FAIL(sql.append_fmt(" AND table_id = %lu and schema_version <= %ld " + } else if (OB_FAIL(sql.append_fmt(" AND table_id = %lu AND schema_version >= %ld AND schema_version <= %ld " " ORDER BY tenant_id, table_id, part_id, sub_part_id, schema_version", fill_extract_schema_id(schema_status, schema_id), + schema->get_truncate_version(), schema_version))) { LOG_WARN("append sql failed", K(ret)); } else { @@ -8480,8 +8557,8 @@ int ObSchemaServiceSQLImpl::fetch_link_table_info(uint64_t tenant_id, } } LOG_DEBUG("dblink column schema", K(i), K(column_schema.get_data_precision()), - K(column_schema.get_data_scale()), - K(column_schema.get_data_length()), + K(column_schema.get_data_scale()), + K(column_schema.get_data_length()), K(column_schema.get_data_type())); if (OB_FAIL(ret)) { } else if (OB_FAIL(tmp_table_schema.add_column(column_schema))) { @@ -8506,7 +8583,7 @@ int ObSchemaServiceSQLImpl::fetch_link_table_info(uint64_t tenant_id, } if (NULL != dblink_conn) { int tmp_ret = OB_SUCCESS; - if (DBLINK_DRV_OB == link_type && + if (DBLINK_DRV_OB == link_type && NULL != result && OB_SUCCESS != (tmp_ret = result->close())) { LOG_WARN("failed to close result", K(tmp_ret)); diff --git a/src/share/schema/ob_schema_service_sql_impl.h b/src/share/schema/ob_schema_service_sql_impl.h index cf8c10eb49..eb05bf3c35 100644 --- a/src/share/schema/ob_schema_service_sql_impl.h +++ b/src/share/schema/ob_schema_service_sql_impl.h @@ -43,6 +43,7 @@ #include "share/schema/ob_context_sql_service.h" #include "share/schema/ob_rls_sql_service.h" #include "sql/dblink/ob_dblink_utils.h" +#include "lib/string/ob_string.h" namespace oceanbase { @@ -86,6 +87,14 @@ public: const static int TENANT_MAP_BUCKET_NUM = 1024; const static int64_t MAX_BATCH_PART_NUM = 5000; + struct TableTrunc { + TableTrunc() : table_id_(OB_INVALID_ID), truncate_version_(OB_INVALID_VERSION) {} + TableTrunc(uint64_t table_id, int64_t truncate_version) : table_id_(table_id), truncate_version_(truncate_version) {} + uint64_t table_id_; + int64_t truncate_version_; + TO_STRING_KV(K_(table_id), K_(truncate_version)); + }; + ObSchemaServiceSQLImpl(); virtual ~ObSchemaServiceSQLImpl(); virtual int init(common::ObMySQLProxy *sql_proxy, @@ -664,9 +673,9 @@ private: common::ObArray &table_schema_array, const uint64_t *table_ids /* = NULL */, const int64_t table_ids_size /*= 0 */, - common::ObIArray &part_tables, + common::ObIArray &part_tables, + common::ObIArray &subpart_tables, common::ObIArray &def_subpart_tables, - common::ObIArray &subpart_tables, common::ObIArray &part_idxs, common::ObIArray &def_subpart_idxs, common::ObIArray &subpart_idxs); @@ -698,10 +707,19 @@ private: // retrieve core table and sys table don't read history table, set check_deleted to false // to filter is_deleted column + int sql_append_pure_ids(const ObRefreshSchemaStatus &schema_status, + const TableTrunc *ids, + const int64_t ids_size, + common::ObSqlString &sql); int sql_append_pure_ids(const ObRefreshSchemaStatus &schema_status, const uint64_t *ids, const int64_t ids_size, common::ObSqlString &sql); + int sql_append_ids_and_truncate_version(const ObRefreshSchemaStatus &schema_status, + const TableTrunc *ids, + const int64_t ids_size, + const int64_t schema_version, + common::ObSqlString &sql); //-------------------------- for new schema_cache ------------------------------ @@ -750,7 +768,7 @@ private: const uint64_t tenant_id, common::ObISQLClient &sql_client, common::ObArray &range_part_tables, - const uint64_t *table_ids /* = NULL */, + const TableTrunc *table_ids /* = NULL */, const int64_t table_ids_size /*= 0 */); template int fetch_all_def_subpart_info(const ObRefreshSchemaStatus &schema_status, @@ -767,7 +785,7 @@ private: const uint64_t tenant_id, common::ObISQLClient &sql_client, common::ObArray &range_subpart_tables, - const uint64_t *table_ids /* = NULL */, + const TableTrunc *table_ids /* = NULL */, const int64_t table_ids_size /*= 0 */); int fetch_partition_info(const ObRefreshSchemaStatus &schema_status, diff --git a/src/share/schema/ob_schema_struct.h b/src/share/schema/ob_schema_struct.h index 144b235d54..bc2a7b0857 100644 --- a/src/share/schema/ob_schema_struct.h +++ b/src/share/schema/ob_schema_struct.h @@ -2585,7 +2585,7 @@ public: virtual bool is_hidden_schema() const override { return false; } virtual bool is_normal_schema() const override { return !is_hidden_schema(); } virtual int check_if_oracle_compat_mode(bool &is_oracle_mode) const; - + inline int64_t get_truncate_version() { return 0; } DECLARE_VIRTUAL_TO_STRING; private: diff --git a/src/share/schema/ob_table_schema.cpp b/src/share/schema/ob_table_schema.cpp index 69bad19a1f..c9e2a8ee73 100644 --- a/src/share/schema/ob_table_schema.cpp +++ b/src/share/schema/ob_table_schema.cpp @@ -146,6 +146,7 @@ int ObSimpleTableSchemaV2::assign(const ObSimpleTableSchemaV2 &other) in_offline_ddl_white_list_ = other.in_offline_ddl_white_list_; object_status_ = other.object_status_; is_force_view_ = other.is_force_view_; + truncate_version_ = other.truncate_version_; if (OB_FAIL(table_mode_.assign(other.table_mode_))) { LOG_WARN("Fail to assign table mode", K(ret), K(other.table_mode_)); } else if (OB_FAIL(deep_copy_str(other.table_name_, table_name_))) { @@ -206,7 +207,8 @@ bool ObSimpleTableSchemaV2::operator ==(const ObSimpleTableSchemaV2 &other) cons link_table_id_ == other.link_table_id_ && link_schema_version_ == other.link_schema_version_ && link_database_name_ == other.link_database_name_ && - object_status_ == other.object_status_) { + object_status_ == other.object_status_ && + truncate_version_ == other.truncate_version_) { ret = true; if (true == ret) { if (simple_foreign_key_info_array_.count() == other.simple_foreign_key_info_array_.count()) { @@ -280,6 +282,7 @@ void ObSimpleTableSchemaV2::reset() tablespace_id_ = OB_INVALID_ID; encrypt_key_.reset(); master_key_id_ = OB_INVALID_ID; + truncate_version_ = OB_INVALID_VERSION; ObPartitionSchema::reset(); } @@ -787,7 +790,8 @@ int64_t ObSimpleTableSchemaV2::to_string(char *buf, const int64_t buf_len) const K(get_tablet_id()), K_(max_dependency_version), K_(object_status), - K_(is_force_view) + K_(is_force_view), + K_(truncate_version) ); J_OBJ_END(); @@ -5653,7 +5657,7 @@ OB_DEF_SERIALIZE(ObTableSchema) rls_group_ids_, rls_context_ids_); } - LST_DO_CODE(OB_UNIS_ENCODE, object_status_, is_force_view_); + LST_DO_CODE(OB_UNIS_ENCODE, object_status_, is_force_view_, truncate_version_); }(); return ret; } @@ -5990,7 +5994,7 @@ OB_DEF_DESERIALIZE(ObTableSchema) rls_policy_ids_, rls_group_ids_, rls_context_ids_); - LST_DO_CODE(OB_UNIS_DECODE, object_status_, is_force_view_); + LST_DO_CODE(OB_UNIS_DECODE, object_status_, is_force_view_, truncate_version_); } }(); return ret; @@ -6124,6 +6128,7 @@ OB_DEF_SERIALIZE_SIZE(ObTableSchema) rls_context_ids_); OB_UNIS_ADD_LEN(object_status_); OB_UNIS_ADD_LEN(is_force_view_); + OB_UNIS_ADD_LEN(truncate_version_); return len; } diff --git a/src/share/schema/ob_table_schema.h b/src/share/schema/ob_table_schema.h index a1294ad952..ea5420358c 100644 --- a/src/share/schema/ob_table_schema.h +++ b/src/share/schema/ob_table_schema.h @@ -572,6 +572,8 @@ public: inline void set_session_id(const uint64_t id) { session_id_ = id; } inline uint64_t get_session_id() const { return session_id_; } + inline void set_truncate_version(const int64_t truncate_version ) { truncate_version_ = truncate_version; } + inline int64_t get_truncate_version() const {return truncate_version_; } virtual int get_zone_list( share::schema::ObSchemaGetterGuard &schema_guard, common::ObIArray &zone_list) const override; @@ -812,6 +814,7 @@ protected: uint64_t tablespace_id_; common::ObString encrypt_key_; uint64_t master_key_id_; + int64_t truncate_version_; // dblink. diff --git a/src/share/schema/ob_table_sql_service.cpp b/src/share/schema/ob_table_sql_service.cpp index d9385f31bf..af4b816040 100644 --- a/src/share/schema/ob_table_sql_service.cpp +++ b/src/share/schema/ob_table_sql_service.cpp @@ -2542,6 +2542,10 @@ int ObTableSqlService::gen_table_dml( || table.view_column_filled())) { ret = OB_NOT_SUPPORTED; LOG_WARN("option is not support before 4.1", K(ret), K(table)); + } else if (data_version < DATA_VERSION_4_1_0_0 + && OB_UNLIKELY((OB_INVALID_VERSION != table.get_truncate_version()))) { + ret = OB_NOT_SUPPORTED; + LOG_WARN("truncate version is not support before 4.1", K(ret), K(table)); } else { const ObPartitionOption &part_option = table.get_part_option(); const ObPartitionOption &sub_part_option = table.get_sub_part_option(); @@ -2649,6 +2653,8 @@ int ObTableSqlService::gen_table_dml( && OB_FAIL(dml.add_column("object_status", static_cast (table.get_object_status())))) || (data_version >= DATA_VERSION_4_1_0_0 && OB_FAIL(dml.add_column("table_flags", table.get_table_flags()))) + || (data_version >= DATA_VERSION_4_1_0_0 + && OB_FAIL(dml.add_column("truncate_version", table.get_truncate_version()))) ) { LOG_WARN("add column failed", K(ret)); } @@ -2783,6 +2789,10 @@ int ObTableSqlService::update_table_attribute(ObISQLClient &sql_client, || new_table_schema.view_column_filled())) { ret = OB_NOT_SUPPORTED; LOG_WARN("option is not support before 4.1", K(ret), K(new_table_schema)); + } else if (data_version < DATA_VERSION_4_1_0_0 + && OB_UNLIKELY((OB_INVALID_VERSION != new_table_schema.get_truncate_version()))) { + ret = OB_NOT_SUPPORTED; + LOG_WARN("truncate version is not support before 4.1", K(ret), K(new_table_schema)); } else if (OB_FAIL(dml.add_pk_column("tenant_id", ObSchemaUtils::get_extract_tenant_id( exec_tenant_id, tenant_id))) || OB_FAIL(dml.add_pk_column("table_id", ObSchemaUtils::get_extract_schema_id( @@ -2812,6 +2822,8 @@ int ObTableSqlService::update_table_attribute(ObISQLClient &sql_client, || OB_FAIL(dml.add_column("data_table_id", new_table_schema.get_data_table_id())) || ((data_version >= DATA_VERSION_4_1_0_0 || update_object_status_ignore_version) && OB_FAIL(dml.add_column("object_status", static_cast (new_table_schema.get_object_status())))) + || (data_version >= DATA_VERSION_4_1_0_0 + && OB_FAIL(dml.add_column("truncate_version", new_table_schema.get_truncate_version()))) ) { LOG_WARN("add column failed", K(ret)); } else { diff --git a/src/sql/resolver/dml/ob_del_upd_resolver.cpp b/src/sql/resolver/dml/ob_del_upd_resolver.cpp index 29eb061138..a1256c5983 100644 --- a/src/sql/resolver/dml/ob_del_upd_resolver.cpp +++ b/src/sql/resolver/dml/ob_del_upd_resolver.cpp @@ -2577,7 +2577,7 @@ int ObDelUpdResolver::build_column_conv_function_with_value_desc(ObInsertTableIn ret = OB_ERR_UNEXPECTED; LOG_WARN("table schema is null", K(ret), K(table_item->ddl_table_id_)); } else { - skip_convert = table_schema->is_index_table() || + skip_convert = table_schema->is_index_table() || column_item->column_id_ == OB_HIDDEN_PK_INCREMENT_COLUMN_ID; LOG_TRACE("skip convert expr in ddl", K(table_item->ddl_table_id_), K(skip_convert)); } @@ -2758,6 +2758,7 @@ int ObDelUpdResolver::generate_autoinc_params(ObInsertTableInfo &table_info) param.autoinc_col_type_ = column_type; param.autoinc_desired_count_ = 0; param.autoinc_mode_is_order_ = table_schema->is_order_auto_increment_mode(); + param.autoinc_version_ = table_schema->get_truncate_version(); // hidden pk auto-increment variables' default value is 1 // auto-increment variables for other columns are set in ob_sql.cpp // because physical plan may come from plan cache; it need be reset every time @@ -4001,12 +4002,12 @@ int ObDelUpdResolver::add_relation_columns(ObIArray &table_as } } } - + } return ret; } -int ObDelUpdResolver::replace_column_ref(ObArray *value_row, +int ObDelUpdResolver::replace_column_ref(ObArray *value_row, ObRawExpr *&expr, bool in_generated_column) {