提交 f0f5ba08 编写于 作者: O obdev 提交者: wangzelin.wzl

add virtual table and cdb system view for ttl

上级 a6b02843
......@@ -166,7 +166,7 @@ class ObTableTTLDeleteRowIterator : public common::ObNewRowIterator
{
public:
ObTableTTLDeleteRowIterator():
is_inited_(false), time_to_live_(INT64_MAX), max_version_(UINT64_MAX),
is_inited_(false), time_to_live_(0), max_version_(0),
limit_del_rows_(-1), cur_del_rows_(0), cur_version_(0), cur_rowkey_(), cur_qualifier_(),
max_version_cnt_(0), ttl_cnt_(0), scan_cnt_(0), is_last_row_ttl_(true) {}
~ObTableTTLDeleteRowIterator() {}
......
......@@ -1134,7 +1134,7 @@ int ObTTLTenantTaskMgr::fetch_ttl_task_id(uint64_t tenant_id, int64_t &new_task_
tmp_task_id, 0))) {
LOG_WARN("fail to fetch new ttl task id", K(ret), "id_type", share::OB_MAX_USED_TTL_TASK_ID_TYPE);
} else {
new_task_id = tmp_task_id;
new_task_id = extract_pure_id(tmp_task_id);
}
return ret;
}
......
/**
* Copyright (c) 2021 OceanBase
* OceanBase CE is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*/
#define USING_LOG_PREFIX SHARE_SCHEMA
#include "ob_inner_table_schema.h"
#include "share/schema/ob_schema_macro_define.h"
#include "share/schema/ob_schema_service_sql_impl.h"
#include "share/schema/ob_table_schema.h"
namespace oceanbase
{
using namespace share::schema;
using namespace common;
namespace share
{
int ObInnerTableSchema::all_virtual_kv_ttl_task_schema(ObTableSchema &table_schema)
{
int ret = OB_SUCCESS;
uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;
//generated fields:
table_schema.set_tenant_id(OB_SYS_TENANT_ID);
table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_DATABASE_ID));
table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_ALL_VIRTUAL_KV_TTL_TASK_TID));
table_schema.set_rowkey_split_pos(0);
table_schema.set_is_use_bloomfilter(false);
table_schema.set_progressive_merge_num(0);
table_schema.set_rowkey_column_num(4);
table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
table_schema.set_table_type(VIRTUAL_TABLE);
table_schema.set_index_type(INDEX_TYPE_IS_NOT);
table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);
if (OB_SUCC(ret)) {
if (OB_FAIL(table_schema.set_table_name(OB_ALL_VIRTUAL_KV_TTL_TASK_TNAME))) {
LOG_ERROR("fail to set table_name", K(ret));
}
}
if (OB_SUCC(ret)) {
if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
LOG_ERROR("fail to set compress_func_name", K(ret));
}
}
table_schema.set_part_level(PARTITION_LEVEL_ZERO);
table_schema.set_charset_type(ObCharset::get_default_charset());
table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
table_schema.set_create_mem_version(1);
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA("tenant_id", //column_name
++column_id, //column_id
1, //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
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA("task_id", //column_name
++column_id, //column_id
2, //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
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA("table_id", //column_name
++column_id, //column_id
3, //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
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA("partition_id", //column_name
++column_id, //column_id
4, //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
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA_TS("gmt_create", //column_name
++column_id, //column_id
0, //rowkey_id
0, //index_id
0, //part_key_pos
ObTimestampType, //column_type
CS_TYPE_INVALID, //column_collation_type
sizeof(ObPreciseDateTime), //column_length
-1, //column_precision
-1, //column_scale
false, //is_nullable
false, //is_autoincrement
false); //is_on_update_for_timestamp
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA_TS("gmt_modified", //column_name
++column_id, //column_id
0, //rowkey_id
0, //index_id
0, //part_key_pos
ObTimestampType, //column_type
CS_TYPE_INVALID, //column_collation_type
sizeof(ObPreciseDateTime), //column_length
-1, //column_precision
-1, //column_scale
false, //is_nullable
false, //is_autoincrement
false); //is_on_update_for_timestamp
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA("task_start_time", //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
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA("task_update_time", //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
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA("trigger_type", //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
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA("status", //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
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA("ttl_del_cnt", //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
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA("max_version_del_cnt", //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
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA("scan_cnt", //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
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA("row_key", //column_name
++column_id, //column_id
0, //rowkey_id
0, //index_id
0, //part_key_pos
ObVarcharType, //column_type
CS_TYPE_BINARY, //column_collation_type
2048, //column_length
-1, //column_precision
-1, //column_scale
false, //is_nullable
false); //is_autoincrement
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA("ret_code", //column_name
++column_id, //column_id
0, //rowkey_id
0, //index_id
0, //part_key_pos
ObVarcharType, //column_type
CS_TYPE_INVALID, //column_collation_type
OB_MAX_ERROR_MSG_LEN, //column_length
-1, //column_precision
-1, //column_scale
false, //is_nullable
false); //is_autoincrement
}
table_schema.set_index_using_type(USING_BTREE);
table_schema.set_row_store_type(FLAT_ROW_STORE);
table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
table_schema.set_progressive_merge_round(1);
table_schema.set_storage_format_version(3);
table_schema.set_max_used_column_id(column_id);
table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
return ret;
}
int ObInnerTableSchema::all_virtual_kv_ttl_task_history_schema(ObTableSchema &table_schema)
{
int ret = OB_SUCCESS;
uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;
//generated fields:
table_schema.set_tenant_id(OB_SYS_TENANT_ID);
table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_DATABASE_ID));
table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_ALL_VIRTUAL_KV_TTL_TASK_HISTORY_TID));
table_schema.set_rowkey_split_pos(0);
table_schema.set_is_use_bloomfilter(false);
table_schema.set_progressive_merge_num(0);
table_schema.set_rowkey_column_num(4);
table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
table_schema.set_table_type(VIRTUAL_TABLE);
table_schema.set_index_type(INDEX_TYPE_IS_NOT);
table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);
if (OB_SUCC(ret)) {
if (OB_FAIL(table_schema.set_table_name(OB_ALL_VIRTUAL_KV_TTL_TASK_HISTORY_TNAME))) {
LOG_ERROR("fail to set table_name", K(ret));
}
}
if (OB_SUCC(ret)) {
if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
LOG_ERROR("fail to set compress_func_name", K(ret));
}
}
table_schema.set_part_level(PARTITION_LEVEL_ZERO);
table_schema.set_charset_type(ObCharset::get_default_charset());
table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
table_schema.set_create_mem_version(1);
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA("tenant_id", //column_name
++column_id, //column_id
1, //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
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA("task_id", //column_name
++column_id, //column_id
2, //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
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA("table_id", //column_name
++column_id, //column_id
3, //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
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA("partition_id", //column_name
++column_id, //column_id
4, //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
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA_TS("gmt_create", //column_name
++column_id, //column_id
0, //rowkey_id
0, //index_id
0, //part_key_pos
ObTimestampType, //column_type
CS_TYPE_INVALID, //column_collation_type
sizeof(ObPreciseDateTime), //column_length
-1, //column_precision
-1, //column_scale
false, //is_nullable
false, //is_autoincrement
false); //is_on_update_for_timestamp
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA_TS("gmt_modified", //column_name
++column_id, //column_id
0, //rowkey_id
0, //index_id
0, //part_key_pos
ObTimestampType, //column_type
CS_TYPE_INVALID, //column_collation_type
sizeof(ObPreciseDateTime), //column_length
-1, //column_precision
-1, //column_scale
false, //is_nullable
false, //is_autoincrement
false); //is_on_update_for_timestamp
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA("task_start_time", //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
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA("task_update_time", //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
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA("trigger_type", //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
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA("status", //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
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA("ttl_del_cnt", //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
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA("max_version_del_cnt", //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
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA("scan_cnt", //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
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA("row_key", //column_name
++column_id, //column_id
0, //rowkey_id
0, //index_id
0, //part_key_pos
ObVarcharType, //column_type
CS_TYPE_BINARY, //column_collation_type
2048, //column_length
-1, //column_precision
-1, //column_scale
false, //is_nullable
false); //is_autoincrement
}
if (OB_SUCC(ret)) {
ADD_COLUMN_SCHEMA("ret_code", //column_name
++column_id, //column_id
0, //rowkey_id
0, //index_id
0, //part_key_pos
ObVarcharType, //column_type
CS_TYPE_INVALID, //column_collation_type
OB_MAX_ERROR_MSG_LEN, //column_length
-1, //column_precision
-1, //column_scale
false, //is_nullable
false); //is_autoincrement
}
table_schema.set_index_using_type(USING_BTREE);
table_schema.set_row_store_type(FLAT_ROW_STORE);
table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
table_schema.set_progressive_merge_round(1);
table_schema.set_storage_format_version(3);
table_schema.set_max_used_column_id(column_id);
table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
return ret;
}
} // end namespace share
} // end namespace oceanbase
......@@ -60,7 +60,7 @@ int ObInnerTableSchema::dba_ob_kv_ttl_tasks_schema(ObTableSchema &table_schema)
table_schema.set_create_mem_version(1);
if (OB_SUCC(ret)) {
if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT b.table_name as TABLE_NAME, a.table_id as TABLE_ID, a.partition_id as PARTITION_ID, usec_to_time(a.task_start_time) as START_TIME, usec_to_time(a.task_update_time) as END_TIME, case a.trigger_type when 0 then "PERIODIC" when 1 then "USER" else "INVALID" END AS TRIGGER_TYPE, case a.status when 0 then "PREPARED" when 1 then "RUNNING" when 2 then "PENDING" when 3 then "CANCELED" when 4 then "FINISHED" when 5 then "MOVED" when 15 then "RS_TRIGGERING" when 16 then "RS_SUSPENDING" when 17 then "RS_CANCELING" when 18 then "RS_MOVING" when 47 then "RS_TRIGGERD" when 48 then "RS_SUSPENDED" when 49 then "RS_CANCELED" when 50 then "RS_MOVED" else "INVALID" END AS STATUS, a.ttl_del_cnt as TTL_DEL_CNT, a.max_version_del_cnt as MAX_VERSION_DEL_CNT, a.scan_cnt as SCAN_CNT, a.ret_code as RET_CODE FROM oceanbase.__all_kv_ttl_task a left outer JOIN oceanbase.__all_table_v2 b on a.table_id = ((a.tenant_id << 40) | b.table_id) )__"))) {
if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT b.table_name as TABLE_NAME, a.table_id as TABLE_ID, a.partition_id as PARTITION_ID, a.task_id as TASK_ID, usec_to_time(a.task_start_time) as START_TIME, usec_to_time(a.task_update_time) as END_TIME, case a.trigger_type when 0 then "PERIODIC" when 1 then "USER" else "INVALID" END AS TRIGGER_TYPE, case a.status when 0 then "PREPARED" when 1 then "RUNNING" when 2 then "PENDING" when 3 then "CANCELED" when 4 then "FINISHED" when 5 then "MOVED" when 15 then "RS_TRIGGERING" when 16 then "RS_SUSPENDING" when 17 then "RS_CANCELING" when 18 then "RS_MOVING" when 47 then "RS_TRIGGERD" when 48 then "RS_SUSPENDED" when 49 then "RS_CANCELED" when 50 then "RS_MOVED" else "INVALID" END AS STATUS, a.ttl_del_cnt as TTL_DEL_CNT, a.max_version_del_cnt as MAX_VERSION_DEL_CNT, a.scan_cnt as SCAN_CNT, a.ret_code as RET_CODE FROM oceanbase.__all_kv_ttl_task a left outer JOIN oceanbase.__all_table_v2 b on a.table_id = ((a.tenant_id << 40) | b.table_id) )__"))) {
LOG_ERROR("fail to set view_definition", K(ret));
}
}
......@@ -112,7 +112,111 @@ int ObInnerTableSchema::dba_ob_kv_ttl_task_history_schema(ObTableSchema &table_s
table_schema.set_create_mem_version(1);
if (OB_SUCC(ret)) {
if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT b.table_name as TABLE_NAME, a.table_id as TABLE_ID, a.partition_id as PARTITION_ID, usec_to_time(a.task_start_time) as START_TIME, usec_to_time(a.task_update_time) as END_TIME, case a.trigger_type when 0 then "PERIODIC" when 1 then "USER" else "INVALID" END AS TRIGGER_TYPE, case a.status when 0 then "PREPARED" when 1 then "RUNNING" when 2 then "PENDING" when 3 then "CANCELED" when 4 then "FINISHED" when 5 then "MOVED" else "INVALID" END AS STATUS, a.ttl_del_cnt as TTL_DEL_CNT, a.max_version_del_cnt as MAX_VERSION_DEL_CNT, a.scan_cnt as SCAN_CNT, a.ret_code as RET_CODE FROM oceanbase.__all_kv_ttl_task_history a left outer JOIN oceanbase.__all_table_v2 b on a.table_id = ((a.tenant_id << 40) | b.table_id) )__"))) {
if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT b.table_name as TABLE_NAME, a.table_id as TABLE_ID, a.partition_id as PARTITION_ID, a.task_id as TASK_ID, usec_to_time(a.task_start_time) as START_TIME, usec_to_time(a.task_update_time) as END_TIME, case a.trigger_type when 0 then "PERIODIC" when 1 then "USER" else "INVALID" END AS TRIGGER_TYPE, case a.status when 0 then "PREPARED" when 1 then "RUNNING" when 2 then "PENDING" when 3 then "CANCELED" when 4 then "FINISHED" when 5 then "MOVED" else "INVALID" END AS STATUS, a.ttl_del_cnt as TTL_DEL_CNT, a.max_version_del_cnt as MAX_VERSION_DEL_CNT, a.scan_cnt as SCAN_CNT, a.ret_code as RET_CODE FROM oceanbase.__all_kv_ttl_task_history a left outer JOIN oceanbase.__all_table_v2 b on a.table_id = ((a.tenant_id << 40) | b.table_id) )__"))) {
LOG_ERROR("fail to set view_definition", K(ret));
}
}
table_schema.set_index_using_type(USING_BTREE);
table_schema.set_row_store_type(FLAT_ROW_STORE);
table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
table_schema.set_progressive_merge_round(1);
table_schema.set_storage_format_version(3);
table_schema.set_max_used_column_id(column_id);
table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
return ret;
}
int ObInnerTableSchema::cdb_ob_kv_ttl_tasks_schema(ObTableSchema &table_schema)
{
int ret = OB_SUCCESS;
uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;
//generated fields:
table_schema.set_tenant_id(OB_SYS_TENANT_ID);
table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_DATABASE_ID));
table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_CDB_OB_KV_TTL_TASKS_TID));
table_schema.set_rowkey_split_pos(0);
table_schema.set_is_use_bloomfilter(false);
table_schema.set_progressive_merge_num(0);
table_schema.set_rowkey_column_num(0);
table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
table_schema.set_table_type(SYSTEM_VIEW);
table_schema.set_index_type(INDEX_TYPE_IS_NOT);
table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);
if (OB_SUCC(ret)) {
if (OB_FAIL(table_schema.set_table_name(OB_CDB_OB_KV_TTL_TASKS_TNAME))) {
LOG_ERROR("fail to set table_name", K(ret));
}
}
if (OB_SUCC(ret)) {
if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
LOG_ERROR("fail to set compress_func_name", K(ret));
}
}
table_schema.set_part_level(PARTITION_LEVEL_ZERO);
table_schema.set_charset_type(ObCharset::get_default_charset());
table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
table_schema.set_create_mem_version(1);
if (OB_SUCC(ret)) {
if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT a.tenant_id as TENANT_ID, b.table_name as TABLE_NAME, a.table_id as TABLE_ID, a.partition_id as PARTITION_ID, a.task_id as TASK_ID, usec_to_time(a.task_start_time) as START_TIME, usec_to_time(a.task_update_time) as END_TIME, case a.trigger_type when 0 then "PERIODIC" when 1 then "USER" else "INVALID" END AS TRIGGER_TYPE, case a.status when 0 then "PREPARED" when 1 then "RUNNING" when 2 then "PENDING" when 3 then "CANCELED" when 4 then "FINISHED" when 5 then "MOVED" when 15 then "RS_TRIGGERING" when 16 then "RS_SUSPENDING" when 17 then "RS_CANCELING" when 18 then "RS_MOVING" when 47 then "RS_TRIGGERD" when 48 then "RS_SUSPENDED" when 49 then "RS_CANCELED" when 50 then "RS_MOVED" else "INVALID" END AS STATUS, a.ttl_del_cnt as TTL_DEL_CNT, a.max_version_del_cnt as MAX_VERSION_DEL_CNT, a.scan_cnt as SCAN_CNT, a.ret_code as RET_CODE FROM oceanbase.__all_virtual_kv_ttl_task a left outer JOIN oceanbase.__all_virtual_table b on a.table_id = b.table_id and a.tenant_id = b.tenant_id )__"))) {
LOG_ERROR("fail to set view_definition", K(ret));
}
}
table_schema.set_index_using_type(USING_BTREE);
table_schema.set_row_store_type(FLAT_ROW_STORE);
table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
table_schema.set_progressive_merge_round(1);
table_schema.set_storage_format_version(3);
table_schema.set_max_used_column_id(column_id);
table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
return ret;
}
int ObInnerTableSchema::cdb_ob_kv_ttl_task_history_schema(ObTableSchema &table_schema)
{
int ret = OB_SUCCESS;
uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;
//generated fields:
table_schema.set_tenant_id(OB_SYS_TENANT_ID);
table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_DATABASE_ID));
table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_CDB_OB_KV_TTL_TASK_HISTORY_TID));
table_schema.set_rowkey_split_pos(0);
table_schema.set_is_use_bloomfilter(false);
table_schema.set_progressive_merge_num(0);
table_schema.set_rowkey_column_num(0);
table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
table_schema.set_table_type(SYSTEM_VIEW);
table_schema.set_index_type(INDEX_TYPE_IS_NOT);
table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);
if (OB_SUCC(ret)) {
if (OB_FAIL(table_schema.set_table_name(OB_CDB_OB_KV_TTL_TASK_HISTORY_TNAME))) {
LOG_ERROR("fail to set table_name", K(ret));
}
}
if (OB_SUCC(ret)) {
if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
LOG_ERROR("fail to set compress_func_name", K(ret));
}
}
table_schema.set_part_level(PARTITION_LEVEL_ZERO);
table_schema.set_charset_type(ObCharset::get_default_charset());
table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
table_schema.set_create_mem_version(1);
if (OB_SUCC(ret)) {
if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT a.tenant_id as TENANT_ID, b.table_name as TABLE_NAME, a.table_id as TABLE_ID, a.partition_id as PARTITION_ID, a.task_id as TASK_ID, usec_to_time(a.task_start_time) as START_TIME, usec_to_time(a.task_update_time) as END_TIME, case a.trigger_type when 0 then "PERIODIC" when 1 then "USER" else "INVALID" END AS TRIGGER_TYPE, case a.status when 0 then "PREPARED" when 1 then "RUNNING" when 2 then "PENDING" when 3 then "CANCELED" when 4 then "FINISHED" when 5 then "MOVED" else "INVALID" END AS STATUS, a.ttl_del_cnt as TTL_DEL_CNT, a.max_version_del_cnt as MAX_VERSION_DEL_CNT, a.scan_cnt as SCAN_CNT, a.ret_code as RET_CODE FROM oceanbase.__all_virtual_kv_ttl_task_history a left outer JOIN oceanbase.__all_virtual_table b on a.table_id = b.table_id and a.tenant_id = b.tenant_id )__"))) {
LOG_ERROR("fail to set view_definition", K(ret));
}
}
......
......@@ -767,6 +767,8 @@ public:
static int all_virtual_backup_backupset_task_schema(share::schema::ObTableSchema &table_schema);
static int all_virtual_pg_backup_backupset_task_schema(share::schema::ObTableSchema &table_schema);
static int all_virtual_global_transaction_schema(share::schema::ObTableSchema &table_schema);
static int all_virtual_kv_ttl_task_schema(share::schema::ObTableSchema &table_schema);
static int all_virtual_kv_ttl_task_history_schema(share::schema::ObTableSchema &table_schema);
static int all_virtual_table_agent_schema(share::schema::ObTableSchema &table_schema);
static int all_virtual_column_agent_schema(share::schema::ObTableSchema &table_schema);
static int all_virtual_database_agent_schema(share::schema::ObTableSchema &table_schema);
......@@ -1079,6 +1081,8 @@ public:
static int column_privileges_schema(share::schema::ObTableSchema &table_schema);
static int dba_ob_kv_ttl_tasks_schema(share::schema::ObTableSchema &table_schema);
static int dba_ob_kv_ttl_task_history_schema(share::schema::ObTableSchema &table_schema);
static int cdb_ob_kv_ttl_tasks_schema(share::schema::ObTableSchema &table_schema);
static int cdb_ob_kv_ttl_task_history_schema(share::schema::ObTableSchema &table_schema);
static int dba_synonyms_schema(share::schema::ObTableSchema &table_schema);
static int dba_objects_schema(share::schema::ObTableSchema &table_schema);
static int all_objects_schema(share::schema::ObTableSchema &table_schema);
......@@ -1803,6 +1807,8 @@ const schema_create_func virtual_table_schema_creators [] = {
ObInnerTableSchema::all_virtual_backup_backupset_task_schema,
ObInnerTableSchema::all_virtual_pg_backup_backupset_task_schema,
ObInnerTableSchema::all_virtual_global_transaction_schema,
ObInnerTableSchema::all_virtual_kv_ttl_task_schema,
ObInnerTableSchema::all_virtual_kv_ttl_task_history_schema,
ObInnerTableSchema::all_virtual_table_agent_schema,
ObInnerTableSchema::all_virtual_column_agent_schema,
ObInnerTableSchema::all_virtual_database_agent_schema,
......@@ -2136,6 +2142,8 @@ const schema_create_func sys_view_schema_creators [] = {
ObInnerTableSchema::column_privileges_schema,
ObInnerTableSchema::dba_ob_kv_ttl_tasks_schema,
ObInnerTableSchema::dba_ob_kv_ttl_task_history_schema,
ObInnerTableSchema::cdb_ob_kv_ttl_tasks_schema,
ObInnerTableSchema::cdb_ob_kv_ttl_task_history_schema,
ObInnerTableSchema::dba_synonyms_schema,
ObInnerTableSchema::dba_objects_schema,
ObInnerTableSchema::all_objects_schema,
......@@ -4070,11 +4078,11 @@ static inline bool is_only_rs_virtual_table(const uint64_t tid)
const int64_t OB_CORE_TABLE_COUNT = 5;
const int64_t OB_SYS_TABLE_COUNT = 189;
const int64_t OB_VIRTUAL_TABLE_COUNT = 463;
const int64_t OB_SYS_VIEW_COUNT = 362;
const int64_t OB_SYS_TENANT_TABLE_COUNT = 1020;
const int64_t OB_VIRTUAL_TABLE_COUNT = 465;
const int64_t OB_SYS_VIEW_COUNT = 364;
const int64_t OB_SYS_TENANT_TABLE_COUNT = 1024;
const int64_t OB_CORE_SCHEMA_VERSION = 1;
const int64_t OB_BOOTSTRAP_SCHEMA_VERSION = 1023;
const int64_t OB_BOOTSTRAP_SCHEMA_VERSION = 1027;
} // end namespace share
} // end namespace oceanbase
......
......@@ -500,6 +500,8 @@ const uint64_t OB_ALL_VIRTUAL_BACKUPSET_HISTORY_MGR_TID = 12201; // "__all_virtu
const uint64_t OB_ALL_VIRTUAL_BACKUP_BACKUPSET_TASK_TID = 12202; // "__all_virtual_backup_backupset_task"
const uint64_t OB_ALL_VIRTUAL_PG_BACKUP_BACKUPSET_TASK_TID = 12203; // "__all_virtual_pg_backup_backupset_task"
const uint64_t OB_ALL_VIRTUAL_GLOBAL_TRANSACTION_TID = 12206; // "__all_virtual_global_transaction"
const uint64_t OB_ALL_VIRTUAL_KV_TTL_TASK_TID = 12326; // "__all_virtual_kv_ttl_task"
const uint64_t OB_ALL_VIRTUAL_KV_TTL_TASK_HISTORY_TID = 12327; // "__all_virtual_kv_ttl_task_history"
const uint64_t OB_ALL_VIRTUAL_TABLE_AGENT_TID = 15001; // "ALL_VIRTUAL_TABLE_AGENT"
const uint64_t OB_ALL_VIRTUAL_COLUMN_AGENT_TID = 15002; // "ALL_VIRTUAL_COLUMN_AGENT"
const uint64_t OB_ALL_VIRTUAL_DATABASE_AGENT_TID = 15003; // "ALL_VIRTUAL_DATABASE_AGENT"
......@@ -812,6 +814,8 @@ const uint64_t OB_CDB_OB_BACKUP_BACKUP_ARCHIVELOG_TID = 21144; // "CDB_OB_BACKUP
const uint64_t OB_COLUMN_PRIVILEGES_TID = 21150; // "COLUMN_PRIVILEGES"
const uint64_t OB_DBA_OB_KV_TTL_TASKS_TID = 21300; // "DBA_OB_KV_TTL_TASKS"
const uint64_t OB_DBA_OB_KV_TTL_TASK_HISTORY_TID = 21301; // "DBA_OB_KV_TTL_TASK_HISTORY"
const uint64_t OB_CDB_OB_KV_TTL_TASKS_TID = 21307; // "CDB_OB_KV_TTL_TASKS"
const uint64_t OB_CDB_OB_KV_TTL_TASK_HISTORY_TID = 21308; // "CDB_OB_KV_TTL_TASK_HISTORY"
const uint64_t OB_DBA_SYNONYMS_TID = 25001; // "DBA_SYNONYMS"
const uint64_t OB_DBA_OBJECTS_TID = 25002; // "DBA_OBJECTS"
const uint64_t OB_ALL_OBJECTS_TID = 25003; // "ALL_OBJECTS"
......@@ -1524,6 +1528,8 @@ const char *const OB_ALL_VIRTUAL_BACKUPSET_HISTORY_MGR_TNAME = "__all_virtual_ba
const char *const OB_ALL_VIRTUAL_BACKUP_BACKUPSET_TASK_TNAME = "__all_virtual_backup_backupset_task";
const char *const OB_ALL_VIRTUAL_PG_BACKUP_BACKUPSET_TASK_TNAME = "__all_virtual_pg_backup_backupset_task";
const char *const OB_ALL_VIRTUAL_GLOBAL_TRANSACTION_TNAME = "__all_virtual_global_transaction";
const char *const OB_ALL_VIRTUAL_KV_TTL_TASK_TNAME = "__all_virtual_kv_ttl_task";
const char *const OB_ALL_VIRTUAL_KV_TTL_TASK_HISTORY_TNAME = "__all_virtual_kv_ttl_task_history";
const char *const OB_ALL_VIRTUAL_TABLE_AGENT_TNAME = "ALL_VIRTUAL_TABLE_AGENT";
const char *const OB_ALL_VIRTUAL_COLUMN_AGENT_TNAME = "ALL_VIRTUAL_COLUMN_AGENT";
const char *const OB_ALL_VIRTUAL_DATABASE_AGENT_TNAME = "ALL_VIRTUAL_DATABASE_AGENT";
......@@ -1836,6 +1842,8 @@ const char *const OB_CDB_OB_BACKUP_BACKUP_ARCHIVELOG_TNAME = "CDB_OB_BACKUP_BACK
const char *const OB_COLUMN_PRIVILEGES_TNAME = "COLUMN_PRIVILEGES";
const char *const OB_DBA_OB_KV_TTL_TASKS_TNAME = "DBA_OB_KV_TTL_TASKS";
const char *const OB_DBA_OB_KV_TTL_TASK_HISTORY_TNAME = "DBA_OB_KV_TTL_TASK_HISTORY";
const char *const OB_CDB_OB_KV_TTL_TASKS_TNAME = "CDB_OB_KV_TTL_TASKS";
const char *const OB_CDB_OB_KV_TTL_TASK_HISTORY_TNAME = "CDB_OB_KV_TTL_TASK_HISTORY";
const char *const OB_DBA_SYNONYMS_TNAME = "DBA_SYNONYMS";
const char *const OB_DBA_OBJECTS_TNAME = "DBA_OBJECTS";
const char *const OB_ALL_OBJECTS_TNAME = "ALL_OBJECTS";
......
......@@ -10214,6 +10214,18 @@ def_table_schema(**gen_iterate_virtual_table_def(
table_name = '__all_virtual_global_transaction',
keywords = all_def_keywords['__all_tenant_global_transaction']))
def_table_schema(**gen_iterate_virtual_table_def(
table_id = '12326',
real_tenant_id=True,
table_name = '__all_virtual_kv_ttl_task',
keywords = all_def_keywords['__all_kv_ttl_task']))
def_table_schema(**gen_iterate_virtual_table_def(
table_id = '12327',
real_tenant_id=True,
table_name = '__all_virtual_kv_ttl_task_history',
keywords = all_def_keywords['__all_kv_ttl_task_history']))
################################################################################
# Oracle Virtual Table(15000,20000]
################################################################################
......@@ -14630,6 +14642,7 @@ def_table_schema(
b.table_name as TABLE_NAME,
a.table_id as TABLE_ID,
a.partition_id as PARTITION_ID,
a.task_id as TASK_ID,
usec_to_time(a.task_start_time) as START_TIME,
usec_to_time(a.task_update_time) as END_TIME,
case a.trigger_type
......@@ -14675,6 +14688,7 @@ def_table_schema(
b.table_name as TABLE_NAME,
a.table_id as TABLE_ID,
a.partition_id as PARTITION_ID,
a.task_id as TASK_ID,
usec_to_time(a.task_start_time) as START_TIME,
usec_to_time(a.task_update_time) as END_TIME,
case a.trigger_type
......@@ -14698,6 +14712,88 @@ def_table_schema(
""".replace("\n", " ")
)
def_table_schema(
table_name = 'CDB_OB_KV_TTL_TASKS',
table_id = '21307',
table_type = 'SYSTEM_VIEW',
rowkey_columns = [],
normal_columns = [],
gm_columns = [],
view_definition = """
SELECT
a.tenant_id as TENANT_ID,
b.table_name as TABLE_NAME,
a.table_id as TABLE_ID,
a.partition_id as PARTITION_ID,
a.task_id as TASK_ID,
usec_to_time(a.task_start_time) as START_TIME,
usec_to_time(a.task_update_time) as END_TIME,
case a.trigger_type
when 0 then "PERIODIC"
when 1 then "USER"
else "INVALID" END AS TRIGGER_TYPE,
case a.status
when 0 then "PREPARED"
when 1 then "RUNNING"
when 2 then "PENDING"
when 3 then "CANCELED"
when 4 then "FINISHED"
when 5 then "MOVED"
when 15 then "RS_TRIGGERING"
when 16 then "RS_SUSPENDING"
when 17 then "RS_CANCELING"
when 18 then "RS_MOVING"
when 47 then "RS_TRIGGERD"
when 48 then "RS_SUSPENDED"
when 49 then "RS_CANCELED"
when 50 then "RS_MOVED"
else "INVALID" END AS STATUS,
a.ttl_del_cnt as TTL_DEL_CNT,
a.max_version_del_cnt as MAX_VERSION_DEL_CNT,
a.scan_cnt as SCAN_CNT,
a.ret_code as RET_CODE
FROM oceanbase.__all_virtual_kv_ttl_task a left outer JOIN oceanbase.__all_virtual_table b on
a.table_id = b.table_id and a.tenant_id = b.tenant_id
""".replace("\n", " ")
)
def_table_schema(
table_name = 'CDB_OB_KV_TTL_TASK_HISTORY',
table_id = '21308',
table_type = 'SYSTEM_VIEW',
rowkey_columns = [],
normal_columns = [],
gm_columns = [],
view_definition = """
SELECT
a.tenant_id as TENANT_ID,
b.table_name as TABLE_NAME,
a.table_id as TABLE_ID,
a.partition_id as PARTITION_ID,
a.task_id as TASK_ID,
usec_to_time(a.task_start_time) as START_TIME,
usec_to_time(a.task_update_time) as END_TIME,
case a.trigger_type
when 0 then "PERIODIC"
when 1 then "USER"
else "INVALID" END AS TRIGGER_TYPE,
case a.status
when 0 then "PREPARED"
when 1 then "RUNNING"
when 2 then "PENDING"
when 3 then "CANCELED"
when 4 then "FINISHED"
when 5 then "MOVED"
else "INVALID" END AS STATUS,
a.ttl_del_cnt as TTL_DEL_CNT,
a.max_version_del_cnt as MAX_VERSION_DEL_CNT,
a.scan_cnt as SCAN_CNT,
a.ret_code as RET_CODE
FROM oceanbase.__all_virtual_kv_ttl_task_history a left outer JOIN oceanbase.__all_virtual_table b on
a.table_id = b.table_id and a.tenant_id = b.tenant_id
""".replace("\n", " ")
)
################################################################################
# Oracle System View (25000, 30000]
# Data Dictionary View (25000, 28000]
......
......@@ -1598,6 +1598,8 @@ case OB_ALL_VIRTUAL_FUNC_TID:
case OB_ALL_VIRTUAL_FUNC_HISTORY_TID:
case OB_ALL_VIRTUAL_GLOBAL_TRANSACTION_TID:
case OB_ALL_VIRTUAL_HISTOGRAM_STAT_TID:
case OB_ALL_VIRTUAL_KV_TTL_TASK_TID:
case OB_ALL_VIRTUAL_KV_TTL_TASK_HISTORY_TID:
case OB_ALL_VIRTUAL_META_TABLE_TID:
case OB_ALL_VIRTUAL_OBJAUTH_TID:
case OB_ALL_VIRTUAL_OBJAUTH_HISTORY_TID:
......@@ -2347,6 +2349,38 @@ case OB_ALL_VIRTUAL_USER_HISTORY_TID:
break;
}
case OB_ALL_VIRTUAL_KV_TTL_TASK_TID: {
ObIterateVirtualTable *iter = NULL;
const bool record_real_tenant_id = true;
if (OB_FAIL(NEW_VIRTUAL_TABLE(ObIterateVirtualTable, iter))) {
SERVER_LOG(WARN, "create virtual table iterator failed", K(ret));
} else if (OB_FAIL(iter->init(OB_ALL_KV_TTL_TASK_TID, record_real_tenant_id, index_schema, params))) {
SERVER_LOG(WARN, "virtual table iter init failed", K(ret));
iter->~ObIterateVirtualTable();
allocator.free(iter);
iter = NULL;
} else {
vt_iter = iter;
}
break;
}
case OB_ALL_VIRTUAL_KV_TTL_TASK_HISTORY_TID: {
ObIterateVirtualTable *iter = NULL;
const bool record_real_tenant_id = true;
if (OB_FAIL(NEW_VIRTUAL_TABLE(ObIterateVirtualTable, iter))) {
SERVER_LOG(WARN, "create virtual table iterator failed", K(ret));
} else if (OB_FAIL(iter->init(OB_ALL_KV_TTL_TASK_HISTORY_TID, record_real_tenant_id, index_schema, params))) {
SERVER_LOG(WARN, "virtual table iter init failed", K(ret));
iter->~ObIterateVirtualTable();
allocator.free(iter);
iter = NULL;
} else {
vt_iter = iter;
}
break;
}
case OB_ALL_VIRTUAL_META_TABLE_TID: {
ObIterateVirtualTable *iter = NULL;
const bool record_real_tenant_id = true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册