fix:complex unique multivalue index not check unique bug
This commit is contained in:
parent
39ffd5cdb4
commit
af40781f9c
@ -5762,6 +5762,14 @@ int ObIJsonBase::to_time(int64_t &value) const
|
||||
int64_t time;
|
||||
|
||||
switch (json_type()) {
|
||||
case ObJsonNodeType::J_INT:
|
||||
case ObJsonNodeType::J_UINT: {
|
||||
int64_t in_val = get_int();
|
||||
if (OB_FAIL(ObTimeConverter::int_to_time(in_val, value))) {
|
||||
LOG_WARN("int_to_date failed", K(ret), K(in_val), K(json_type()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ObJsonNodeType::J_TIME: {
|
||||
ObTime t;
|
||||
if (OB_FAIL(get_obtime(t))) {
|
||||
|
@ -505,14 +505,6 @@ int ObTableLoadService::check_support_direct_load(ObSchemaGetterGuard &schema_gu
|
||||
LOG_WARN("direct-load does not support table has full-text search index", KR(ret));
|
||||
FORWARD_USER_ERROR_MSG(ret, "%sdirect-load does not support table has full-text search index", tmp_prefix);
|
||||
}
|
||||
// check if exists multi-value index
|
||||
else if (OB_FAIL(table_schema->check_has_multivalue_index(schema_guard, has_multivalue_index))) {
|
||||
LOG_WARN("fail to check has multivalue index", K(ret));
|
||||
} else if (has_multivalue_index) {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("direct-load does not support table has multi-value index", KR(ret));
|
||||
FORWARD_USER_ERROR_MSG(ret, "%sdirect-load does not support table has multi-value index", tmp_prefix);
|
||||
}
|
||||
// check if exists generated column
|
||||
else if (OB_UNLIKELY(table_schema->has_generated_column())) {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
|
@ -2070,7 +2070,7 @@ int ObMulValueIndexBuilderUtil::build_and_generate_multivalue_column_raw(
|
||||
ObString expr_def_string;
|
||||
|
||||
bool is_oracle_mode = false;
|
||||
bool is_add_column = false;
|
||||
int is_add_column = 0;
|
||||
if (OB_FAIL(data_schema.check_if_oracle_compat_mode(is_oracle_mode))) {
|
||||
LOG_WARN("check_if_oracle_compat_mode failed", K(ret));
|
||||
} else if (is_oracle_mode) {
|
||||
@ -2079,22 +2079,25 @@ int ObMulValueIndexBuilderUtil::build_and_generate_multivalue_column_raw(
|
||||
}
|
||||
|
||||
int64_t expr_idx = 0;
|
||||
for (; OB_SUCC(ret) && expr_idx < sort_items.count(); ++expr_idx) {
|
||||
ObColumnSortItem& sort_item = sort_items.at(expr_idx);
|
||||
for (size_t i = 0; OB_SUCC(ret) && i < sort_items.count(); ++i) {
|
||||
ObColumnSortItem& sort_item = sort_items.at(i);
|
||||
bool is_multi_value_index = false;
|
||||
if (sort_item.prefix_len_ > 0) {
|
||||
} else if (!sort_item.is_func_index_) {
|
||||
} else if (OB_FAIL(is_multivalue_index_type(sort_item.column_name_, is_multi_value_index))) {
|
||||
LOG_WARN("failed to calc index type", K(ret), K(sort_item.column_name_));
|
||||
} else if (is_multi_value_index) {
|
||||
is_add_column = true;
|
||||
is_add_column++;
|
||||
expr_idx = i;
|
||||
expr_def_string = sort_item.column_name_;
|
||||
// found multivalue index define, break
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret) && expr_def_string.length() > 0) {
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (lib::is_mysql_mode() && is_add_column > 1) {
|
||||
ret = OB_NOT_MULTIVALUE_SUPPORT;
|
||||
LOG_USER_ERROR(OB_NOT_MULTIVALUE_SUPPORT, "more than one multi-valued key part per index");
|
||||
} else if (expr_def_string.length() > 0) {
|
||||
ObColumnSortItem sort_item = sort_items.at(expr_idx);
|
||||
const ObString &index_expr_def = expr_def_string;
|
||||
ObRawExprFactory expr_factory(allocator);
|
||||
@ -2536,9 +2539,8 @@ int ObMulValueIndexBuilderUtil::set_multivalue_index_table_columns(
|
||||
common::ObOrderType order_type;
|
||||
const ObColumnSchemaV2 *mvi_array_column = nullptr;
|
||||
int32_t multi_column_cnt = 0;
|
||||
// 2 means : multivalue column, multivalue array column
|
||||
bool is_complex_index = arg.index_columns_.count() > 2;
|
||||
bool is_real_unique = index_schema.is_unique_index() && !is_complex_index;
|
||||
ObArray<const ObColumnSchemaV2 *> tmp_cols;
|
||||
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < arg.index_columns_.count(); ++i) {
|
||||
const ObColumnSchemaV2 *mvi_column = nullptr;
|
||||
const ObColumnSortItem &mvi_col_item = arg.index_columns_.at(i);
|
||||
@ -2551,7 +2553,6 @@ int ObMulValueIndexBuilderUtil::set_multivalue_index_table_columns(
|
||||
"database_id", data_schema.get_database_id(),
|
||||
"table_name", data_schema.get_table_name(),
|
||||
"column name", mvi_col_item.column_name_, K(ret));
|
||||
} else if (mvi_column->is_rowkey_column()) {
|
||||
} else if (!mvi_column->is_multivalue_generated_array_column()) {
|
||||
if (OB_FAIL(ObIndexBuilderUtil::add_column(mvi_column,
|
||||
true/*is_index_column*/,
|
||||
@ -2569,6 +2570,8 @@ int ObMulValueIndexBuilderUtil::set_multivalue_index_table_columns(
|
||||
ret = OB_NOT_MULTIVALUE_SUPPORT;
|
||||
LOG_USER_ERROR(OB_NOT_MULTIVALUE_SUPPORT, "more than one multi-valued key part per index");
|
||||
}
|
||||
} else if (mvi_column->is_rowkey_column() && OB_FAIL(tmp_cols.push_back(mvi_column))) {
|
||||
LOG_WARN("failed to tmp save rowkey column", K(ret));
|
||||
}
|
||||
} else if (mvi_column->is_multivalue_generated_array_column()) {
|
||||
mvi_array_column = mvi_column;
|
||||
@ -2579,13 +2582,13 @@ int ObMulValueIndexBuilderUtil::set_multivalue_index_table_columns(
|
||||
} else if (OB_ISNULL(mvi_array_column)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("failed to get multivalue array column", K(ret));
|
||||
} else if (is_real_unique) {
|
||||
} else {
|
||||
// json-array column is not index coumn, not rowkey column
|
||||
index_schema.set_rowkey_column_num(row_desc.get_column_num());
|
||||
index_schema.set_index_column_num(row_desc.get_column_num());
|
||||
}
|
||||
|
||||
bool is_rowkey = !is_real_unique;
|
||||
bool is_rowkey = (!index_schema.is_unique_index());
|
||||
bool is_index_column = is_rowkey;
|
||||
|
||||
const ObColumnSchemaV2 *rowkey_column = nullptr;
|
||||
@ -2598,15 +2601,24 @@ int ObMulValueIndexBuilderUtil::set_multivalue_index_table_columns(
|
||||
ret = OB_ERR_BAD_FIELD_ERROR;
|
||||
LOG_WARN("get_column_schema failed", "table_id", data_schema.get_table_id(),
|
||||
K(column_id), K(ret));
|
||||
} else if (OB_FAIL(ObIndexBuilderUtil::add_column(rowkey_column,
|
||||
is_index_column/*is_index_column*/,
|
||||
is_rowkey /*is_rowkey*/,
|
||||
rowkey_column->get_order_in_rowkey(),
|
||||
row_desc,
|
||||
index_schema,
|
||||
false /*is_hidden*/,
|
||||
true /*is_specified_storing_col*/))) {
|
||||
LOG_WARN("add column failed", K(ret));
|
||||
} else {
|
||||
bool is_found = false;
|
||||
for (size_t i = 0; !is_found && i < tmp_cols.count(); ++i) {
|
||||
if (tmp_cols.at(i) == rowkey_column) {
|
||||
is_found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_found && OB_FAIL(ObIndexBuilderUtil::add_column(rowkey_column,
|
||||
is_index_column/*is_index_column*/,
|
||||
is_rowkey /*is_rowkey*/,
|
||||
rowkey_column->get_order_in_rowkey(),
|
||||
row_desc,
|
||||
index_schema,
|
||||
false /*is_hidden*/,
|
||||
true /*is_specified_storing_col*/))) {
|
||||
LOG_WARN("add column failed", K(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2628,7 +2640,7 @@ int ObMulValueIndexBuilderUtil::set_multivalue_index_table_columns(
|
||||
order_type, K(row_desc), K(ret));
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret) && !is_real_unique) {
|
||||
if (OB_SUCC(ret) && !index_schema.is_unique_index()) {
|
||||
// json-array column is not index coumn, not rowkey column
|
||||
index_schema.set_rowkey_column_num(row_desc.get_column_num() );
|
||||
index_schema.set_index_column_num(row_desc.get_column_num());
|
||||
|
@ -416,6 +416,7 @@ int ObDASDomainUtils::generate_multivalue_index_rows(ObIAllocator &allocator,
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
bool is_save_rowkey = true;
|
||||
const int64_t index_rowkey_cnt = das_ctdef.table_param_.get_data_table().get_rowkey_column_num();
|
||||
bool is_unique_index = das_ctdef.table_param_.get_data_table().get_index_type() == ObIndexType::INDEX_TYPE_UNIQUE_MULTIVALUE_LOCAL;
|
||||
const int64_t data_table_rowkey_cnt = das_ctdef.table_param_.get_data_table().get_data_table_rowkey_column_num();
|
||||
const char* data = nullptr;
|
||||
@ -429,15 +430,14 @@ int ObDASDomainUtils::generate_multivalue_index_rows(ObIAllocator &allocator,
|
||||
uint64_t rowkey_column_end = column_num - 1;
|
||||
|
||||
void *rows_buf = nullptr;
|
||||
|
||||
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 && (is_unique_index && rowkey_column_start == 1)) {
|
||||
} else if (record_num == 0 && is_unique_index) {
|
||||
} 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));
|
||||
} else {
|
||||
uint32_t real_record_num = record_num;
|
||||
if (record_num == 0 && !(is_unique_index && rowkey_column_start == 1)) {
|
||||
if (record_num == 0 && !is_unique_index) {
|
||||
real_record_num = 1;
|
||||
}
|
||||
|
||||
|
@ -1925,11 +1925,11 @@ int ObRawExprPrinter::print_json_value(ObSysFunRawExpr *expr)
|
||||
int64_t type = static_cast<ObConstRawExpr*>(expr->get_param_expr(JsnValueClause::JSN_VAL_EMPTY))->get_value().get_int();
|
||||
switch (type) {
|
||||
case JsnValueType::JSN_VALUE_ERROR:
|
||||
DATA_PRINTF(" error");
|
||||
DATA_PRINTF(" error on empty");
|
||||
break;
|
||||
case JsnValueType::JSN_VALUE_NULL:
|
||||
if (lib::is_mysql_mode() || type == 1) {
|
||||
DATA_PRINTF(" null");
|
||||
DATA_PRINTF(" null on empty");
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1938,15 +1938,13 @@ int ObRawExprPrinter::print_json_value(ObSysFunRawExpr *expr)
|
||||
case JsnValueType::JSN_VALUE_DEFAULT:
|
||||
DATA_PRINTF(" default ");
|
||||
PRINT_EXPR(expr->get_param_expr(JSN_VAL_EMPTY_DEF));
|
||||
DATA_PRINTF(" on empty");
|
||||
break;
|
||||
default:
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid type value.", K(type));
|
||||
break;
|
||||
}
|
||||
if (OB_SUCC(ret) && (lib::is_mysql_mode() || type < JsnValueType::JSN_VALUE_IMPLICIT)) {
|
||||
DATA_PRINTF(" on empty");
|
||||
}
|
||||
}
|
||||
}
|
||||
// print error type type 7, default value 8.
|
||||
|
@ -6144,8 +6144,6 @@ int ObAlterTableResolver::resolve_change_column(const ParseNode &node)
|
||||
LOG_WARN("can't set primary key nullable", K(ret));
|
||||
} else if (OB_FAIL(check_alter_geo_column_allowed(alter_column_schema, *origin_col_schema))) {
|
||||
LOG_WARN("modify geo column not allowed", K(ret));
|
||||
} else if (OB_FAIL(check_alter_multivalue_depend_column_allowed(alter_column_schema, *origin_col_schema))) {
|
||||
LOG_WARN("modify geo column not allowed", K(ret));
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
@ -6490,8 +6488,6 @@ int ObAlterTableResolver::resolve_modify_column(const ParseNode &node,
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "Modify geometry srid");
|
||||
LOG_WARN("can't not modify geometry srid", K(ret),
|
||||
K(origin_col_schema->get_srid()), K(alter_column_schema.get_srid()));
|
||||
} else if (OB_FAIL(check_alter_multivalue_depend_column_allowed(alter_column_schema, *origin_col_schema))) {
|
||||
LOG_WARN("modify geo column not allowed", K(ret));
|
||||
} else if (origin_col_schema->get_data_type() == ObRoaringBitmapType
|
||||
&& alter_column_schema.get_data_type() != ObRoaringBitmapType
|
||||
&& !ob_is_string_type(alter_column_schema.get_data_type())) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user