181 lines
6.9 KiB
C++
181 lines
6.9 KiB
C++
/**
|
|
* 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"
|
|
#include "share/scn.h"
|
|
|
|
namespace oceanbase
|
|
{
|
|
using namespace share::schema;
|
|
using namespace common;
|
|
namespace share
|
|
{
|
|
|
|
int ObInnerTableSchema::innodb_sys_fields_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(OB_INVALID_ID);
|
|
table_schema.set_database_id(OB_INFORMATION_SCHEMA_ID);
|
|
table_schema.set_table_id(OB_INNODB_SYS_FIELDS_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_INNODB_SYS_FIELDS_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()));
|
|
|
|
if (OB_SUCC(ret)) {
|
|
if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT CAST(NULL as UNSIGNED) as INDEX_ID, CAST(NULL as CHAR) as NAME, CAST(NULL as UNSIGNED) as POS FROM DUAL WHERE 0 = 1 )__"))) {
|
|
LOG_ERROR("fail to set view_definition", K(ret));
|
|
}
|
|
}
|
|
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);
|
|
table_schema.set_progressive_merge_round(1);
|
|
table_schema.set_storage_format_version(3);
|
|
table_schema.set_tablet_id(0);
|
|
|
|
table_schema.set_max_used_column_id(column_id);
|
|
return ret;
|
|
}
|
|
|
|
int ObInnerTableSchema::innodb_sys_foreign_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(OB_INVALID_ID);
|
|
table_schema.set_database_id(OB_INFORMATION_SCHEMA_ID);
|
|
table_schema.set_table_id(OB_INNODB_SYS_FOREIGN_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_INNODB_SYS_FOREIGN_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()));
|
|
|
|
if (OB_SUCC(ret)) {
|
|
if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT CAST(NULL as CHAR) as ID, CAST(NULL as CHAR) as FOR_NAME, CAST(NULL as CHAR) as REF_NAME, CAST(NULL as UNSIGNED) as N_COLS, CAST(NULL as UNSIGNED) as TYPE FROM DUAL WHERE 0 = 1 )__"))) {
|
|
LOG_ERROR("fail to set view_definition", K(ret));
|
|
}
|
|
}
|
|
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);
|
|
table_schema.set_progressive_merge_round(1);
|
|
table_schema.set_storage_format_version(3);
|
|
table_schema.set_tablet_id(0);
|
|
|
|
table_schema.set_max_used_column_id(column_id);
|
|
return ret;
|
|
}
|
|
|
|
int ObInnerTableSchema::innodb_sys_foreign_cols_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(OB_INVALID_ID);
|
|
table_schema.set_database_id(OB_INFORMATION_SCHEMA_ID);
|
|
table_schema.set_table_id(OB_INNODB_SYS_FOREIGN_COLS_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_INNODB_SYS_FOREIGN_COLS_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()));
|
|
|
|
if (OB_SUCC(ret)) {
|
|
if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT CAST(NULL as CHAR) as ID, CAST(NULL as CHAR) as FOR_COL_NAME, CAST(NULL as CHAR) as REF_COL_NAME, CAST(NULL as UNSIGNED) as POS FROM DUAL WHERE 0 = 1 )__"))) {
|
|
LOG_ERROR("fail to set view_definition", K(ret));
|
|
}
|
|
}
|
|
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);
|
|
table_schema.set_progressive_merge_round(1);
|
|
table_schema.set_storage_format_version(3);
|
|
table_schema.set_tablet_id(0);
|
|
|
|
table_schema.set_max_used_column_id(column_id);
|
|
return ret;
|
|
}
|
|
|
|
|
|
} // end namespace share
|
|
} // end namespace oceanbase
|