Fix functional index bugs

This commit is contained in:
obdev
2023-05-08 03:41:56 +00:00
committed by ob-robot
parent 5671bf1857
commit c8b3ff602c
2 changed files with 116 additions and 95 deletions

View File

@ -739,11 +739,15 @@ int ObIndexBuilderUtil::adjust_ordinary_index_column_args(
ObArenaAllocator allocator(ObModIds::OB_SQL_EXPR);
ObRawExprFactory expr_factory(allocator);
SMART_VAR(sql::ObSQLSessionInfo, session) {
SMART_VAR(sql::ObExecContext, exec_ctx, allocator) {
uint64_t tenant_id = data_schema.get_tenant_id();
const ObTenantSchema *tenant_schema = NULL;
ObSchemaGetterGuard guard;
ObSchemaChecker schema_checker;
ObRawExpr *expr = NULL;
LinkExecCtxGuard link_guard(session, exec_ctx);
exec_ctx.set_my_session(&session);
exec_ctx.set_is_ps_prepare_stage(false);
if (OB_FAIL(session.init(0 /*default session id*/,
0 /*default proxy id*/,
&allocator))) {
@ -840,6 +844,7 @@ int ObIndexBuilderUtil::adjust_ordinary_index_column_args(
}
}
}
}
if (OB_SUCC(ret)) {
ObString tmp_name = new_sort_item.column_name_;
//Keep the memory lifetime of column_name consistent with index_arg

View File

@ -1364,9 +1364,25 @@ int ObAlterTableResolver::resolve_add_index(const ParseNode &node)
ObCreateIndexArg &index_arg = create_index_stmt.get_create_index_arg();
if (is_index_part_specified) {
ObTableSchema &index_schema = index_arg.index_schema_;
if (OB_FAIL(share::ObIndexBuilderUtil::set_index_table_columns(
index_arg, *table_schema_, index_schema, false))) {
SMART_VAR(ObCreateIndexArg, my_create_index_arg) {
SMART_VAR(ObTableSchema, new_table_schema) {
ObArray<ObColumnSchemaV2 *> gen_columns;
if (OB_FAIL(new_table_schema.assign(*table_schema_))) {
LOG_WARN("fail to assign schema", K(ret));
} else if (OB_FAIL(my_create_index_arg.assign(index_arg))) {
LOG_WARN("fail to assign index arg", K(ret));
} else if (OB_FAIL(share::ObIndexBuilderUtil::adjust_expr_index_args(
my_create_index_arg, new_table_schema, *allocator_, gen_columns))) {
LOG_WARN("fail to adjust expr index args", K(ret));
} else if (OB_FAIL(share::ObIndexBuilderUtil::set_index_table_columns(
my_create_index_arg, new_table_schema, my_create_index_arg.index_schema_, false))) {
LOG_WARN("fail to set index table columns", K(ret));
} else if (OB_FAIL(index_schema.assign(my_create_index_arg.index_schema_))){
LOG_WARN("fail to assign schema", K(ret));
}
}
}
if (OB_FAIL(ret)) {
} else if (OB_FAIL(resolve_index_partition_node(index_partition_option->children_[0], &create_index_stmt))) {
LOG_WARN("fail to resolve partition option", K(ret));
} else {