fix:multivalue delete from table bug, json overlaps search result not correct,add some constraint

This commit is contained in:
obdev 2024-04-28 06:34:49 +00:00 committed by ob-robot
parent ead3e7cb36
commit d8fd236fa0
10 changed files with 60 additions and 36 deletions

View File

@ -13116,7 +13116,7 @@ int ObDDLService::check_is_offline_ddl(ObAlterTableArg &alter_table_arg,
}
if (OB_SUCC(ret) && is_double_table_long_running_ddl(ddl_type)) {
bool has_index_operation = false;
bool has_fts_index = false;
bool has_fts_or_multivalue_index = false;
bool is_adding_constraint = false;
bool is_column_store = false;
uint64_t table_id = alter_table_arg.alter_table_schema_.get_table_id();
@ -13133,19 +13133,19 @@ int ObDDLService::check_is_offline_ddl(ObAlterTableArg &alter_table_arg,
table_id,
has_index_operation))) {
LOG_WARN("check has index operation failed", K(ret));
} else if (OB_FAIL(check_has_fts_index(schema_guard,
} else if (OB_FAIL(check_has_domain_index(schema_guard,
tenant_id,
table_id,
has_fts_index))) {
has_fts_or_multivalue_index))) {
LOG_WARN("check has fts index failed", K(ret));
} else if (OB_FAIL(check_is_adding_constraint(tenant_id, table_id, is_adding_constraint))) {
LOG_WARN("failed to call check_is_adding_constraint", K(ret));
} else if (has_index_operation) {
ret = OB_NOT_SUPPORTED;
LOG_USER_ERROR(OB_NOT_SUPPORTED, "The DDL cannot be run concurrently with creating index.");
} else if (has_fts_index) {
} else if (has_fts_or_multivalue_index) {
ret = OB_NOT_SUPPORTED;
LOG_USER_ERROR(OB_NOT_SUPPORTED, "Run this DDL operation on table with fulltext search index");
LOG_USER_ERROR(OB_NOT_SUPPORTED, "Run this DDL operation on table with fulltext search index or multivalue index.");
} else if (is_adding_constraint) {
ret = OB_NOT_SUPPORTED;
LOG_USER_ERROR(OB_NOT_SUPPORTED, "The DDL cannot be run concurrently with adding constraint.");
@ -13155,7 +13155,7 @@ int ObDDLService::check_is_offline_ddl(ObAlterTableArg &alter_table_arg,
return ret;
}
int ObDDLService::check_has_fts_index(
int ObDDLService::check_has_domain_index(
ObSchemaGetterGuard &schema_guard,
const uint64_t tenant_id,
const uint64_t data_table_id,
@ -14405,18 +14405,18 @@ int ObDDLService::check_alter_partitions(const ObTableSchema &orig_table_schema,
LOG_WARN("split partition in 4.0 not allowed", K(ret), K(tablegroup_id));
LOG_USER_ERROR(OB_OP_NOT_ALLOW, "split partition in 4.0");
}
bool has_fts_index = false;
bool has_fts_or_multivalue_index = false;
const int64_t table_id = orig_table_schema.get_table_id();
if (OB_FAIL(ret)) {
} else if (OB_FAIL(check_has_fts_index(schema_guard,
} else if (OB_FAIL(check_has_domain_index(schema_guard,
tenant_id,
table_id,
has_fts_index))) {
has_fts_or_multivalue_index))) {
LOG_WARN("failed to check if have fts index", K(ret), K(table_id));
} else if (has_fts_index) {
} else if (has_fts_or_multivalue_index) {
ret = OB_NOT_SUPPORTED;
LOG_WARN("alter partition operation on table with fts index not supported", K(ret), K(orig_table_schema));
LOG_USER_ERROR(OB_NOT_SUPPORTED, "alter partition operation on table with fts index");
LOG_WARN("alter partition operation on table with fulltext or multivalue index not supported", K(ret), K(orig_table_schema));
LOG_USER_ERROR(OB_NOT_SUPPORTED, "alter partition operation on table with fulltext or multivalue index");
}
if (OB_FAIL(ret)) {

View File

@ -1285,7 +1285,7 @@ private:
const ObTableSchema &table_schema,
uint64_t &tablet_cnt);
int check_has_fts_index(
int check_has_domain_index(
ObSchemaGetterGuard &schema_guard,
const uint64_t tenant_id,
const uint64_t data_table_id,

View File

@ -341,7 +341,6 @@ int ObDASDomainUtils::generate_multivalue_index_rows(ObIAllocator &allocator,
if (OB_FAIL(get_pure_mutivalue_data(json_str, data, data_len, record_num))) {
LOG_WARN("failed to parse binary.", K(ret), K(json_str));
} else if (record_num == 0) {
ret = OB_ITER_END;
} else if (OB_FAIL(calc_save_rowkey_policy(allocator, das_ctdef, row_projector,
dml_row, record_num, is_save_rowkey))) {
LOG_WARN("failed to calc store policy.", K(ret), K(data_table_rowkey_cnt));
@ -362,13 +361,19 @@ int ObDASDomainUtils::generate_multivalue_index_rows(ObIAllocator &allocator,
}
for(uint64_t j = 0; OB_SUCC(ret) && j < column_num; j++) {
obj_arr[j].set_nop_value();
const ObObjMeta &col_type = das_ctdef.column_types_.at(j);
ObObjMeta col_type = das_ctdef.column_types_.at(j);
const ObAccuracy &col_accuracy = das_ctdef.column_accuracys_.at(j);
int64_t projector_idx = row_projector.at(j);
if (multivalue_idx == projector_idx) {
if (OB_FAIL(obj_arr[j].deserialize(data, data_len, pos))) {
LOG_WARN("failed to deserialize datum.", K(ret), K(json_str));
} else {
if (ob_is_numeric_type(col_type.get_type()) || ob_is_temporal_type(col_type.get_type())) {
col_type.set_collation_level(CS_LEVEL_NUMERIC);
} else {
col_type.set_collation_level(CS_LEVEL_IMPLICIT);
}
obj_arr[j].set_collation_level(col_type.get_collation_level());
obj_arr[j].set_collation_type(col_type.get_collation_type());
obj_arr[j].set_type(col_type.get_type());

View File

@ -49,6 +49,11 @@ int ObExprJsonContains::calc_result_typeN(ObExprResType& type,
type.set_precision(DEFAULT_PRECISION_FOR_BOOL);
type.set_scale(ObAccuracy::DDL_DEFAULT_ACCURACY[ObIntType].scale_);
if (ob_is_string_type(types_stack[1].get_type())) {
types_stack[1].set_calc_type(ObJsonType);
types_stack[1].set_calc_collation_type(CS_TYPE_UTF8MB4_BIN);
}
// set type for json_path
if (OB_SUCC(ret) && param_num == 3) {
if (OB_FAIL(ObJsonExprHelper::is_valid_for_path(types_stack, 2))) {

View File

@ -43,6 +43,16 @@ int ObExprJsonOverlaps::calc_result_type2(ObExprResType &type,
type.set_int32();
type.set_precision(DEFAULT_PRECISION_FOR_BOOL);
type.set_scale(ObAccuracy::DDL_DEFAULT_ACCURACY[ObIntType].scale_);
if (ob_is_string_type(type1.get_type()) && type1.get_collation_type() != CS_TYPE_BINARY) {
type1.set_calc_type(ObJsonType);
type1.set_calc_collation_type(CS_TYPE_UTF8MB4_BIN);
}
if (ob_is_string_type(type2.get_type()) && type2.get_collation_type() != CS_TYPE_BINARY) {
type2.set_calc_type(ObJsonType);
type2.set_calc_collation_type(CS_TYPE_UTF8MB4_BIN);
}
return ret;
}

View File

@ -17390,11 +17390,11 @@ int ObDMLResolver::try_add_join_table_for_fts(const TableItem *left_table, Joine
ret = OB_ERR_UNEXPECTED;
STORAGE_FTS_LOG(WARN, "unexpected null", K(ret));
} else if (!left_table->is_basic_table()) {
if (OB_FAIL(ObTransformUtils::check_table_with_fulltext_recursively(const_cast<TableItem*>(left_table),
if (OB_FAIL(ObTransformUtils::check_table_with_fts_or_multivalue_recursively(const_cast<TableItem*>(left_table),
schema_checker_,
session_info_,
has_table_with_fulltext_index))) {
STORAGE_FTS_LOG(WARN, "fail to check table with fulltext recursively", K(ret));
STORAGE_FTS_LOG(WARN, "fail to check table with fulltext or mutivalue recursively", K(ret));
} else if (has_table_with_fulltext_index) {
ret = OB_NOT_SUPPORTED;
LOG_USER_ERROR(OB_NOT_SUPPORTED, "complex dml operations on table with fulltext index");

View File

@ -4109,8 +4109,8 @@ bool ObSysFunRawExpr::inner_json_expr_same_as(
}
if (OB_ISNULL(r_param_expr)) {
} else if (r_param_expr->is_wrappered_json_extract()) {
r_param_expr = r_param_expr->get_param_expr(0)->get_param_expr(1);
r_column_expr = r_param_expr->get_param_expr(0)->get_param_expr(0);
r_param_expr = r_param_expr->get_param_expr(0)->get_param_expr(1);
} else if (r_param_expr->get_expr_type() == T_FUN_SYS_JSON_EXTRACT) {
r_column_expr = r_param_expr->get_param_expr(0);
r_param_expr = r_param_expr->get_param_expr(1);

View File

@ -10171,15 +10171,15 @@ int ObTransformPreProcess::disable_complex_dml_for_fulltext_index(ObDMLStmt *stm
// do nothing
} else {
for (int64_t i = 0; OB_SUCC(ret) && !has_table_with_fulltext_index && i < tables_to_check.count(); ++i) {
if (OB_FAIL(ObTransformUtils::check_table_with_fulltext_recursively(tables_to_check.at(i),
if (OB_FAIL(ObTransformUtils::check_table_with_fts_or_multivalue_recursively(tables_to_check.at(i),
ctx_->schema_checker_,
ctx_->session_info_,
has_table_with_fulltext_index))) {
LOG_WARN("failed to check table with fulltext recursively", K(ret));
LOG_WARN("failed to check table with fulltext or mutivalue recursively", K(ret));
} else if (has_table_with_fulltext_index) {
ret = OB_NOT_SUPPORTED;
LOG_USER_ERROR(OB_NOT_SUPPORTED, "complex dml operations on table with fulltext index");
LOG_WARN("not supported complex dml operations on table with fulltext index", K(ret));
LOG_USER_ERROR(OB_NOT_SUPPORTED, "complex dml operations on table with fulltext or multivalue index");
LOG_WARN("not supported complex dml operations on table with fulltext or mutivalue index", K(ret));
}
}
}

View File

@ -15359,10 +15359,10 @@ bool ObTransformUtils::is_const_null(ObRawExpr &expr)
return bret;
}
int ObTransformUtils::check_table_with_fulltext_recursively(TableItem *table,
int ObTransformUtils::check_table_with_fts_or_multivalue_recursively(TableItem *table,
ObSchemaChecker *schema_checker,
ObSQLSessionInfo *session_info,
bool &has_fulltext_index)
bool &has_fts_or_multivalue_index)
{
int ret = OB_SUCCESS;
if (OB_ISNULL(table) || OB_ISNULL(schema_checker) || OB_ISNULL(session_info)) {
@ -15374,12 +15374,12 @@ int ObTransformUtils::check_table_with_fulltext_recursively(TableItem *table,
LOG_WARN("unexpected null", K(ret));
} else {
ObIArray<TableItem*> &tables = table->ref_query_->get_table_items();
for (int64_t i = 0; OB_SUCC(ret) && !has_fulltext_index && i < tables.count(); ++i) {
if (SMART_CALL(check_table_with_fulltext_recursively(tables.at(i),
for (int64_t i = 0; OB_SUCC(ret) && !has_fts_or_multivalue_index && i < tables.count(); ++i) {
if (SMART_CALL(check_table_with_fts_or_multivalue_recursively(tables.at(i),
schema_checker,
session_info,
has_fulltext_index))) {
LOG_WARN("failed to check table with fulltext recursively", K(ret));
has_fts_or_multivalue_index))) {
LOG_WARN("failed to check table with fulltext or multivalue recursively", K(ret));
}
}
}
@ -15390,22 +15390,26 @@ int ObTransformUtils::check_table_with_fulltext_recursively(TableItem *table,
table_schema))) {
LOG_WARN("failed to get table schema", K(ret));
} else if (OB_FAIL(table_schema->check_has_fts_index(*schema_checker->get_schema_guard(),
has_fulltext_index))) {
has_fts_or_multivalue_index))) {
LOG_WARN("failed to check has fts index", K(ret));
} else if (has_fts_or_multivalue_index) {
} else if (OB_FAIL(table_schema->check_has_multivalue_index(*schema_checker->get_schema_guard(),
has_fts_or_multivalue_index))) {
LOG_WARN("failed to check has multivalue.", K(ret));
}
} else if (table->is_joined_table()) {
JoinedTable *joined_table = static_cast<JoinedTable*>(table);
if (OB_FAIL(SMART_CALL(check_table_with_fulltext_recursively(joined_table->left_table_,
if (OB_FAIL(SMART_CALL(check_table_with_fts_or_multivalue_recursively(joined_table->left_table_,
schema_checker,
session_info,
has_fulltext_index)))) {
has_fts_or_multivalue_index)))) {
LOG_WARN("failed to check left table", K(ret));
} else if (has_fulltext_index) {
} else if (has_fts_or_multivalue_index) {
// do nothing
} else if (OB_FAIL(SMART_CALL(check_table_with_fulltext_recursively(joined_table->right_table_,
} else if (OB_FAIL(SMART_CALL(check_table_with_fts_or_multivalue_recursively(joined_table->right_table_,
schema_checker,
session_info,
has_fulltext_index)))) {
has_fts_or_multivalue_index)))) {
LOG_WARN("failed to check right table", K(ret));
}
}

View File

@ -1888,10 +1888,10 @@ public:
static bool is_const_null(ObRawExpr &expr);
static bool is_full_group_by(ObSelectStmt& stmt, ObSQLMode mode);
static int check_table_with_fulltext_recursively(TableItem *table,
static int check_table_with_fts_or_multivalue_recursively(TableItem *table,
ObSchemaChecker *schema_checker,
ObSQLSessionInfo *session_info,
bool &has_fulltext_index);
bool &has_fts_or_multivalue_index);
static int add_aggr_winfun_expr(ObSelectStmt *stmt,
ObRawExpr *expr);
static int expand_mview_table(ObTransformerCtx *ctx, ObDMLStmt *upper_stmt, TableItem *rt_mv_table);