fix core at ob_stmt_comparer
This commit is contained in:
@ -35,6 +35,7 @@ void ObStmtMapInfo::reset()
|
|||||||
is_group_equal_ = false;
|
is_group_equal_ = false;
|
||||||
having_map_.reset();
|
having_map_.reset();
|
||||||
is_having_equal_ = false;
|
is_having_equal_ = false;
|
||||||
|
is_order_equal_ = false;
|
||||||
select_item_map_.reset();
|
select_item_map_.reset();
|
||||||
is_select_item_equal_ = false;
|
is_select_item_equal_ = false;
|
||||||
is_distinct_equal_ = false;
|
is_distinct_equal_ = false;
|
||||||
@ -70,6 +71,7 @@ int ObStmtMapInfo::assign(const ObStmtMapInfo& other)
|
|||||||
is_cond_equal_ = other.is_cond_equal_;
|
is_cond_equal_ = other.is_cond_equal_;
|
||||||
is_group_equal_ = other.is_group_equal_;
|
is_group_equal_ = other.is_group_equal_;
|
||||||
is_having_equal_ = other.is_having_equal_;
|
is_having_equal_ = other.is_having_equal_;
|
||||||
|
is_order_equal_ = other.is_order_equal_;
|
||||||
is_select_item_equal_ = other.is_select_item_equal_;
|
is_select_item_equal_ = other.is_select_item_equal_;
|
||||||
is_distinct_equal_ = other.is_distinct_equal_;
|
is_distinct_equal_ = other.is_distinct_equal_;
|
||||||
}
|
}
|
||||||
@ -602,12 +604,13 @@ int ObStmtComparer::check_stmt_containment(const ObDMLStmt *first,
|
|||||||
second_count = second->get_order_item_size();
|
second_count = second->get_order_item_size();
|
||||||
if (0 == first_count && 0 == second_count) {
|
if (0 == first_count && 0 == second_count) {
|
||||||
map_info.is_order_equal_ = true;
|
map_info.is_order_equal_ = true;
|
||||||
|
} else if (first_count != second_count) {
|
||||||
|
// do nothing
|
||||||
} else if (OB_FAIL(compute_orderby_map(first_sel,
|
} else if (OB_FAIL(compute_orderby_map(first_sel,
|
||||||
second_sel,
|
second_sel,
|
||||||
first_sel->get_order_items(),
|
first_sel->get_order_items(),
|
||||||
second_sel->get_order_items(),
|
second_sel->get_order_items(),
|
||||||
map_info,
|
map_info,
|
||||||
map_info.order_map_,
|
|
||||||
match_count))) {
|
match_count))) {
|
||||||
LOG_WARN("failed to compute order item map", K(ret));
|
LOG_WARN("failed to compute order item map", K(ret));
|
||||||
} else if (match_count == first_count && match_count == second_count) {
|
} else if (match_count == first_count && match_count == second_count) {
|
||||||
@ -766,42 +769,31 @@ int ObStmtComparer::compute_orderby_map(const ObDMLStmt *first,
|
|||||||
const ObIArray<OrderItem> &first_orders,
|
const ObIArray<OrderItem> &first_orders,
|
||||||
const ObIArray<OrderItem> &second_orders,
|
const ObIArray<OrderItem> &second_orders,
|
||||||
ObStmtMapInfo &map_info,
|
ObStmtMapInfo &map_info,
|
||||||
ObIArray<int64_t> &order_map,
|
|
||||||
int64_t &match_count)
|
int64_t &match_count)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
ObSqlBitSet<> matched_items;
|
|
||||||
ObStmtCompareContext context(first, second, map_info, &first->get_query_ctx()->calculable_items_);
|
ObStmtCompareContext context(first, second, map_info, &first->get_query_ctx()->calculable_items_);
|
||||||
match_count = 0;
|
match_count = 0;
|
||||||
|
bool first_match_all = true;
|
||||||
if (OB_ISNULL(first) || OB_ISNULL(second) || OB_ISNULL(first->get_query_ctx())) {
|
if (OB_ISNULL(first) || OB_ISNULL(second) || OB_ISNULL(first->get_query_ctx())) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_WARN("get unexpected null", K(first), K(second), K(ret));
|
LOG_WARN("get unexpected null", K(first), K(second), K(ret));
|
||||||
} else if (OB_FAIL(order_map.prepare_allocate(first_orders.count()))) {
|
|
||||||
LOG_WARN("failed to preallocate array", K(ret));
|
|
||||||
} else {
|
} else {
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < first_orders.count(); ++i) {
|
for (int64_t i = 0; OB_SUCC(ret) && first_match_all && i < first_orders.count() && i < second_orders.count(); ++i) {
|
||||||
bool is_match = false;
|
bool is_match = false;
|
||||||
order_map.at(i) = OB_INVALID_ID;
|
if (first_orders.at(i).order_type_ != second_orders.at(i).order_type_) {
|
||||||
for (int64_t j = 0; OB_SUCC(ret) && !is_match && j < second_orders.count(); ++j) {
|
first_match_all = false;
|
||||||
if (matched_items.has_member(j)) {
|
} else if (OB_FAIL(is_same_condition(first_orders.at(i).expr_,
|
||||||
// do nothing
|
second_orders.at(i).expr_,
|
||||||
} else if (first_orders.at(i).order_type_ != second_orders.at(i).order_type_) {
|
context,
|
||||||
// do nothing
|
is_match))) {
|
||||||
} else if (OB_FAIL(is_same_condition(first_orders.at(i).expr_,
|
LOG_WARN("failed to check is condition equal", K(ret));
|
||||||
second_orders.at(j).expr_,
|
} else if (!is_match) {
|
||||||
context,
|
first_match_all = false;
|
||||||
is_match))) {
|
} else if (OB_FAIL(append(map_info.equal_param_map_, context.equal_param_info_))) {
|
||||||
LOG_WARN("failed to check is condition equal", K(ret));
|
LOG_WARN("failed to append exprs", K(ret));
|
||||||
} else if (!is_match) {
|
} else {
|
||||||
// do nothing
|
match_count++;
|
||||||
} else if (OB_FAIL(append(map_info.equal_param_map_, context.equal_param_info_))) {
|
|
||||||
LOG_WARN("failed to append exprs", K(ret));
|
|
||||||
} else if (OB_FAIL(matched_items.add_member(j))) {
|
|
||||||
LOG_WARN("failed to add member", K(ret));
|
|
||||||
} else {
|
|
||||||
match_count++;
|
|
||||||
order_map.at(i) = j;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1304,12 +1296,13 @@ int ObStmtComparer::compare_set_stmt(const ObSelectStmt *first,
|
|||||||
int64_t match_count = 0;
|
int64_t match_count = 0;
|
||||||
if (0 == first_count && 0 == second_count) {
|
if (0 == first_count && 0 == second_count) {
|
||||||
map_info.is_order_equal_ = true;
|
map_info.is_order_equal_ = true;
|
||||||
|
} else if (first_count != second_count) {
|
||||||
|
// do nothing
|
||||||
} else if (OB_FAIL(compute_orderby_map(first,
|
} else if (OB_FAIL(compute_orderby_map(first,
|
||||||
second,
|
second,
|
||||||
first->get_order_items(),
|
first->get_order_items(),
|
||||||
second->get_order_items(),
|
second->get_order_items(),
|
||||||
map_info,
|
map_info,
|
||||||
map_info.order_map_,
|
|
||||||
match_count))) {
|
match_count))) {
|
||||||
LOG_WARN("failed to compute order item map", K(ret));
|
LOG_WARN("failed to compute order item map", K(ret));
|
||||||
} else if (match_count == first_count && match_count == second_count) {
|
} else if (match_count == first_count && match_count == second_count) {
|
||||||
|
|||||||
@ -43,7 +43,6 @@ enum QueryRelation
|
|||||||
common::ObSEArray<int64_t, 4> cond_map_;
|
common::ObSEArray<int64_t, 4> cond_map_;
|
||||||
common::ObSEArray<int64_t, 4> group_map_;
|
common::ObSEArray<int64_t, 4> group_map_;
|
||||||
common::ObSEArray<int64_t, 4> having_map_;
|
common::ObSEArray<int64_t, 4> having_map_;
|
||||||
common::ObSEArray<int64_t, 4> order_map_;
|
|
||||||
common::ObSEArray<int64_t, 4> select_item_map_;
|
common::ObSEArray<int64_t, 4> select_item_map_;
|
||||||
bool is_table_equal_;
|
bool is_table_equal_;
|
||||||
bool is_from_equal_;
|
bool is_from_equal_;
|
||||||
@ -80,7 +79,9 @@ enum QueryRelation
|
|||||||
K_(having_map),
|
K_(having_map),
|
||||||
K_(select_item_map),
|
K_(select_item_map),
|
||||||
K_(equal_param_map),
|
K_(equal_param_map),
|
||||||
K_(view_select_item_map));
|
K_(view_select_item_map),
|
||||||
|
K_(is_order_equal),
|
||||||
|
K_(is_distinct_equal));
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StmtCompareHelper {
|
struct StmtCompareHelper {
|
||||||
@ -236,7 +237,6 @@ public:
|
|||||||
const ObIArray<OrderItem> &first_orders,
|
const ObIArray<OrderItem> &first_orders,
|
||||||
const ObIArray<OrderItem> &second_orders,
|
const ObIArray<OrderItem> &second_orders,
|
||||||
ObStmtMapInfo &map_info,
|
ObStmtMapInfo &map_info,
|
||||||
ObIArray<int64_t> &order_map,
|
|
||||||
int64_t &match_count);
|
int64_t &match_count);
|
||||||
|
|
||||||
static int compute_from_items_map(const ObDMLStmt *first,
|
static int compute_from_items_map(const ObDMLStmt *first,
|
||||||
|
|||||||
Reference in New Issue
Block a user