[bp2] batch patch code from 31x to opensource
This commit is contained in:
@ -56,6 +56,7 @@ int IndexDMLInfo::deep_copy(ObRawExprFactory& expr_factory, const IndexDMLInfo&
|
||||
rowkey_cnt_ = other.rowkey_cnt_;
|
||||
need_filter_null_ = other.need_filter_null_;
|
||||
distinct_algo_ = other.distinct_algo_;
|
||||
index_type_ = other.index_type_;
|
||||
assignments_.reset();
|
||||
if (OB_FAIL(column_exprs_.assign(other.column_exprs_))) {
|
||||
LOG_WARN("failed to assign column exprs", K(ret));
|
||||
|
||||
@ -29,7 +29,8 @@ public:
|
||||
part_cnt_(common::OB_INVALID_ID),
|
||||
all_part_num_(0),
|
||||
need_filter_null_(false),
|
||||
distinct_algo_(T_DISTINCT_NONE)
|
||||
distinct_algo_(T_DISTINCT_NONE),
|
||||
index_type_(share::schema::INDEX_TYPE_IS_NOT)
|
||||
{}
|
||||
inline void reset()
|
||||
{
|
||||
@ -47,6 +48,7 @@ public:
|
||||
assignments_.reset();
|
||||
need_filter_null_ = false;
|
||||
distinct_algo_ = T_DISTINCT_NONE;
|
||||
index_type_ = share::schema::INDEX_TYPE_IS_NOT;
|
||||
calc_part_id_exprs_.reset();
|
||||
}
|
||||
int64_t to_explain_string(char* buf, int64_t buf_len, ExplainType type) const;
|
||||
@ -79,6 +81,7 @@ public:
|
||||
}
|
||||
seed = do_hash(need_filter_null_, seed);
|
||||
seed = do_hash(distinct_algo_, seed);
|
||||
seed = do_hash(index_type_, seed);
|
||||
for (int64_t i = 0; i < primary_key_ids_.count(); ++i) {
|
||||
seed = do_hash(primary_key_ids_.at(i), seed);
|
||||
}
|
||||
@ -120,6 +123,7 @@ public:
|
||||
ObAssignments assignments_;
|
||||
bool need_filter_null_;
|
||||
DistinctType distinct_algo_;
|
||||
share::schema::ObIndexType index_type_;
|
||||
common::ObSEArray<ObRawExpr*, 8, common::ModulePageAllocator, true> calc_part_id_exprs_;
|
||||
|
||||
common::ObSEArray<uint64_t, common::OB_PREALLOCATED_NUM, common::ModulePageAllocator, true> primary_key_ids_;
|
||||
|
||||
@ -422,6 +422,7 @@ int ObDeleteResolver::resolve_global_delete_index_info(const TableItem& table_it
|
||||
index_dml_info.index_tid_ = index_tid[i];
|
||||
index_dml_info.rowkey_cnt_ = index_schema->get_rowkey_column_num();
|
||||
index_dml_info.part_cnt_ = index_schema->get_partition_cnt();
|
||||
index_dml_info.index_type_ = index_schema->get_index_type();
|
||||
if (OB_FAIL(index_schema->get_index_name(index_dml_info.index_name_))) {
|
||||
LOG_WARN("get index name from index schema failed", K(ret));
|
||||
} else if (OB_FAIL(delete_stmt->add_multi_table_dml_info(index_dml_info))) {
|
||||
|
||||
@ -140,6 +140,7 @@ int ObTableAssignment::deep_copy(ObRawExprFactory& expr_factory, const ObTableAs
|
||||
int ret = OB_SUCCESS;
|
||||
table_id_ = other.table_id_;
|
||||
is_update_part_key_ = other.is_update_part_key_;
|
||||
is_update_unique_key_ = other.is_update_unique_key_;
|
||||
if (OB_FAIL(assignments_.prepare_allocate(other.assignments_.count()))) {
|
||||
LOG_WARN("failed to prepare allocate array", K(ret));
|
||||
}
|
||||
@ -159,6 +160,7 @@ int ObTableAssignment::assign(const ObTableAssignment& other)
|
||||
} else {
|
||||
table_id_ = other.table_id_;
|
||||
is_update_part_key_ = other.is_update_part_key_;
|
||||
is_update_unique_key_ = other.is_update_unique_key_;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -564,7 +564,8 @@ struct ObMaterializedViewContext {
|
||||
typedef common::ObSEArray<ObAssignment, common::OB_PREALLOCATED_NUM, common::ModulePageAllocator, true> ObAssignments;
|
||||
/// all assignments of one table
|
||||
struct ObTableAssignment {
|
||||
ObTableAssignment() : table_id_(OB_INVALID_ID), assignments_(), is_update_part_key_(false)
|
||||
ObTableAssignment()
|
||||
: table_id_(OB_INVALID_ID), assignments_(), is_update_part_key_(false), is_update_unique_key_(false)
|
||||
{}
|
||||
|
||||
int deep_copy(ObRawExprFactory& expr_factory, const ObTableAssignment& other);
|
||||
@ -579,14 +580,15 @@ struct ObTableAssignment {
|
||||
seed = do_hash(assignments_.at(j), seed);
|
||||
}
|
||||
seed = do_hash(is_update_part_key_, seed);
|
||||
|
||||
seed = do_hash(is_update_unique_key_, seed);
|
||||
return seed;
|
||||
}
|
||||
|
||||
uint64_t table_id_;
|
||||
ObAssignments assignments_;
|
||||
bool is_update_part_key_;
|
||||
TO_STRING_KV(K_(table_id), N_ASSIGN, assignments_, K_(is_update_part_key));
|
||||
bool is_update_unique_key_;
|
||||
TO_STRING_KV(K_(table_id), N_ASSIGN, assignments_, K_(is_update_part_key), K_(is_update_unique_key));
|
||||
};
|
||||
/// multi-table assignments
|
||||
typedef common::ObSEArray<ObTableAssignment, 3, common::ModulePageAllocator, true> ObTablesAssignments;
|
||||
|
||||
@ -181,8 +181,7 @@ int ObInsertResolver::resolve(const ParseNode& parse_tree)
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret) && insert_stmt->value_from_select() && session_info_->use_static_typing_engine() &&
|
||||
!insert_stmt->get_insert_up()) {
|
||||
if (OB_SUCC(ret) && insert_stmt->value_from_select() && !insert_stmt->get_insert_up()) {
|
||||
if (OB_FAIL(fill_index_dml_info_column_conv_exprs())) {
|
||||
LOG_WARN("fail to fill index dml info column conv exprs", K(ret));
|
||||
}
|
||||
@ -345,6 +344,7 @@ int ObInsertResolver::resolve_multi_table_dml_info(uint64_t table_offset /*defau
|
||||
index_dml_info.index_tid_ = index_schema->get_table_id();
|
||||
index_dml_info.rowkey_cnt_ = index_schema->get_rowkey_column_num();
|
||||
index_dml_info.part_cnt_ = index_schema->get_partition_cnt();
|
||||
index_dml_info.index_type_ = index_schema->get_index_type();
|
||||
if (OB_FAIL(index_schema->get_index_name(index_dml_info.index_name_))) {
|
||||
LOG_WARN("get index name from index schema failed", K(ret));
|
||||
} else if (OB_FAIL(insert_stmt->add_multi_table_dml_info(index_dml_info))) {
|
||||
|
||||
@ -231,8 +231,7 @@ int ObUpdateResolver::resolve(const ParseNode& parse_tree)
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
// Distribute the centralized assignment information to each index, and do assignment updates for each index
|
||||
if (OB_FAIL(update_stmt->refill_index_assignment_info(
|
||||
if (OB_FAIL(update_stmt->refill_global_index_dml_info(
|
||||
*params_.expr_factory_, session_info_->use_static_typing_engine()))) {
|
||||
LOG_WARN("init index assignment info failed", K(ret));
|
||||
}
|
||||
@ -602,6 +601,7 @@ int ObUpdateResolver::resolve_multi_table_dml_info(const ObTableAssignment& ta,
|
||||
index_dml_info.part_cnt_ = index_schema->get_partition_cnt();
|
||||
index_dml_info.all_part_num_ = index_schema->get_all_part_num();
|
||||
index_dml_info.rowkey_cnt_ = index_schema->get_rowkey_column_num();
|
||||
index_dml_info.index_type_ = index_schema->get_index_type();
|
||||
if (OB_FAIL(index_schema->get_index_name(index_dml_info.index_name_))) {
|
||||
LOG_WARN("get index name from index schema failed", K(ret));
|
||||
} else if (OB_FAIL(update_stmt->add_multi_table_dml_info(index_dml_info))) {
|
||||
|
||||
@ -47,7 +47,7 @@ int ObUpdateStmt::deep_copy_stmt_struct(
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(refill_index_assignment_info(expr_factory, other.use_static_typing_engine_))) {
|
||||
if (OB_FAIL(refill_global_index_dml_info(expr_factory, other.use_static_typing_engine_))) {
|
||||
LOG_WARN("fail refill index assignment info", K(ret));
|
||||
}
|
||||
}
|
||||
@ -315,6 +315,7 @@ const ObTablesAssignments* ObUpdateStmt::get_slice_from_all_table_assignments(
|
||||
LOG_WARN("fail copy array", K(ret));
|
||||
} else {
|
||||
bool is_update_part_key = false;
|
||||
bool is_update_unique_key = false;
|
||||
if (dml_index_info.all_part_num_ > 1) { // Only partition tables have part_key
|
||||
for (int i = 0; i < dml_index_info.assignments_.count(); ++i) {
|
||||
uint64_t col_id = dml_index_info.assignments_.at(i).column_expr_->get_column_id();
|
||||
@ -326,7 +327,22 @@ const ObTablesAssignments* ObUpdateStmt::get_slice_from_all_table_assignments(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (share::schema::ObSimpleTableSchemaV2::is_global_unique_index_table(dml_index_info.index_type_)) {
|
||||
for (int i = 0; i < dml_index_info.assignments_.count(); ++i) {
|
||||
uint64_t col_id = dml_index_info.assignments_.at(i).column_expr_->get_column_id();
|
||||
for (int j = 0; j < dml_index_info.primary_key_ids_.count(); ++j) {
|
||||
if (dml_index_info.primary_key_ids_.at(j) == col_id) {
|
||||
is_update_unique_key = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// [pdml]: 对于每个索引表单独计算,不应该继承主表的属性
|
||||
table_assignments->is_update_part_key_ = is_update_part_key;
|
||||
table_assignments->is_update_unique_key_ = is_update_unique_key;
|
||||
table_assignments->table_id_ = dml_index_info.table_id_;
|
||||
}
|
||||
|
||||
@ -342,7 +358,7 @@ const ObTablesAssignments* ObUpdateStmt::get_slice_from_all_table_assignments(
|
||||
return tables_assignments;
|
||||
}
|
||||
|
||||
int ObUpdateStmt::refill_index_assignment_info(ObRawExprFactory& expr_factory, bool use_static_typing_engine)
|
||||
int ObUpdateStmt::refill_global_index_dml_info(ObRawExprFactory& expr_factory, bool use_static_typing_engine)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const ObTablesAssignments& table_assign = get_tables_assignments();
|
||||
@ -358,7 +374,6 @@ int ObUpdateStmt::refill_index_assignment_info(ObRawExprFactory& expr_factory, b
|
||||
}
|
||||
}
|
||||
}
|
||||
use_static_typing_engine_ = use_static_typing_engine;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@ -75,7 +75,7 @@ public:
|
||||
virtual int has_special_expr(const ObExprInfoFlag, bool& has) const override;
|
||||
virtual int replace_inner_stmt_expr(
|
||||
const common::ObIArray<ObRawExpr*>& other_exprs, const common::ObIArray<ObRawExpr*>& new_exprs) override;
|
||||
int refill_index_assignment_info(ObRawExprFactory& expr_factory, bool use_static_typing_engine);
|
||||
int refill_global_index_dml_info(ObRawExprFactory& expr_factory, bool use_static_typing_engine);
|
||||
const ObTablesAssignments* get_slice_from_all_table_assignments(
|
||||
common::ObIAllocator& allocator, int64_t table_idx, int64_t index_idx) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user