fix bug, not allow to create cg in shared storag mode

This commit is contained in:
AnimationFan 2024-11-08 06:48:09 +00:00 committed by ob-robot
parent 6ef1d1d4ba
commit cb5fb02205
3 changed files with 1 additions and 93 deletions

View File

@ -3387,95 +3387,6 @@ int ObCreateTableResolver::resolve_table_charset_info(const ParseNode *node) {
return ret;
}
/*
* only when default columns store is column_store
* have to add each column group
*/
int ObCreateTableResolver::resolve_column_group(const ParseNode *cg_node)
{
int ret = OB_SUCCESS;
ObCreateTableStmt *create_table_stmt = static_cast<ObCreateTableStmt *>(stmt_);
ObArray<uint64_t> column_ids; // not include virtual column
uint64_t compat_version = 0;
ObTableStoreType table_store_type = OB_TABLE_STORE_INVALID;
if (OB_ISNULL(create_table_stmt)) {
ret = OB_ERR_UNEXPECTED;
SQL_RESV_LOG(WARN, "create_table_stmt should not be null", KR(ret));
} else {
ObTableSchema &table_schema = create_table_stmt->get_create_table_arg().schema_;
const uint64_t tenant_id = table_schema.get_tenant_id();
const int64_t column_cnt = table_schema.get_column_count();
if (OB_FAIL(column_ids.reserve(column_cnt))) {
LOG_WARN("fail to reserve", KR(ret), K(column_cnt));
} else if (OB_FAIL(GET_MIN_DATA_VERSION(tenant_id, compat_version))) {
LOG_WARN("fail to get min data version", KR(ret), K(tenant_id));
} else if (!(compat_version >= DATA_VERSION_4_3_0_0)) {
if (OB_NOT_NULL(cg_node) && (T_COLUMN_GROUP == cg_node->type_)) {
ret = OB_NOT_SUPPORTED;
LOG_WARN("can't support column store if version less than 4_1_0_0", KR(ret), K(compat_version));
}
} else {
table_schema.set_column_store(true);
bool is_each_cg_exist = false;
if (OB_NOT_NULL(cg_node)) {
if (OB_FAIL(parse_column_group(cg_node, table_schema, table_schema))) {
LOG_WARN("fail to parse column group", K(ret));
}
}
/* build column group when cg node is null && tenant cg valid*/
ObTenantConfigGuard tenant_config(TENANT_CONF(session_info_->get_effective_tenant_id()));
if (OB_FAIL(ret)) {
} else if ( OB_LIKELY(tenant_config.is_valid()) && nullptr == cg_node) {
/* force to build each cg*/
if (!ObSchemaUtils::can_add_column_group(table_schema)) {
} else if (OB_FAIL(ObTableStoreFormat::find_table_store_type(
tenant_config->default_table_store_format.get_value_string(),
table_store_type))) {
LOG_WARN("fail to get table store format", K(ret), K(table_store_type));
} else if (ObTableStoreFormat::is_with_column(table_store_type)) {
/* for default is column store, must add each column group*/
if (OB_FAIL(ObSchemaUtils::build_add_each_column_group(table_schema, table_schema))) {
LOG_WARN("fail to add each column group", K(ret));
}
}
/* force to build all cg*/
ObColumnGroupSchema all_cg;
if (OB_FAIL(ret)) {
} else if (!ObSchemaUtils::can_add_column_group(table_schema)) {
} else if (ObTableStoreFormat::is_row_with_column_store(table_store_type)) {
if (OB_FAIL(ObSchemaUtils::build_all_column_group(table_schema, table_schema.get_tenant_id(),
table_schema.get_max_used_column_group_id() + 1, all_cg))) {
LOG_WARN("fail to add all column group", K(ret));
} else if (OB_FAIL(table_schema.add_column_group(all_cg))) {
LOG_WARN("fail to build all column group", K(ret));
}
}
}
// add default_type column_group, build a empty and then use alter_deafult_cg
if (OB_SUCC(ret)) {
ObColumnGroupSchema tmp_cg;
column_ids.reuse();
if (OB_FAIL(build_column_group(table_schema, ObColumnGroupType::DEFAULT_COLUMN_GROUP,
OB_DEFAULT_COLUMN_GROUP_NAME, column_ids, DEFAULT_TYPE_COLUMN_GROUP_ID, tmp_cg))) {
LOG_WARN("fail to build default type column_group", KR(ret), K(table_store_type),
"table_id", table_schema.get_table_id());
} else if (OB_FAIL(table_schema.add_column_group(tmp_cg))) {
LOG_WARN("fail to add default column group", KR(ret), "table_id", table_schema.get_table_id());
} else if (OB_FAIL(ObSchemaUtils::alter_rowkey_column_group(table_schema))) {
LOG_WARN("fail to adjust rowkey column group when add column group", K(ret));
} else if (OB_FAIL(ObSchemaUtils::alter_default_column_group(table_schema))) {
LOG_WARN("fail to adjust default column group", K(ret));
}
}
}
}
return ret;
}
int ObCreateTableResolver::resolve_auto_partition(const ParseNode *partition_node)
{
int ret = OB_SUCCESS;

View File

@ -133,11 +133,8 @@ private:
int check_external_table_generated_partition_column_sanity(ObTableSchema &table_schema, ObRawExpr *dependant_expr, ObIArray<int64_t> &external_part_idx);
typedef common::hash::ObPlacementHashSet<uint64_t, common::OB_MAX_USER_DEFINED_COLUMNS_COUNT> VPColumnIdHashSet;
uint64_t gen_column_group_id();
int resolve_column_group(const ParseNode *cg_node);
int add_inner_index_for_heap_gtt();
int check_max_row_data_length(const ObTableSchema &table_schema);
int create_default_partition_for_table(ObTableSchema &table_schema);
int set_default_micro_index_clustered_(share::schema::ObTableSchema &table_schema);

View File

@ -46,7 +46,7 @@ protected:
int resolve_column_group_helper(const ParseNode *cg_node, ObTableSchema &table_schema);
// check this type of table_schema should build column_group or not
uint64_t gen_column_group_id();
int resolve_column_group(const ParseNode *cg_node);
virtual int resolve_column_group(const ParseNode *cg_node) final;
protected:
uint64_t cur_column_group_id_;
};