fix_multivalue index bug
This commit is contained in:
@ -2117,7 +2117,7 @@ int ObMulValueIndexBuilderUtil::build_and_generate_multivalue_column(
|
|||||||
LOG_WARN("multivalue generated expr should be function, not column ref.", K(ret));
|
LOG_WARN("multivalue generated expr should be function, not column ref.", K(ret));
|
||||||
} else {
|
} else {
|
||||||
//real index expr, so generate hidden generated column in data table schema
|
//real index expr, so generate hidden generated column in data table schema
|
||||||
if (OB_FAIL(generate_multivalue_column(*expr, table_schema, gen_col, budy_col, schema_checker->get_schema_guard()))) {
|
if (OB_FAIL(generate_multivalue_column(*expr, table_schema, schema_checker->get_schema_guard(), gen_col, budy_col))) {
|
||||||
LOG_WARN("generate ordinary generated column failed", K(ret));
|
LOG_WARN("generate ordinary generated column failed", K(ret));
|
||||||
} else if (OB_FAIL(ObRawExprUtils::check_generated_column_expr_str(
|
} else if (OB_FAIL(ObRawExprUtils::check_generated_column_expr_str(
|
||||||
gen_col->get_cur_default_value().get_string(), session_info, table_schema))) {
|
gen_col->get_cur_default_value().get_string(), session_info, table_schema))) {
|
||||||
@ -2132,11 +2132,11 @@ int ObMulValueIndexBuilderUtil::build_and_generate_multivalue_column(
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ObMulValueIndexBuilderUtil::generate_multivalue_column(
|
int ObMulValueIndexBuilderUtil::generate_multivalue_column(
|
||||||
ObRawExpr &expr,
|
sql::ObRawExpr &expr,
|
||||||
ObTableSchema &data_schema,
|
ObTableSchema &data_schema,
|
||||||
|
ObSchemaGetterGuard *schema_guard,
|
||||||
ObColumnSchemaV2 *&gen_col,
|
ObColumnSchemaV2 *&gen_col,
|
||||||
ObColumnSchemaV2 *&gen_budy_col,
|
ObColumnSchemaV2 *&gen_budy_col)
|
||||||
ObSchemaGetterGuard *schema_guard)
|
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
ObColumnSchemaV2 multival_col;
|
ObColumnSchemaV2 multival_col;
|
||||||
|
|||||||
@ -205,11 +205,11 @@ public:
|
|||||||
ObColumnSchemaV2 *&gen_col,
|
ObColumnSchemaV2 *&gen_col,
|
||||||
ObColumnSchemaV2 *&budy_col);
|
ObColumnSchemaV2 *&budy_col);
|
||||||
static int generate_multivalue_column(
|
static int generate_multivalue_column(
|
||||||
sql::ObRawExpr &expr,
|
sql::ObRawExpr &expr,
|
||||||
ObTableSchema &data_schema,
|
ObTableSchema &data_schema,
|
||||||
ObColumnSchemaV2 *&gen_col,
|
ObSchemaGetterGuard *schema_guard,
|
||||||
ObColumnSchemaV2 *&budy_col,
|
ObColumnSchemaV2 *&gen_col,
|
||||||
ObSchemaGetterGuard *schema_guard);
|
ObColumnSchemaV2 *&gen_budy_col);
|
||||||
static int inner_adjust_multivalue_arg(
|
static int inner_adjust_multivalue_arg(
|
||||||
obrpc::ObCreateIndexArg &index_arg,
|
obrpc::ObCreateIndexArg &index_arg,
|
||||||
const ObTableSchema &data_schema,
|
const ObTableSchema &data_schema,
|
||||||
|
|||||||
@ -698,7 +698,10 @@ int ObMulValueIndexLookupOp::save_doc_id_and_rowkey()
|
|||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
|
|
||||||
|
// index_column_cnt : |multivalue column| rowkey column | doc-id column |
|
||||||
int64_t index_column_cnt = index_ctdef_->result_output_.count();
|
int64_t index_column_cnt = index_ctdef_->result_output_.count();
|
||||||
|
const storage::ObTableReadInfo& read_info = lookup_ctdef_->table_param_.get_read_info();
|
||||||
|
int64_t main_rowkey_column_cnt = read_info.get_schema_rowkey_count();
|
||||||
ObObj *obj_ptr = nullptr;
|
ObObj *obj_ptr = nullptr;
|
||||||
|
|
||||||
ObIAllocator &allocator = lookup_memctx_->get_arena_allocator();
|
ObIAllocator &allocator = lookup_memctx_->get_arena_allocator();
|
||||||
@ -712,7 +715,7 @@ int ObMulValueIndexLookupOp::save_doc_id_and_rowkey()
|
|||||||
|
|
||||||
int64_t rowkey_null_count = 0;
|
int64_t rowkey_null_count = 0;
|
||||||
|
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < index_column_cnt - 1; ++i) {
|
for (int64_t i = 0; OB_SUCC(ret) && i < main_rowkey_column_cnt; ++i) {
|
||||||
ObObj tmp_obj;
|
ObObj tmp_obj;
|
||||||
ObExpr *expr = index_ctdef_->result_output_.at(i);
|
ObExpr *expr = index_ctdef_->result_output_.at(i);
|
||||||
if (T_PSEUDO_GROUP_ID == expr->type_) {
|
if (T_PSEUDO_GROUP_ID == expr->type_) {
|
||||||
@ -730,10 +733,10 @@ int ObMulValueIndexLookupOp::save_doc_id_and_rowkey()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (OB_FAIL(ret)) {
|
if (OB_FAIL(ret)) {
|
||||||
} else if (rowkey_null_count != index_column_cnt - 1) {
|
} else if (rowkey_null_count != main_rowkey_column_cnt) {
|
||||||
++index_rowkey_cnt_;
|
++index_rowkey_cnt_;
|
||||||
++lookup_rowkey_cnt_;
|
++lookup_rowkey_cnt_;
|
||||||
ObRowkey main_rowkey(obj_ptr, index_column_cnt - 1);
|
ObRowkey main_rowkey(obj_ptr, main_rowkey_column_cnt);
|
||||||
if (OB_FAIL(sorter_.add_item(main_rowkey))) {
|
if (OB_FAIL(sorter_.add_item(main_rowkey))) {
|
||||||
LOG_WARN("filter mbr failed", K(ret));
|
LOG_WARN("filter mbr failed", K(ret));
|
||||||
}
|
}
|
||||||
@ -741,19 +744,19 @@ int ObMulValueIndexLookupOp::save_doc_id_and_rowkey()
|
|||||||
++aux_key_count_;
|
++aux_key_count_;
|
||||||
++lookup_rowkey_cnt_;
|
++lookup_rowkey_cnt_;
|
||||||
// last column is doc-id
|
// last column is doc-id
|
||||||
int64_t doc_id_idx = index_column_cnt - 1;
|
int64_t doc_id_idx = main_rowkey_column_cnt;
|
||||||
ObExpr* doc_id_expr = index_ctdef_->result_output_.at(doc_id_idx);
|
ObExpr* doc_id_expr = index_ctdef_->result_output_.at(doc_id_idx);
|
||||||
ObDatum& doc_id_datum = doc_id_expr->locate_expr_datum(*lookup_rtdef_->eval_ctx_);
|
ObDatum& doc_id_datum = doc_id_expr->locate_expr_datum(*lookup_rtdef_->eval_ctx_);
|
||||||
ObObj tmp_obj;
|
ObObj tmp_obj;
|
||||||
if (OB_FAIL(doc_id_datum.to_obj(tmp_obj, doc_id_expr->obj_meta_, doc_id_expr->obj_datum_map_))) {
|
if (OB_FAIL(doc_id_datum.to_obj(tmp_obj, doc_id_expr->obj_meta_, doc_id_expr->obj_datum_map_))) {
|
||||||
LOG_WARN("convert datum to obj failed", K(ret));
|
LOG_WARN("convert datum to obj failed", K(ret));
|
||||||
} else if (OB_FAIL(ob_write_obj(allocator, tmp_obj, obj_ptr[0]))) {
|
} else if (OB_FAIL(ob_write_obj(allocator, tmp_obj, obj_ptr[doc_id_idx]))) {
|
||||||
LOG_WARN("deep copy rowkey value failed", K(ret), K(tmp_obj));
|
LOG_WARN("deep copy rowkey value failed", K(ret), K(tmp_obj));
|
||||||
} else if (doc_id_datum.is_null()) {
|
} else if (doc_id_datum.is_null()) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_WARN("docid and rowkey can't both be null", K(ret));
|
LOG_WARN("docid and rowkey can't both be null", K(ret));
|
||||||
} else {
|
} else {
|
||||||
ObRowkey table_rowkey(obj_ptr, 1);
|
ObRowkey table_rowkey(&obj_ptr[doc_id_idx], 1);
|
||||||
if (OB_FAIL(aux_sorter_.add_item(table_rowkey))) {
|
if (OB_FAIL(aux_sorter_.add_item(table_rowkey))) {
|
||||||
LOG_WARN("filter mbr failed", K(ret));
|
LOG_WARN("filter mbr failed", K(ret));
|
||||||
}
|
}
|
||||||
@ -993,18 +996,20 @@ int ObMulValueIndexLookupOp::fetch_rowkey_from_aux()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int64_t rowkey_colunmn_cnt = doc_id_lookup_ctdef_->result_output_.count();
|
|
||||||
ObObj *obj_ptr = nullptr;
|
ObObj *obj_ptr = nullptr;
|
||||||
ObIAllocator &allocator = lookup_memctx_->get_arena_allocator();
|
ObIAllocator &allocator = lookup_memctx_->get_arena_allocator();
|
||||||
|
|
||||||
if (OB_ISNULL(obj_ptr = static_cast<ObObj*>(allocator.alloc(sizeof(ObObj) * rowkey_colunmn_cnt)))) {
|
const storage::ObTableReadInfo& read_info = lookup_ctdef_->table_param_.get_read_info();
|
||||||
|
int64_t main_rowkey_column_cnt = read_info.get_schema_rowkey_count();
|
||||||
|
|
||||||
|
if (OB_ISNULL(obj_ptr = static_cast<ObObj*>(allocator.alloc(sizeof(ObObj) * main_rowkey_column_cnt)))) {
|
||||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
LOG_WARN("allocate buffer failed", K(ret), K(rowkey_colunmn_cnt));
|
LOG_WARN("allocate buffer failed", K(ret), K(main_rowkey_column_cnt));
|
||||||
} else {
|
} else {
|
||||||
obj_ptr = new(obj_ptr) ObObj[rowkey_colunmn_cnt];
|
obj_ptr = new(obj_ptr) ObObj[main_rowkey_column_cnt];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < rowkey_colunmn_cnt; ++i) {
|
for (int64_t i = 0; OB_SUCC(ret) && i < main_rowkey_column_cnt; ++i) {
|
||||||
ObObj tmp_obj;
|
ObObj tmp_obj;
|
||||||
ObExpr *expr = doc_id_lookup_ctdef_->result_output_.at(i);
|
ObExpr *expr = doc_id_lookup_ctdef_->result_output_.at(i);
|
||||||
if (T_PSEUDO_GROUP_ID == expr->type_) {
|
if (T_PSEUDO_GROUP_ID == expr->type_) {
|
||||||
@ -1019,11 +1024,11 @@ int ObMulValueIndexLookupOp::fetch_rowkey_from_aux()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (OB_SUCC(ret)) {
|
if (OB_SUCC(ret)) {
|
||||||
ObRowkey table_rowkey(obj_ptr, rowkey_colunmn_cnt);
|
ObRowkey table_rowkey(obj_ptr, main_rowkey_column_cnt);
|
||||||
if (OB_FAIL(sorter_.add_item(table_rowkey))) {
|
if (OB_FAIL(sorter_.add_item(table_rowkey))) {
|
||||||
LOG_WARN("filter mbr failed", K(ret));
|
LOG_WARN("filter mbr failed", K(ret));
|
||||||
} else {
|
} else {
|
||||||
LOG_TRACE("add rowkey success", K(table_rowkey), K(obj_ptr), K(obj_ptr[0]), K(rowkey_colunmn_cnt));
|
LOG_TRACE("add rowkey success", K(table_rowkey), K(obj_ptr), K(obj_ptr[0]), K(main_rowkey_column_cnt));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -436,12 +436,12 @@ int ObExprJsonQuery::set_multivalue_result(ObEvalCtx& ctx,
|
|||||||
ObJsonOpaque apaque(str_bin, ObUserDefinedSQLType);
|
ObJsonOpaque apaque(str_bin, ObUserDefinedSQLType);
|
||||||
ObStringBuffer str_buff(&allocator);
|
ObStringBuffer str_buff(&allocator);
|
||||||
|
|
||||||
uint32_t element_count = json_base == nullptr ? 0 : json_base->element_count();
|
uint32_t element_count = (json_base == nullptr) ?
|
||||||
|
0 : (json_base->json_type() == ObJsonNodeType::J_ARRAY ? json_base->element_count() : 1);
|
||||||
|
|
||||||
uint8_t is_cast = false;
|
uint8_t is_cast = false;
|
||||||
uint64_t reserve_len = 0;
|
uint64_t reserve_len = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (OB_FAIL(ret)) {
|
if (OB_FAIL(ret)) {
|
||||||
} else if (OB_FAIL(check_enable_cast_index_array(json_base, false))) {
|
} else if (OB_FAIL(check_enable_cast_index_array(json_base, false))) {
|
||||||
LOG_WARN("failed to check index array size", K(ret));
|
LOG_WARN("failed to check index array size", K(ret));
|
||||||
|
|||||||
@ -2646,7 +2646,7 @@ int ObCreateTableResolver::resolve_index_node(const ParseNode *node)
|
|||||||
|
|
||||||
ObColumnNameHashWrapper budy_column_name_key(budy_column_schema->get_column_name_str());
|
ObColumnNameHashWrapper budy_column_name_key(budy_column_schema->get_column_name_str());
|
||||||
if (OB_FAIL(column_name_set_.set_refactored(budy_column_name_key))) {
|
if (OB_FAIL(column_name_set_.set_refactored(budy_column_name_key))) {
|
||||||
LOG_WARN("add column name to map failed", K(column_schema->get_column_name_str()), K(ret));
|
LOG_WARN("add column name to map failed", K(budy_column_schema->get_column_name_str()), K(ret));
|
||||||
} else if (OB_FAIL(add_sort_column(budy_sort_item))) {
|
} else if (OB_FAIL(add_sort_column(budy_sort_item))) {
|
||||||
LOG_WARN("failed to add sort item", K(ret));
|
LOG_WARN("failed to add sort item", K(ret));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user