提交 616d4b62 编写于 作者: O obdev 提交者: ob-robot

fix:multivalue index lookup bug, create multivalue index with pk column

上级 814ff31f
...@@ -2161,6 +2161,7 @@ int ObMulValueIndexBuilderUtil::generate_multivalue_column( ...@@ -2161,6 +2161,7 @@ int ObMulValueIndexBuilderUtil::generate_multivalue_column(
} else if (old_gen_col != NULL) { } else if (old_gen_col != NULL) {
//got it //got it
gen_col = old_gen_col; gen_col = old_gen_col;
gen_budy_col = data_schema.get_column_schema(gen_col->get_column_id());
} else { } else {
//need to add new generated column //need to add new generated column
ObObj default_value; ObObj default_value;
...@@ -2387,6 +2388,7 @@ int ObMulValueIndexBuilderUtil::set_multivalue_index_table_columns( ...@@ -2387,6 +2388,7 @@ int ObMulValueIndexBuilderUtil::set_multivalue_index_table_columns(
"database_id", data_schema.get_database_id(), "database_id", data_schema.get_database_id(),
"table_name", data_schema.get_table_name(), "table_name", data_schema.get_table_name(),
"column name", mvi_col_item.column_name_, K(ret)); "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()) { } else if (!mvi_column->is_multivalue_generated_array_column()) {
if (OB_FAIL(ObIndexBuilderUtil::add_column(mvi_column, if (OB_FAIL(ObIndexBuilderUtil::add_column(mvi_column,
true/*is_index_column*/, true/*is_index_column*/,
......
...@@ -831,6 +831,8 @@ int ObMulValueIndexLookupOp::save_rowkeys() ...@@ -831,6 +831,8 @@ int ObMulValueIndexLookupOp::save_rowkeys()
if (OB_FAIL(sorter_.do_sort(true))) { if (OB_FAIL(sorter_.do_sort(true))) {
LOG_WARN("do rowkey sort failed", K(ret)); LOG_WARN("do rowkey sort failed", K(ret));
} else {
lookup_rowkey_cnt_ = 0;
} }
for (int64_t i = 0; OB_SUCC(ret) && i < default_row_batch_cnt; ++i) { for (int64_t i = 0; OB_SUCC(ret) && i < default_row_batch_cnt; ++i) {
...@@ -859,6 +861,7 @@ int ObMulValueIndexLookupOp::save_rowkeys() ...@@ -859,6 +861,7 @@ int ObMulValueIndexLookupOp::save_rowkeys()
LOG_WARN("store lookup key range failed", K(ret), K(scan_param_)); LOG_WARN("store lookup key range failed", K(ret), K(scan_param_));
} }
last_rowkey_ = *idx_row; last_rowkey_ = *idx_row;
++lookup_rowkey_cnt_;
LOG_DEBUG("build data table range", K(ret), K(*idx_row), K(lookup_range), K(scan_param_.key_ranges_.count())); LOG_DEBUG("build data table range", K(ret), K(*idx_row), K(lookup_range), K(scan_param_.key_ranges_.count()));
} }
} }
......
...@@ -261,6 +261,14 @@ int ObExprJsonQuery::eval_json_query(const ObExpr &expr, ObEvalCtx &ctx, ObDatum ...@@ -261,6 +261,14 @@ int ObExprJsonQuery::eval_json_query(const ObExpr &expr, ObEvalCtx &ctx, ObDatum
} else if (is_null_result) { } else if (is_null_result) {
// ToDo: need check is_multivalue? // ToDo: need check is_multivalue?
res.set_null(); res.set_null();
if (is_multivalue &&
OB_FAIL(set_multivalue_result(ctx, temp_allocator, nullptr, expr,
param_ctx->json_param_.error_type_,
in_coll_type, dst_coll_type,
param_ctx->json_param_.error_val_,
param_ctx->json_param_.accuracy_, cast_param, res))) {
LOG_WARN("multi value result set fail", K(ret));
}
} else if (param_ctx->json_param_.on_mismatch_[0] == JSN_QUERY_MISMATCH_DOT } else if (param_ctx->json_param_.on_mismatch_[0] == JSN_QUERY_MISMATCH_DOT
&& hits.size() == 1 && hits.size() == 1
&& param_ctx->json_param_.dst_type_ != ObJsonType) { // dot notation && param_ctx->json_param_.dst_type_ != ObJsonType) { // dot notation
...@@ -274,7 +282,6 @@ int ObExprJsonQuery::eval_json_query(const ObExpr &expr, ObEvalCtx &ctx, ObDatum ...@@ -274,7 +282,6 @@ int ObExprJsonQuery::eval_json_query(const ObExpr &expr, ObEvalCtx &ctx, ObDatum
} else if (OB_FAIL(ObJsonUtil::set_lob_datum(&temp_allocator, expr, ctx, param_ctx->json_param_.dst_type_, 0, res))) { } else if (OB_FAIL(ObJsonUtil::set_lob_datum(&temp_allocator, expr, ctx, param_ctx->json_param_.dst_type_, 0, res))) {
LOG_WARN("fail to set lob datum from string val", K(ret)); LOG_WARN("fail to set lob datum from string val", K(ret));
} }
// ToDo: need set_multivalue_result?
} else if (use_wrapper == 1) { } else if (use_wrapper == 1) {
size_t hit_size = hits.size(); size_t hit_size = hits.size();
ObJsonArray j_arr_res(&temp_allocator); ObJsonArray j_arr_res(&temp_allocator);
...@@ -477,6 +484,7 @@ int ObExprJsonQuery::set_multivalue_result(ObEvalCtx& ctx, ...@@ -477,6 +484,7 @@ int ObExprJsonQuery::set_multivalue_result(ObEvalCtx& ctx,
ObObj tmp_obj; ObObj tmp_obj;
int64_t pos = str_buff.length(); int64_t pos = str_buff.length();
tmp_obj.set_collation_type(dst_collation); tmp_obj.set_collation_type(dst_collation);
tmp_obj.set_type(dest_type);
if (ob_is_numeric_type(dest_type) || ob_is_temporal_type(dest_type)) { if (ob_is_numeric_type(dest_type) || ob_is_temporal_type(dest_type)) {
tmp_obj.set_collation_level(CS_LEVEL_NUMERIC); tmp_obj.set_collation_level(CS_LEVEL_NUMERIC);
} else { } else {
...@@ -523,6 +531,7 @@ int ObExprJsonQuery::set_multivalue_result(ObEvalCtx& ctx, ...@@ -523,6 +531,7 @@ int ObExprJsonQuery::set_multivalue_result(ObEvalCtx& ctx,
ObObj tmp_obj; ObObj tmp_obj;
int64_t pos = str_buff.length(); int64_t pos = str_buff.length();
tmp_obj.set_collation_type(dst_collation); tmp_obj.set_collation_type(dst_collation);
tmp_obj.set_type(dest_type);
if (ob_is_numeric_type(dest_type) || ob_is_temporal_type(dest_type)) { if (ob_is_numeric_type(dest_type) || ob_is_temporal_type(dest_type)) {
tmp_obj.set_collation_level(CS_LEVEL_NUMERIC); tmp_obj.set_collation_level(CS_LEVEL_NUMERIC);
} else { } else {
......
...@@ -1512,10 +1512,14 @@ int ObJsonUtil::cast_json_scalar_to_sql_obj(common::ObIAllocator *allocator, ...@@ -1512,10 +1512,14 @@ int ObJsonUtil::cast_json_scalar_to_sql_obj(common::ObIAllocator *allocator,
uint8_t is_type_mismatch = false; uint8_t is_type_mismatch = false;
if (OB_FAIL(cast_to_res(allocator, ctx, j_base, accuracy, cast_param, res_datum, is_type_mismatch))) { if (OB_FAIL(cast_to_res(allocator, ctx, j_base, accuracy, cast_param, res_datum, is_type_mismatch))) {
LOG_WARN("fail to cast.", K(ret)); LOG_WARN("fail to cast.", K(ret));
} } else {
res_obj.set_type(obj_type);
res_obj.set_collation_type(collation);
res_datum.to_obj(res_obj, res_obj.meta_); res_datum.to_obj(res_obj, res_obj.meta_);
res_obj.set_collation_type(collation); res_obj.set_collation_type(collation);
} }
}
return ret; return ret;
} }
......
...@@ -3992,6 +3992,37 @@ int ObQueryRange::init_domain_key_part(const ObRawExpr *expr, ObKeyPart *&out_k ...@@ -3992,6 +3992,37 @@ int ObQueryRange::init_domain_key_part(const ObRawExpr *expr, ObKeyPart *&out_k
return ret; return ret;
} }
int ObQueryRange::set_normal_key_true_or_false(ObKeyPart *&out_key_part, bool is_always_true)
{
int ret = OB_SUCCESS;
bool is_create_key_part = out_key_part == nullptr;
if (is_create_key_part && OB_FAIL(alloc_full_key_part(out_key_part))) {
LOG_WARN("create full key part failed", K(ret));
} else if (!is_create_key_part && OB_FAIL(out_key_part->create_normal_key())) {
LOG_WARN("create normal key failed", K(ret));
} else {
out_key_part->normal_keypart_->include_start_ = false;
out_key_part->normal_keypart_->include_end_ = false;
out_key_part->normal_keypart_->always_true_ = is_always_true;
out_key_part->normal_keypart_->always_false_ = !is_always_true;
if (is_always_true) {
out_key_part->normal_keypart_->start_.set_min_value();
out_key_part->normal_keypart_->end_.set_max_value();
} else {
out_key_part->normal_keypart_->start_.set_max_value();
out_key_part->normal_keypart_->end_.set_min_value();
}
out_key_part->id_ = table_graph_.key_part_head_->id_;
out_key_part->pos_ = table_graph_.key_part_head_->pos_;
}
return ret;
}
int ObQueryRange::get_member_of_keyparts(const common::ObObj &const_param, ObKeyPart *&out_key_part, const ObDataTypeCastParams &dtc_params) int ObQueryRange::get_member_of_keyparts(const common::ObObj &const_param, ObKeyPart *&out_key_part, const ObDataTypeCastParams &dtc_params)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
...@@ -4004,10 +4035,11 @@ int ObQueryRange::get_member_of_keyparts(const common::ObObj &const_param, ObKey ...@@ -4004,10 +4035,11 @@ int ObQueryRange::get_member_of_keyparts(const common::ObObj &const_param, ObKey
if (OB_FAIL(ObKeyPart::try_cast_value(dtc_params, allocator_, out_key_part->pos_, cast_obj, cmp))) { if (OB_FAIL(ObKeyPart::try_cast_value(dtc_params, allocator_, out_key_part->pos_, cast_obj, cmp))) {
LOG_WARN("failed to try cast value type", K(ret)); LOG_WARN("failed to try cast value type", K(ret));
} else if (cmp != 0) { } else if (cmp != 0) {
if (OB_NOT_NULL(query_range_ctx_)) { if (OB_FAIL(set_normal_key_true_or_false(out_key_part, true))) {
LOG_WARN("failed set normal key", K(ret));
} else if (OB_NOT_NULL(query_range_ctx_)) {
query_range_ctx_->cur_expr_is_precise_ = false; query_range_ctx_->cur_expr_is_precise_ = false;
} }
GET_ALWAYS_TRUE_OR_FALSE(true, out_key_part);
} else if (OB_FAIL(get_domain_equal_keypart(cast_obj, cast_obj, *out_key_part))) { } else if (OB_FAIL(get_domain_equal_keypart(cast_obj, cast_obj, *out_key_part))) {
LOG_WARN("get normal cmp keypart failed", K(ret)); LOG_WARN("get normal cmp keypart failed", K(ret));
} }
......
...@@ -885,6 +885,7 @@ private: ...@@ -885,6 +885,7 @@ private:
int connect_and_or_domain_keyparts(ObIArray<ObKeyPart*> &key_parts, ObKeyPart *&out_key_part, int connect_and_or_domain_keyparts(ObIArray<ObKeyPart*> &key_parts, ObKeyPart *&out_key_part,
ObExecContext *exec_ctx, const ObDataTypeCastParams &dtc_params, ObExecContext *exec_ctx, const ObDataTypeCastParams &dtc_params,
bool is_and_op); bool is_and_op);
int set_normal_key_true_or_false(ObKeyPart *&out_key_part, bool is_always_true);
int get_member_of_keyparts(const common::ObObj &const_param, ObKeyPart *&out_key_part, const ObDataTypeCastParams &dtc_params); int get_member_of_keyparts(const common::ObObj &const_param, ObKeyPart *&out_key_part, const ObDataTypeCastParams &dtc_params);
int get_contain_or_overlaps_keyparts(const common::ObObj &const_param, const common::ObDomainOpType op_type, int get_contain_or_overlaps_keyparts(const common::ObObj &const_param, const common::ObDomainOpType op_type,
ObIArray<ObKeyPart*> &key_parts, ObKeyPart *&out_key_part, ObIArray<ObKeyPart*> &key_parts, ObKeyPart *&out_key_part,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册